From a3f7a33f956eff839c3c13a47c903fd9daf65286 Mon Sep 17 00:00:00 2001 From: Arnaud Rebillout Date: Fri, 15 Sep 2023 16:14:12 +0700 Subject: [PATCH] efi-image: Fix missing part_* modules in boot.efi Setting the value of PARTITIONLIST in a sub-shell is scoped to the sub-shell, it will not change the value of the variable in the parent shell. In other words: #!/bin/sh FOOBAR= (FOOBAR=foo) echo FOOBAR=$FOOBAR gives the output: FOOBAR= As a consequence, PARTITIONLIST being empty, there are no part_* modules embedded in the boot.efi binary. This is clearly a regression, introduced in 7b36f5b0ad751081f6316dcb0498df307a2ec902. Somehow, Debian doesn't seem to be impacted. Kali Linux is impacted, but only under very special conditions, leading to this bug report: This commit fixes it, by setting the PARTITIONLIST variable first, and then using it where needs be. As a consequence it greatly simplifies the next part of the code, as we can just use a heredoc to create the grub config. --- scripts/build/efi-image | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/build/efi-image b/scripts/build/efi-image index 5a180aec2..0833f5793 100755 --- a/scripts/build/efi-image +++ b/scripts/build/efi-image @@ -56,17 +56,19 @@ EOF # Set the timestamps find $workdir -newermt "$(date -d@${SOURCE_DATE_EPOCH} '+%Y-%m-%d %H:%M:%S')" -exec touch '{}' -d@${SOURCE_DATE_EPOCH} ';' -mkdir -p "$outdir/boot/grub/$platform" # All partition modules will be activated, unless UEFI secure boot is active (they are not signed) PARTITIONLIST="" -(echo "if [ x$grub_platform == xefi -a x$lockdown != xy ] ; then "; \ - for i in /usr/lib/grub/$platform/part_*.mod; do - i=`echo $i | sed 's?^.*/??g;s?\.mod$??g;'` - echo "insmod $i" - PARTITIONLIST="${PARTITIONLIST} $i" - done; \ - echo "fi"; \ - echo "source /boot/grub/grub.cfg") >"$outdir/boot/grub/$platform/grub.cfg" +for i in /usr/lib/grub/$platform/part_*.mod; do + i=$(echo $i | sed 's?^.*/??g;s?\.mod$??g;') + PARTITIONLIST="$PARTITIONLIST $i" +done +mkdir -p "$outdir/boot/grub/$platform" +cat >"$outdir/boot/grub/$platform/grub.cfg" <"$memdisk_img"