Control: tags -1 + patch

Attached is an updated version of the patch:

- Moves the check inside the existing `test -z "${initramfs}" && test -z 
"${initrd_real}"` block in `util/grub.d/10_linux.in` (and adds the matching 
check to `util/grub.d/20_linux_xen.in`).
- Guards the skip check on `GRUB_DISABLE_INITRD != true`, empty 
`GRUB_FORCE_PARTUUID`, and an executable 
`/etc/kernel/postinst.d/initramfs-tools` or `/etc/kernel/postinst.d/dracut` 
hook, so initrd-less cloud images are unaffected when `update-grub` runs from 
inside `/usr/lib/linux/triggers/<version>`.

Thanks,
Viktor Pashaiev
Description: Skip linux image with pending postinst trigger and missing initrd
Author: Viktor Pashaiev <[email protected]>
Bug-Debian: https://bugs.debian.org/1151014
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/2141741
Last-Update: 2026-11-04

--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -445,6 +445,12 @@ for linux in ${reverse_sorted_list}; do
   fi
 
   if test -z "${initramfs}" && test -z "${initrd_real}" ; then
+    if [ "x${GRUB_DISABLE_INITRD}" != "xtrue" ] && [ "x${GRUB_FORCE_PARTUUID}" = "x" ] \
+	&& ( test -x /etc/kernel/postinst.d/initramfs-tools || test -x /etc/kernel/postinst.d/dracut ) \
+	&& ( test -e "/usr/lib/linux/triggers/${version}" || test -e "/usr/lib/linux/triggers/${alt_version}" ); then
+      gettext_printf "Skipping linux image with pending post-installation trigger and no initrd: %s\n" "$linux" >&2
+      continue
+    fi
     # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs.  Since there's
     # no initrd or builtin initramfs, it can't work here.
     if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -326,6 +326,12 @@ for current_xen in ${reverse_sorted_xen_
 	fi
 
 	if test -z "${initrd_real}"; then
+	    if [ "x${GRUB_DISABLE_INITRD}" != "xtrue" ] && [ "x${GRUB_FORCE_PARTUUID}" = "x" ] \
+		&& ( test -x /etc/kernel/postinst.d/initramfs-tools || test -x /etc/kernel/postinst.d/dracut ) \
+		&& ( test -e "/usr/lib/linux/triggers/${version}" || test -e "/usr/lib/linux/triggers/${alt_version}" ); then
+		gettext_printf "Skipping linux image with pending post-installation trigger and no initrd: %s\n" "$linux" >&2
+		continue
+	    fi
     # "UUID=" magic is parsed by initrds.  Since there's no initrd, it can't work here.
 	    if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
 		|| [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then

Reply via email to