* 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.
This commit is contained in:
parent
9da59c3275
commit
40e80b9403
3 changed files with 33 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2012-05-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* 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 <phcoder@gmail.com>
|
2012-05-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/fs/bfs.c (iterate_in_b_tree): Add missing NESTED_FUNC_ATTR.
|
* grub-core/fs/bfs.c (iterate_in_b_tree): Add missing NESTED_FUNC_ATTR.
|
||||||
|
|
|
@ -138,6 +138,8 @@ static grub_menu_t
|
||||||
read_config_file (const char *config)
|
read_config_file (const char *config)
|
||||||
{
|
{
|
||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
|
const char *old_file, *old_dir;
|
||||||
|
char *config_dir, *ptr = 0;
|
||||||
|
|
||||||
auto grub_err_t getline (char **line, int cont);
|
auto grub_err_t getline (char **line, int cont);
|
||||||
grub_err_t getline (char **line, int cont __attribute__ ((unused)))
|
grub_err_t getline (char **line, int cont __attribute__ ((unused)))
|
||||||
|
@ -176,6 +178,19 @@ read_config_file (const char *config)
|
||||||
if (! file)
|
if (! file)
|
||||||
return 0;
|
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)
|
while (1)
|
||||||
{
|
{
|
||||||
char *line;
|
char *line;
|
||||||
|
@ -191,6 +206,15 @@ read_config_file (const char *config)
|
||||||
grub_free (line);
|
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);
|
grub_file_close (file);
|
||||||
|
|
||||||
return newmenu;
|
return newmenu;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
if [ -f \$prefix/custom.cfg ]; then
|
if [ -f \${config_directory}/custom.cfg ]; then
|
||||||
|
source \${config_directory}/custom.cfg
|
||||||
|
elif [ -z "\${config_directory}" -a -f \$prefix/custom.cfg ]; then
|
||||||
source \$prefix/custom.cfg;
|
source \$prefix/custom.cfg;
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in a new issue