diff --git a/ChangeLog b/ChangeLog index 59d00a865..6c6c7a341 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-05-27 Vladimir Serbinenko + + * grub-core/normal/main.c (read_config_file): Provide config_file and + config_directory. + * util/grub.d/41_custom.in: Use config_directoy when available. + 2012-05-27 Vladimir Serbinenko * grub-core/fs/bfs.c (iterate_in_b_tree): Add missing NESTED_FUNC_ATTR. diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index 1963fe485..feeb1ef13 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -138,6 +138,8 @@ static grub_menu_t read_config_file (const char *config) { grub_file_t file; + const char *old_file, *old_dir; + char *config_dir, *ptr = 0; auto grub_err_t getline (char **line, int cont); grub_err_t getline (char **line, int cont __attribute__ ((unused))) @@ -176,6 +178,19 @@ read_config_file (const char *config) if (! file) return 0; + old_file = grub_env_get ("config_file"); + old_dir = grub_env_get ("config_directory"); + grub_env_set ("config_file", config); + config_dir = grub_strdup (config); + if (config_dir) + ptr = grub_strrchr (config_dir, '/'); + if (ptr) + *ptr = 0; + grub_env_set ("config_directory", config_dir); + + grub_env_export ("config_file"); + grub_env_export ("config_directory"); + while (1) { char *line; @@ -191,6 +206,15 @@ read_config_file (const char *config) grub_free (line); } + if (old_file) + grub_env_set ("config_file", old_file); + else + grub_env_unset ("config_file"); + if (old_dir) + grub_env_set ("config_directory", old_dir); + else + grub_env_unset ("config_directory"); + grub_file_close (file); return newmenu; diff --git a/util/grub.d/41_custom.in b/util/grub.d/41_custom.in index 64d691c55..fcc21a987 100644 --- a/util/grub.d/41_custom.in +++ b/util/grub.d/41_custom.in @@ -1,6 +1,8 @@ #!/bin/sh cat <