Bug#992915: grub-legacy: Removing kernel image fails: /usr/sbin/update-grub: line 273: tempfile: command not found
Axel Beckert
abe at debian.org
Tue Aug 24 23:31:20 BST 2021
Package: grub-legacy
Severity: serious
Version: 0.97-77
Tags: patch
Control: affects -1 src:linux
Removing a kernel image fails as follows due to grub-legacy's
update-grub uses the deprecated and now removed tempfile utility:
Removing linux-image-5.10.0-6-amd64 (5.10.28-1) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.10.0-6-amd64
/etc/kernel/postrm.d/zz-update-grub:
Searching for GRUB installation directory ... found: /boot/grub
/usr/sbin/update-grub: line 273: tempfile: command not found
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.10.0-6-amd64 (--remove):
installed linux-image-5.10.0-6-amd64 package post-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
linux-image-5.10.0-6-amd64
Processing was halted because there were too many errors.
This currently blocks all further apt activities.
The following patch seems to fix the issue:
--- /usr/sbin/update-grub~ 2018-05-05 14:45:49.000000000 +0200
+++ /usr/sbin/update-grub 2021-08-25 00:26:21.527777990 +0200
@@ -270,7 +270,7 @@
# Default options to use in a new config file. This will only be used if $menu_file
# doesn't already exist. Only edit the lines between the two "EOF"s. The others are
# part of the script.
-newtemplate=$(tempfile)
+newtemplate=$(mktemp)
cat > "$newtemplate" <<EOF
# $menu_file_basename - See: grub(8), info grub, update-grub(8)
# grub-install(8), grub-floppy(8),
@@ -637,7 +637,7 @@
savedefault=$(GetMenuOpt "savedefault" "$savedefault")
# Generate the menu options we want to insert
-buffer=$(tempfile)
+buffer=$(mktemp)
echo $start >> $buffer
echo "## lines between the AUTOMAGIC KERNELS LIST markers will be modified" >> $buffer
echo "## by the debian update-grub script except for the default options below" >> $buffer
@@ -1034,7 +1034,7 @@
fi
else
value="$1"
- newmenu=$(tempfile)
+ newmenu=$(mktemp)
sed -e "s/^[[:blank:]]*default[[:blank:]]*[[:digit:]]*\(.*\)/default ${value}\1/;b" $menu > $newmenu
cat $newmenu > $menu
rm -f $newmenu
-- System Information:
Debian Release: bookworm/sid
APT prefers unstable
APT policy: (990, 'unstable'), (600, 'testing'), (500, 'unstable-debug'), (500, 'buildd-unstable'), (110, 'experimental'), (1, 'experimental-debug'), (1, 'buildd-experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.10.0-8-amd64 (SMP w/4 CPU threads)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled
Versions of packages grub-legacy depends on:
ii grub-common 2.04-20
ii libc6-i386 2.31-17
grub-legacy recommends no packages.
Versions of packages grub-legacy suggests:
pn grub-legacy-doc <none>
pn mdadm <none>
ii multiboot 0.6.96+20101113-3
-- no debconf information
More information about the Pkg-grub-devel
mailing list