Error when removing GRUB together with grub-btrfs using “apt purge” command.
Description
In case you want to completely remove GRUB and grub-btrfs together, for example to switch to systemd-boot, the error mentioned below occurs. With the minor change mentioned under Solution, the problem no longer occurs and the apt command runs without errors.
Environment
OS: siduction (debian sid)
grub-btrfs version 4.11-0~1siduction3
Kernel version 6.12.8-1-siduction-amd64
Error message
After the command “apt purge grub-* grub-btrfs” I received this error:
Purging configuration files for grub-btrfs (4.11-0~1siduction3) ...
/var/lib/dpkg/info/grub-btrfs.postrm: 23: update-grub: not found
dpkg: error processing package grub-btrfs (--purge):
installed grub-btrfs package post-removal script subprocess returned error exit status 127
Purging configuration files for grub-efi-amd64-bin (2.12-5) ...
Errors were encountered while processing:
grub-btrfs
Solution
Change the file /var/lib/dpkg/info/grub-btrfs.postrm from line 21 from
case "$1" in
purge)
update-grub
;;
to
case "$1" in
purge)
if [ -x /usr/sbin/update-grub ]; then
update-grub
fi
;;
The code is self explanatory.
Possible alternatives
Regarding your last commit 129c3d84
Lintian doesn't like that and complains: W: grub-btrfs: command-with-path-in-maintainer-script /usr/sbin/update-grub [control/postinst:22] (plain script)
Line 23 could also have this content. But I can't check if warnings occur in Lintian.
if bash -n update-grub; then
or
if sh -n /usr/sbin/update-grub; then
With kind regards Axel Konrad (ak-li1)