Comment 2 for bug 1951779

Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote : Re: package linux-image-5.13.0-19-generic 5.13.0-19.19 failed to install/upgrade: run-parts: /etc/kernel/postinst.d/x-grub-legacy-ec2 exited with return code 127

Thanks for taking the time to report this bug and trying to make Ubuntu better.

This seems to be a bug indeed. From the upgrade logs we can see:

/etc/kernel/postinst.d/x-grub-legacy-ec2:
Searching for GRUB installation directory ... found: /boot/grub
/usr/sbin/update-grub-legacy-ec2: line 494: tempfile: command not found
run-parts: /etc/kernel/postinst.d/x-grub-legacy-ec2 exited with return code 127
dpkg: error processing package linux-image-5.13.0-19-generic (--configure):
 installed linux-image-5.13.0-19-generic package post-installation script subprocess returned error exit status 1

The important part here is the "tempfile: command not found". The tempfile command was removed from debianutils package in version 5.0, and during the do-release-upgrade run it was upgraded from version 4.9.1 (Focal) to version 5.5-1 (Jammy). The debianutils package was upgraded before linux-image-5.13.0-19-generic:5.13.0-19.19 and then when the linux-image postinst triggered the execution of /usr/sbin/update-grub-legacy-ec2 you got the crash because this script still relies on the tempfile command.

In order to do not break upgrades from Focal to Jammy we need to make the update-grub-legacy-ec2 script in src:grub-legacy-ec2 use likely "mktemp" instead of "tempfile". A bonus point would be to avoid using the "which" command (probably use "command -v") since it was already deprecated in debianutils version 5.0 and should be removed in the future.