Bug#1052690: grub2: post-install script overrides manual changes to GRUB_DISABLE_OS_PROBER
Jordi Bosveld
jordi at jotti.nl
Sun Oct 8 14:59:52 BST 2023
Hello all,
It seems that the debconf setting 'grub2/enable_os_prober' gets reset to
false every time the package is reconfigured, possibly as part of a
package upgrade or reinstallation. When one invokes 'dpkg-reconfigure
grub-efi-amd64' (or grub-pc etc.) the previously chosen answer to the
'enable_os_prober' query is forgotten and the preselected answer is now
'No'. When dpkg-reconfigure is run with the '-phigh' option this happens
silently and os-prober is once again disabled. The same occurs when
reinstalling or upgrading the corresponding grub package.
> Additional information: It turns out that the post-install script
> patches /etc/default/grub here:
Yes, but by the time this postinst script is executed, debconf will have
already been misconfigured and the 'db_get grub2/enable_os_prober'
command as seen on line 401 will receive a possibly incorrect 'false'.
The double negative used in the configuration is a bit confusing,
especially once you deal with a commented line (meaning its contents are
disabled) declaring that the variable that dictates whether or not to
disable a certain setting should be set to disabled. The package script
'config' warns the reader 'Watch for the inverted logic here', and
ironically this is where the bug is at. I have attached a patch that
will rectify this issue. For simplicity I decided to compare the config
variable GRUB_DISABLE_OS_PROBER from /etc/default/grub to 'false', i.e.
a value of exactly 'false' will set the 'grub2/enable_os_prober' debconf
setting to 'true' and all other contents will result in
'grub2/enable_os_prober = false'. One could possibly expand the check to
include 0, no, False, FALSE and whatnot, but that is ultimately up to
the maintainers and I wanted to keep things simple. With this patch
applied the previously chosen answer is remembered and a
(re)installation or reconfiguration no longer changes the setting. Also,
manually uncommenting the line with GRUB_DISABLE_OS_PROBER=false (as
mentioned in the package changelog) will now result in debconf properly
changing the 'grub2/enable_os_prober' setting to 'true' the next time it
is invoked, so on upgrades and such that line will no longer be
rewritten into something that disables os-prober. Changing it to
anything other than 'false' will result in 'grub2/enable_os_prober' to
be set to 'false', and consequently the line containing
GRUB_DISABLE_OS_PROBER=whatever in /etc/default/grub will get rewritten
to the default commented '#GRUB_DISABLE_OS_PROBER=false', which means
the setting will now default to 'true', as before.
--
Kind regards,
Jordi Bosveld
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grub-devel/attachments/20231008/f40b1052/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: keep-os-prober-setting.diff
Type: text/x-patch
Size: 561 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-grub-devel/attachments/20231008/f40b1052/attachment.bin>
More information about the Pkg-grub-devel
mailing list