efi-image: Fix <platform>/grub.cfg, variables must NOT be expanded

The test 'if [ x$grub_platform == xefi -a x$lockdown != xy ]' is meant
to be done by GRUB at runtime, so this line should appear verbatim in
the grub.cfg file.

However the variables are expanded at build-time by the script, because
the dollar symbol is not escaped.

Here's the result on a 12.1.0 live image:

    $ cat <<debian-live-12.1.0>>/boot/grub/x86_64-efi/grub.cfg
    if [ x == xefi -a x != xy ] ; then
    insmod part_acorn
    insmod part_amiga
    insmod part_apple
    insmod part_bsd
    insmod part_dfly
    insmod part_dvh
    insmod part_gpt
    insmod part_msdos
    insmod part_plan
    insmod part_sun
    insmod part_sunpc
    fi
    source /boot/grub/grub.cfg

Note that this mistake would have been caught if only the nounset option
had been used (ie. 'set -u').

Fixes commit: 7b36f5b0ad
This commit is contained in:
Arnaud Rebillout 2023-09-18 08:39:38 +07:00
parent a3f7a33f95
commit 6dbb8d2598
1 changed files with 1 additions and 1 deletions

View File

@ -64,7 +64,7 @@ for i in /usr/lib/grub/$platform/part_*.mod; do
done
mkdir -p "$outdir/boot/grub/$platform"
cat >"$outdir/boot/grub/$platform/grub.cfg" <<EOF
if [ x$grub_platform == xefi -a x$lockdown != xy ] ; then
if [ x\$grub_platform == xefi -a x\$lockdown != xy ] ; then
$(printf " insmod %s\n" $PARTITIONLIST)
fi
source /boot/grub/grub.cfg