grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* Setting config_directory to prefix at grub launch time
@ 2016-01-15 10:16 Arbiel (gmx)
  2016-01-15 10:22 ` Andrei Borzenkov
  0 siblings, 1 reply; 7+ messages in thread
From: Arbiel (gmx) @ 2016-01-15 10:16 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 871 bytes --]

In the Ubuntu distributions, there is a /etc/grub.d/41_custom which
creates the following lines in the grub configuration file

### BEGIN /etc/grub.d/41_custom ###
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;
fi
### END /etc/grub.d/41_custom ###

In the custom.cfg file, I use the source command to insert some private
scripts stored in a ${prefix}/greffons/ directory. However, when the
configuration file has been the target of a configfile command, the
source of my private scripts becomes ${config_file}/greffons/. To be
compatible to all situations, I need to have config_file set to prefix
at the beginning of grub's running, as at this very moment prefix also
is the directory of the configuration file.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Setting config_directory to prefix at grub launch time
  2016-01-15 10:16 Setting config_directory to prefix at grub launch time Arbiel (gmx)
@ 2016-01-15 10:22 ` Andrei Borzenkov
  2016-01-15 11:32   ` Arbiel (gmx)
  0 siblings, 1 reply; 7+ messages in thread
From: Andrei Borzenkov @ 2016-01-15 10:22 UTC (permalink / raw)
  To: The development of GNU GRUB

On Fri, Jan 15, 2016 at 1:16 PM, Arbiel (gmx) <arbiel.perlacremaz@gmx.fr> wrote:
> In the Ubuntu distributions, there is a /etc/grub.d/41_custom which
> creates the following lines in the grub configuration file
>
> ### BEGIN /etc/grub.d/41_custom ###
> 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;
> fi
> ### END /etc/grub.d/41_custom ###
>
> In the custom.cfg file, I use the source command to insert some private
> scripts stored in a ${prefix}/greffons/ directory. However, when the
> configuration file has been the target of a configfile command, the
> source of my private scripts becomes ${config_file}/greffons/. To be
> compatible to all situations, I need to have config_file set to prefix
> at the beginning of grub's running, as at this very moment prefix also
> is the directory of the configuration file.
>

config_directory is managed by grub to point to current source of
configuration. If you always need to use prefix, just always use
prefix. I'm afraid I do not understand the problem.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Setting config_directory to prefix at grub launch time
  2016-01-15 10:22 ` Andrei Borzenkov
@ 2016-01-15 11:32   ` Arbiel (gmx)
  2016-01-15 14:18     ` Arbiel (gmx)
  0 siblings, 1 reply; 7+ messages in thread
From: Arbiel (gmx) @ 2016-01-15 11:32 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 1977 bytes --]



Le 15/01/2016 11:22, Andrei Borzenkov a écrit :
> On Fri, Jan 15, 2016 at 1:16 PM, Arbiel (gmx) <arbiel.perlacremaz@gmx.fr> wrote:
>> In the Ubuntu distributions, there is a /etc/grub.d/41_custom which
>> creates the following lines in the grub configuration file
>>
>> ### BEGIN /etc/grub.d/41_custom ###
>> 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;
>> fi
>> ### END /etc/grub.d/41_custom ###
>>
>> In the custom.cfg file, I use the source command to insert some private
>> scripts stored in a ${prefix}/greffons/ directory. However, when the
>> configuration file has been the target of a configfile command, the
>> source of my private scripts becomes ${config_file}/greffons/. To be
>> compatible to all situations, I need to have config_file set to prefix
>> at the beginning of grub's running, as at this very moment prefix also
>> is the directory of the configuration file.
>>
> config_directory is managed by grub to point to current source of
> configuration. 
No, config_directory is unset when grub executes the configuration file
pointed to by core.img. There is no config_directory listed by the "set"
command (using|grub-mkconfig (GRUB) 2.02~beta2-9ubuntu1.4|).
It seems to only be set by the configfile command.
> If you always need to use prefix, just always use
> prefix. I'm afraid I do not understand the problem.
I cannot always use prefix as I want to access the scripts located in
the same directory as the current configuration file. This is the reason
why I would be glad to always use config_directory, which is
unfortunately unset when the current configuration file is the one
core.img points to.
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Setting config_directory to prefix at grub launch time
  2016-01-15 11:32   ` Arbiel (gmx)
@ 2016-01-15 14:18     ` Arbiel (gmx)
  2016-01-15 17:12       ` Andrei Borzenkov
  0 siblings, 1 reply; 7+ messages in thread
From: Arbiel (gmx) @ 2016-01-15 14:18 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 3236 bytes --]



Le 15/01/2016 12:32, Arbiel (gmx) a écrit :
>
> Le 15/01/2016 11:22, Andrei Borzenkov a écrit :
>> On Fri, Jan 15, 2016 at 1:16 PM, Arbiel (gmx) <arbiel.perlacremaz@gmx.fr> wrote:
>>> In the Ubuntu distributions, there is a /etc/grub.d/41_custom which
>>> creates the following lines in the grub configuration file
>>>
>>> ### BEGIN /etc/grub.d/41_custom ###
>>> 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;
>>> fi
>>> ### END /etc/grub.d/41_custom ###
>>>
>>> In the custom.cfg file, I use the source command to insert some private
>>> scripts stored in a ${prefix}/greffons/ directory. However, when the
>>> configuration file has been the target of a configfile command, the
>>> source of my private scripts becomes ${config_file}/greffons/. To be
>>> compatible to all situations, I need to have config_file set to prefix
>>> at the beginning of grub's running, as at this very moment prefix also
>>> is the directory of the configuration file.
>>>
>> config_directory is managed by grub to point to current source of
>> configuration. 
> No, config_directory is unset when grub executes the configuration file
> pointed to by core.img. There is no config_directory listed by the "set"
> command (using|grub-mkconfig (GRUB) 2.02~beta2-9ubuntu1.4|).
> It seems to only be set by the configfile command.
Sorry for the disturbance. config_directory is set even when the current
configuration file is the one pointed to by core.img. I run a new test
echoing its value as the first line of the file. Its value is the same
as the value of prefix.
>> If you always need to use prefix, just always use
>> prefix. I'm afraid I do not understand the problem.
> I cannot always use prefix as I want to access the scripts located in
> the same directory as the current configuration file. This is the reason
> why I would be glad to always use config_directory, which is
> unfortunately unset when the current configuration file is the one
> core.img points to.
However, I confirm config_directory is not listed in the output of the
set command. Here is what I got

?=0
cmdpath=(hd0)
color_highlight=black/light-gray
color_normal=light-gray/black
defaut=0
feature_200_final=y
feature_chainloader_bpb=y
feature_default_font_path=y
feature_menuentry_id=y
feature_menuentry_option=y
feature_nativedisk_cmd=y
feature_ntdlr=y
feature_platform_search_hint=y
feature_timeout_style=y
font=unicode
gfxmode=auto
grub_cpu=i386
grub_platform=pc
lang=fr_FR
linux_gfx_mode=keep
locale_dir=(hd0,msdos1)/boot/grub/locale
menu_color_highlight=black/light-gray
menu_color_normal=white/black
menuentry-id=--id
pager=
prefix=(hd0,msdos1)/boot/grub
root=hd0,msdos1
secondary_locale_dir=
timeout_style=menu

>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
>>
>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Setting config_directory to prefix at grub launch time
  2016-01-15 14:18     ` Arbiel (gmx)
@ 2016-01-15 17:12       ` Andrei Borzenkov
  2016-01-15 21:40         ` Arbiel (gmx)
  0 siblings, 1 reply; 7+ messages in thread
From: Andrei Borzenkov @ 2016-01-15 17:12 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 573 bytes --]

15.01.2016 17:18, Arbiel (gmx) пишет:
> However, I confirm config_directory is not listed in the output of the
> set command.

That's correct. config_directory is set when executing config file and
unset when processing is completed. When you are in CLI, there is no
config file, so it is not set. Each configfile command is executed in
own environment which is destroyed when it is finished. You may have
multiple (also nested) configfile invocations.  What would you set it
to? config_directory has no meaningful value outside of configfile
processing.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Setting config_directory to prefix at grub launch time
  2016-01-15 17:12       ` Andrei Borzenkov
@ 2016-01-15 21:40         ` Arbiel (gmx)
  2016-01-16  6:25           ` Andrei Borzenkov
  0 siblings, 1 reply; 7+ messages in thread
From: Arbiel (gmx) @ 2016-01-15 21:40 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 1060 bytes --]



Le 15/01/2016 18:12, Andrei Borzenkov a écrit :
> 15.01.2016 17:18, Arbiel (gmx) пишет:
>> However, I confirm config_directory is not listed in the output of the
>> set command.
> That's correct. config_directory is set when executing config file and
> unset when processing is completed.
I understand the processing of a file to come to its end when grub
displays its menu.
> When you are in CLI, there is no
> config file, so it is not set. Each configfile command is executed in
> own environment which is destroyed when it is finished. You may have
> multiple (also nested) configfile invocations.  What would you set it
> to?
I'm just happy with that. I only made a wrong deduction based on the
fact that I did not see config_directory in the set's output.
> config_directory has no meaningful value outside of configfile
> processing.
That's clear.
>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Setting config_directory to prefix at grub launch time
  2016-01-15 21:40         ` Arbiel (gmx)
@ 2016-01-16  6:25           ` Andrei Borzenkov
  0 siblings, 0 replies; 7+ messages in thread
From: Andrei Borzenkov @ 2016-01-16  6:25 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1444 bytes --]

16.01.2016 00:40, Arbiel (gmx) пишет:
> 
> 
> Le 15/01/2016 18:12, Andrei Borzenkov a écrit :
>> 15.01.2016 17:18, Arbiel (gmx) пишет:
>>> However, I confirm config_directory is not listed in the output of the
>>> set command.
>> That's correct. config_directory is set when executing config file and
>> unset when processing is completed.
> I understand the processing of a file to come to its end when grub
> displays its menu.

Yes. At this point config_directory gets unset before displaying menu,
if any menu was defined during config file processing.

>> When you are in CLI, there is no
>> config file, so it is not set. Each configfile command is executed in
>> own environment which is destroyed when it is finished. You may have
>> multiple (also nested) configfile invocations.  What would you set it
>> to?
> I'm just happy with that. I only made a wrong deduction based on the
> fact that I did not see config_directory in the set's output.
>> config_directory has no meaningful value outside of configfile
>> processing.
> That's clear.
>>
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
> 
> 
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-01-16  6:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-15 10:16 Setting config_directory to prefix at grub launch time Arbiel (gmx)
2016-01-15 10:22 ` Andrei Borzenkov
2016-01-15 11:32   ` Arbiel (gmx)
2016-01-15 14:18     ` Arbiel (gmx)
2016-01-15 17:12       ` Andrei Borzenkov
2016-01-15 21:40         ` Arbiel (gmx)
2016-01-16  6:25           ` Andrei Borzenkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).