fix(iso): render isolinux flavour before validation
This commit is contained in:
@@ -14,18 +14,27 @@ extract_live_grub_entry() {
|
||||
return 0
|
||||
}
|
||||
|
||||
load_live_build_append() {
|
||||
load_live_build_boot_config() {
|
||||
lb_dir="$1"
|
||||
binary_cfg="$lb_dir/config/binary"
|
||||
chroot_cfg="$lb_dir/config/chroot"
|
||||
[ -f "$binary_cfg" ] || return 1
|
||||
[ -f "$chroot_cfg" ] || return 1
|
||||
|
||||
# config/binary is generated by live-build and contains shell variable
|
||||
# assignments such as LB_BOOTAPPEND_LIVE="boot=live ...".
|
||||
# These files are generated by live-build. Its configuration code derives
|
||||
# LB_LINUX_FLAVOURS by removing an optional :architecture suffix from each
|
||||
# LB_LINUX_FLAVOURS_WITH_ARCH item; the default flavour is the first item.
|
||||
unset LB_BOOTAPPEND_LIVE LB_LINUX_FLAVOURS_WITH_ARCH
|
||||
# shellcheck disable=SC1090
|
||||
. "$binary_cfg"
|
||||
# shellcheck disable=SC1090
|
||||
. "$chroot_cfg"
|
||||
|
||||
[ -n "${LB_BOOTAPPEND_LIVE:-}" ] || return 1
|
||||
[ -n "${LB_LINUX_FLAVOURS_WITH_ARCH:-}" ] || return 1
|
||||
live_build_append="$LB_BOOTAPPEND_LIVE"
|
||||
live_build_flavour="$(printf '%s\n' "$LB_LINUX_FLAVOURS_WITH_ARCH" | awk '{ split($1, item, ":"); print item[1] }')"
|
||||
[ -n "$live_build_flavour" ] || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -64,12 +73,13 @@ write_canonical_isolinux_cfg() {
|
||||
kernel="$2"
|
||||
initrd="$3"
|
||||
append_live="$4"
|
||||
flavour="$5"
|
||||
version_label="${PROJECT_VERSION_EFFECTIVE}"
|
||||
|
||||
template="${BUILDER_DIR}/config/bootloaders/isolinux/live.cfg.in"
|
||||
tmp_cfg="${cfg}.new"
|
||||
render_bootloader_template "$template" "$tmp_cfg" \
|
||||
"$version_label" "@LINUX@" "$kernel" "$append_live" "@INITRD@" "$initrd"
|
||||
"$version_label" "@LINUX@" "$kernel" "$append_live" "@INITRD@" "$initrd" "$flavour"
|
||||
mv "$tmp_cfg" "$cfg"
|
||||
}
|
||||
|
||||
@@ -84,6 +94,7 @@ render_bootloader_template() {
|
||||
append_live="$6"
|
||||
initrd_placeholder="$7"
|
||||
initrd="$8"
|
||||
flavour="${9:-}"
|
||||
|
||||
for required_placeholder in \
|
||||
"@VERSION@" \
|
||||
@@ -92,6 +103,10 @@ render_bootloader_template() {
|
||||
"$initrd_placeholder"; do
|
||||
require_template_placeholder "$template" "$required_placeholder" || return 1
|
||||
done
|
||||
if grep -Fq '@FLAVOUR@' "$template" && [ -z "$flavour" ]; then
|
||||
echo "ERROR: template $template requires a non-empty @FLAVOUR@ value" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
BEE_RENDER_VERSION="$version" \
|
||||
BEE_RENDER_KERNEL_PLACEHOLDER="$kernel_placeholder" \
|
||||
@@ -99,6 +114,7 @@ render_bootloader_template() {
|
||||
BEE_RENDER_APPEND="$append_live" \
|
||||
BEE_RENDER_INITRD_PLACEHOLDER="$initrd_placeholder" \
|
||||
BEE_RENDER_INITRD="$initrd" \
|
||||
BEE_RENDER_FLAVOUR="$flavour" \
|
||||
awk '
|
||||
function replace_literal(text, needle, replacement, at) {
|
||||
while ((at = index(text, needle)) != 0) {
|
||||
@@ -113,10 +129,12 @@ render_bootloader_template() {
|
||||
append_live = ENVIRON["BEE_RENDER_APPEND"]
|
||||
initrd_placeholder = ENVIRON["BEE_RENDER_INITRD_PLACEHOLDER"]
|
||||
initrd = ENVIRON["BEE_RENDER_INITRD"]
|
||||
flavour = ENVIRON["BEE_RENDER_FLAVOUR"]
|
||||
line = replace_literal($0, "@VERSION@", version)
|
||||
line = replace_literal(line, kernel_placeholder, kernel)
|
||||
line = replace_literal(line, "@APPEND_LIVE@", append_live)
|
||||
line = replace_literal(line, initrd_placeholder, initrd)
|
||||
line = replace_literal(line, "@FLAVOUR@", flavour)
|
||||
print line
|
||||
}
|
||||
' "$template" > "$output"
|
||||
@@ -128,9 +146,10 @@ enforce_live_build_bootloader_assets() {
|
||||
grub_dir="$lb_dir/binary/boot/grub"
|
||||
isolinux_cfg="$lb_dir/binary/isolinux/live.cfg"
|
||||
|
||||
if ! load_live_build_append "$lb_dir"; then
|
||||
echo "bootloader sync: WARNING: could not load LB_BOOTAPPEND_LIVE from $lb_dir/config/binary" >&2
|
||||
if ! load_live_build_boot_config "$lb_dir"; then
|
||||
echo "bootloader sync: WARNING: could not load live boot settings from $lb_dir/config" >&2
|
||||
live_build_append=""
|
||||
live_build_flavour=""
|
||||
fi
|
||||
|
||||
if [ -f "$grub_cfg" ]; then
|
||||
@@ -145,8 +164,12 @@ enforce_live_build_bootloader_assets() {
|
||||
|
||||
if [ -f "$isolinux_cfg" ]; then
|
||||
if extract_live_isolinux_entry "$isolinux_cfg"; then
|
||||
write_canonical_isolinux_cfg "$isolinux_cfg" "$isolinux_kernel" "$isolinux_initrd_path" "${live_build_append:-$isolinux_append}"
|
||||
echo "bootloader sync: rewrote binary/isolinux/live.cfg with canonical EASY-BEE menu"
|
||||
if [ -n "$live_build_flavour" ]; then
|
||||
write_canonical_isolinux_cfg "$isolinux_cfg" "$isolinux_kernel" "$isolinux_initrd_path" "${live_build_append:-$isolinux_append}" "$live_build_flavour"
|
||||
echo "bootloader sync: rewrote binary/isolinux/live.cfg with canonical EASY-BEE menu"
|
||||
else
|
||||
echo "bootloader sync: WARNING: could not determine live-build kernel flavour" >&2
|
||||
fi
|
||||
else
|
||||
echo "bootloader sync: WARNING: could not extract live entry from $isolinux_cfg" >&2
|
||||
fi
|
||||
|
||||
@@ -437,6 +437,8 @@ validate_iso_live_boot_entries() {
|
||||
|
||||
if grep -Eq '@[A-Z][A-Z_]*@' "$grub_cfg" "$isolinux_cfg"; then
|
||||
echo "ERROR: unresolved live-build placeholders remain in ISO bootloader config" >&2
|
||||
grep -En '@[A-Z][A-Z_]*@' "$grub_cfg" | sed 's/^/ GRUB: /' >&2 || true
|
||||
grep -En '@[A-Z][A-Z_]*@' "$isolinux_cfg" | sed 's/^/ isolinux: /' >&2 || true
|
||||
rm -f "$grub_cfg" "$isolinux_cfg"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -57,21 +57,40 @@ if render_bootloader_template "$literal_template" "$literal_output" \
|
||||
echo "ERROR: bootloader renderer accepted a missing required placeholder" >&2
|
||||
exit 1
|
||||
fi
|
||||
if render_bootloader_template "$BUILDER_DIR/config/bootloaders/isolinux/live.cfg.in" "$literal_output" \
|
||||
'13.0-test' '@LINUX@' '/live/vmlinuz' 'boot=live' '@INITRD@' '/live/initrd.img' >/dev/null 2>&1; then
|
||||
echo "ERROR: isolinux renderer accepted a missing flavour" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
live_build_config_root="$TEST_ROOT/live-build-config"
|
||||
mkdir -p "$live_build_config_root/config"
|
||||
printf '%s\n' \
|
||||
'LB_BOOTAPPEND_LIVE="boot=live live-media-label=EASY_BEE_TEST"' > "$live_build_config_root/config/binary"
|
||||
printf '%s\n' \
|
||||
'LB_LINUX_FLAVOURS_WITH_ARCH="amd64:amd64 686-pae:i386"' > "$live_build_config_root/config/chroot"
|
||||
load_live_build_boot_config "$live_build_config_root"
|
||||
if [ "$live_build_append" != 'boot=live live-media-label=EASY_BEE_TEST' ] || \
|
||||
[ "$live_build_flavour" != amd64 ]; then
|
||||
echo "ERROR: failed to load the default live-build boot settings" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rendered_grub="$TEST_ROOT/grub.cfg"
|
||||
rendered_isolinux="$TEST_ROOT/live.cfg"
|
||||
sed \
|
||||
-e 's#@APPEND_LIVE@#boot=live live-media-label=EASY_BEE_TEST#g' \
|
||||
-e 's#@KERNEL_LIVE@#/live/vmlinuz#g' \
|
||||
-e 's#@INITRD_LIVE@#/live/initrd.img#g' \
|
||||
-e 's#@VERSION@#13.0-test#g' \
|
||||
"$BUILDER_DIR/config/bootloaders/grub-efi/grub.cfg" > "$rendered_grub"
|
||||
sed \
|
||||
-e 's#@APPEND_LIVE@#boot=live live-media-label=EASY_BEE_TEST#g' \
|
||||
-e 's#@LINUX@#/live/vmlinuz#g' \
|
||||
-e 's#@INITRD@#/live/initrd.img#g' \
|
||||
-e 's#@VERSION@#13.0-test#g' \
|
||||
"$BUILDER_DIR/config/bootloaders/isolinux/live.cfg.in" > "$rendered_isolinux"
|
||||
write_canonical_grub_cfg "$rendered_grub" /live/vmlinuz \
|
||||
'boot=live live-media-label=EASY_BEE_TEST' /live/initrd.img
|
||||
write_canonical_isolinux_cfg "$rendered_isolinux" /live/vmlinuz /live/initrd.img \
|
||||
'boot=live live-media-label=EASY_BEE_TEST' "$live_build_flavour"
|
||||
|
||||
if grep -Eq '@[A-Z][A-Z_]*@' "$rendered_grub" "$rendered_isolinux"; then
|
||||
echo "ERROR: canonical bootloader renderer left an unresolved placeholder" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! grep -q '^label live-amd64-normal$' "$rendered_isolinux"; then
|
||||
echo "ERROR: canonical isolinux renderer did not apply the live-build flavour" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
validate_live_cmdline_params "$rendered_grub" linux GRUB "$BEE_ISO_VOLUME"
|
||||
validate_live_cmdline_params "$rendered_isolinux" append isolinux "$BEE_ISO_VOLUME"
|
||||
|
||||
Reference in New Issue
Block a user