Drop post-build EFI bootloader patching
This commit is contained in:
@@ -674,274 +674,6 @@ label memtest
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
extract_live_grub_entry() {
|
|
||||||
cfg="$1"
|
|
||||||
live_linux="$(awk '/^[[:space:]]*linux[[:space:]]+\/live\// { print; exit }' "$cfg")"
|
|
||||||
live_initrd="$(awk '/^[[:space:]]*initrd[[:space:]]+\/live\// { print; exit }' "$cfg")"
|
|
||||||
[ -n "$live_linux" ] || return 1
|
|
||||||
[ -n "$live_initrd" ] || return 1
|
|
||||||
|
|
||||||
grub_kernel="$(printf '%s\n' "$live_linux" | awk '{print $2}')"
|
|
||||||
grub_append="$(printf '%s\n' "$live_linux" | cut -d' ' -f3-)"
|
|
||||||
grub_initrd="$(printf '%s\n' "$live_initrd" | awk '{print $2}')"
|
|
||||||
[ -n "$grub_kernel" ] || return 1
|
|
||||||
[ -n "$grub_append" ] || return 1
|
|
||||||
[ -n "$grub_initrd" ] || return 1
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
load_live_build_append() {
|
|
||||||
lb_dir="$1"
|
|
||||||
binary_cfg="$lb_dir/config/binary"
|
|
||||||
[ -f "$binary_cfg" ] || return 1
|
|
||||||
|
|
||||||
# config/binary is generated by live-build and contains shell variable
|
|
||||||
# assignments such as LB_BOOTAPPEND_LIVE="boot=live ...".
|
|
||||||
# shellcheck disable=SC1090
|
|
||||||
. "$binary_cfg"
|
|
||||||
|
|
||||||
[ -n "${LB_BOOTAPPEND_LIVE:-}" ] || return 1
|
|
||||||
live_build_append="$LB_BOOTAPPEND_LIVE"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
extract_live_isolinux_entry() {
|
|
||||||
cfg="$1"
|
|
||||||
isolinux_linux="$(awk '/^[[:space:]]*linux[[:space:]]+\/live\// { print; exit }' "$cfg")"
|
|
||||||
isolinux_initrd="$(awk '/^[[:space:]]*initrd[[:space:]]+\/live\// { print; exit }' "$cfg")"
|
|
||||||
isolinux_append="$(awk '/^[[:space:]]*append[[:space:]]+/ { sub(/^[[:space:]]*append[[:space:]]+/, ""); print; exit }' "$cfg")"
|
|
||||||
[ -n "$isolinux_linux" ] || return 1
|
|
||||||
[ -n "$isolinux_initrd" ] || return 1
|
|
||||||
[ -n "$isolinux_append" ] || return 1
|
|
||||||
|
|
||||||
isolinux_kernel="$(printf '%s\n' "$isolinux_linux" | awk '{print $2}')"
|
|
||||||
isolinux_initrd_path="$(printf '%s\n' "$isolinux_initrd" | awk '{print $2}')"
|
|
||||||
[ -n "$isolinux_kernel" ] || return 1
|
|
||||||
[ -n "$isolinux_initrd_path" ] || return 1
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
write_canonical_grub_cfg() {
|
|
||||||
cfg="$1"
|
|
||||||
kernel="$2"
|
|
||||||
append_live="$3"
|
|
||||||
initrd="$4"
|
|
||||||
|
|
||||||
cat > "$cfg" <<EOF
|
|
||||||
source /boot/grub/config.cfg
|
|
||||||
|
|
||||||
menuentry "EASY-BEE" {
|
|
||||||
linux ${kernel} ${append_live} nomodeset bee.nvidia.mode=normal pci=realloc net.ifnames=0 biosdevname=0 mitigations=off transparent_hugepage=always numa_balancing=disable pcie_aspm=off intel_idle.max_cstate=1 processor.max_cstate=1 nowatchdog nosoftlockup
|
|
||||||
initrd ${initrd}
|
|
||||||
}
|
|
||||||
|
|
||||||
menuentry "EASY-BEE -- load to RAM (toram)" {
|
|
||||||
linux ${kernel} ${append_live} toram nomodeset bee.nvidia.mode=normal pci=realloc net.ifnames=0 biosdevname=0 mitigations=off transparent_hugepage=always numa_balancing=disable pcie_aspm=off intel_idle.max_cstate=1 processor.max_cstate=1 nowatchdog nosoftlockup
|
|
||||||
initrd ${initrd}
|
|
||||||
}
|
|
||||||
|
|
||||||
menuentry "EASY-BEE -- no GUI / no X11" {
|
|
||||||
linux ${kernel} ${append_live} nomodeset bee.gui=off bee.nvidia.mode=gsp-off pci=realloc net.ifnames=0 biosdevname=0 mitigations=off transparent_hugepage=always numa_balancing=disable pcie_aspm=off intel_idle.max_cstate=1 processor.max_cstate=1 nowatchdog nosoftlockup
|
|
||||||
initrd ${initrd}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if [ "\${grub_platform}" = "efi" ]; then
|
|
||||||
menuentry "Memory Test (memtest86+)" {
|
|
||||||
chainloader /boot/memtest86+x64.efi
|
|
||||||
}
|
|
||||||
else
|
|
||||||
menuentry "Memory Test (memtest86+)" {
|
|
||||||
linux16 /boot/memtest86+x64.bin
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "\${grub_platform}" = "efi" ]; then
|
|
||||||
menuentry "UEFI Firmware Settings" {
|
|
||||||
fwsetup
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
write_canonical_isolinux_cfg() {
|
|
||||||
cfg="$1"
|
|
||||||
kernel="$2"
|
|
||||||
initrd="$3"
|
|
||||||
append_live="$4"
|
|
||||||
|
|
||||||
cat > "$cfg" <<EOF
|
|
||||||
label live-@FLAVOUR@-normal
|
|
||||||
menu label ^EASY-BEE
|
|
||||||
linux ${kernel}
|
|
||||||
initrd ${initrd}
|
|
||||||
append ${append_live} nomodeset bee.nvidia.mode=normal net.ifnames=0 biosdevname=0 mitigations=off transparent_hugepage=always numa_balancing=disable pcie_aspm=off intel_idle.max_cstate=1 processor.max_cstate=1 nowatchdog nosoftlockup
|
|
||||||
|
|
||||||
label live-@FLAVOUR@-toram
|
|
||||||
menu label EASY-BEE (^load to RAM)
|
|
||||||
menu default
|
|
||||||
linux ${kernel}
|
|
||||||
initrd ${initrd}
|
|
||||||
append ${append_live} toram nomodeset bee.nvidia.mode=normal net.ifnames=0 biosdevname=0 mitigations=off transparent_hugepage=always numa_balancing=disable pcie_aspm=off intel_idle.max_cstate=1 processor.max_cstate=1 nowatchdog nosoftlockup
|
|
||||||
|
|
||||||
label live-@FLAVOUR@-console
|
|
||||||
menu label EASY-BEE (^no GUI / no X11)
|
|
||||||
linux ${kernel}
|
|
||||||
initrd ${initrd}
|
|
||||||
append ${append_live} nomodeset bee.gui=off bee.nvidia.mode=gsp-off net.ifnames=0 biosdevname=0 mitigations=off transparent_hugepage=always numa_balancing=disable pcie_aspm=off intel_idle.max_cstate=1 processor.max_cstate=1 nowatchdog nosoftlockup
|
|
||||||
|
|
||||||
label live-@FLAVOUR@-gsp-off
|
|
||||||
menu label EASY-BEE (^NVIDIA GSP=off)
|
|
||||||
linux ${kernel}
|
|
||||||
initrd ${initrd}
|
|
||||||
append ${append_live} nomodeset bee.nvidia.mode=gsp-off net.ifnames=0 biosdevname=0 mitigations=off transparent_hugepage=always numa_balancing=disable pcie_aspm=off intel_idle.max_cstate=1 processor.max_cstate=1 nowatchdog nosoftlockup
|
|
||||||
|
|
||||||
label live-@FLAVOUR@-kms
|
|
||||||
menu label EASY-BEE (^KMS, no nomodeset)
|
|
||||||
linux ${kernel}
|
|
||||||
initrd ${initrd}
|
|
||||||
append ${append_live} bee.nvidia.mode=normal net.ifnames=0 biosdevname=0 mitigations=off transparent_hugepage=always numa_balancing=disable pcie_aspm=off intel_idle.max_cstate=1 processor.max_cstate=1 nowatchdog nosoftlockup
|
|
||||||
|
|
||||||
label live-@FLAVOUR@-kms-gsp-off
|
|
||||||
menu label EASY-BEE (KMS, ^GSP=off)
|
|
||||||
linux ${kernel}
|
|
||||||
initrd ${initrd}
|
|
||||||
append ${append_live} bee.nvidia.mode=gsp-off net.ifnames=0 biosdevname=0 mitigations=off transparent_hugepage=always numa_balancing=disable pcie_aspm=off intel_idle.max_cstate=1 processor.max_cstate=1 nowatchdog nosoftlockup
|
|
||||||
|
|
||||||
label live-@FLAVOUR@-failsafe
|
|
||||||
menu label EASY-BEE (^fail-safe)
|
|
||||||
linux ${kernel}
|
|
||||||
initrd ${initrd}
|
|
||||||
append ${append_live} nomodeset bee.nvidia.mode=gsp-off noapic noapm nodma nomce nolapic nosmp vga=normal net.ifnames=0 biosdevname=0
|
|
||||||
|
|
||||||
label memtest
|
|
||||||
menu label ^Memory Test (memtest86+)
|
|
||||||
linux /boot/memtest86+x64.bin
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
enforce_live_build_bootloader_assets() {
|
|
||||||
lb_dir="$1"
|
|
||||||
grub_cfg="$lb_dir/binary/boot/grub/grub.cfg"
|
|
||||||
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
|
|
||||||
live_build_append=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$grub_cfg" ]; then
|
|
||||||
if extract_live_grub_entry "$grub_cfg"; then
|
|
||||||
mkdir -p "$grub_dir/live-theme"
|
|
||||||
cp "${BUILDER_DIR}/config/bootloaders/grub-efi/config.cfg" "$grub_dir/config.cfg"
|
|
||||||
cp "${BUILDER_DIR}/config/bootloaders/grub-efi/theme.cfg" "$grub_dir/theme.cfg"
|
|
||||||
cp -R "${BUILDER_DIR}/config/bootloaders/grub-efi/live-theme/." "$grub_dir/live-theme/"
|
|
||||||
write_canonical_grub_cfg "$grub_cfg" "$grub_kernel" "${live_build_append:-$grub_append}" "$grub_initrd"
|
|
||||||
echo "bootloader sync: rewrote binary/boot/grub/grub.cfg with canonical EASY-BEE menu"
|
|
||||||
else
|
|
||||||
echo "bootloader sync: WARNING: could not extract live entry from $grub_cfg" >&2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
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"
|
|
||||||
else
|
|
||||||
echo "bootloader sync: WARNING: could not extract live entry from $isolinux_cfg" >&2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
sync_efi_grub_theme_assets "$lb_dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
fat_image_has_file() {
|
|
||||||
img="$1"
|
|
||||||
path="$2"
|
|
||||||
mtype -i "$img" "$path" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
is_efi_grub_fat_image() {
|
|
||||||
img="$1"
|
|
||||||
fat_image_has_file "$img" "::/EFI/boot/grubx64.efi" || return 1
|
|
||||||
fat_image_has_file "$img" "::/boot/grub/grub.cfg" || return 1
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
copy_file_to_fat_image() {
|
|
||||||
img="$1"
|
|
||||||
src="$2"
|
|
||||||
dst="$3"
|
|
||||||
mcopy -o -i "$img" "$src" "$dst" >/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
grow_efi_grub_fat_image() {
|
|
||||||
img="$1"
|
|
||||||
tmpdir="$(mktemp -d)"
|
|
||||||
newimg="$(mktemp "${img##*/}.XXXXXX")"
|
|
||||||
|
|
||||||
current_size="$(wc -c < "$img" | tr -d '[:space:]')"
|
|
||||||
[ -n "$current_size" ] || current_size=0
|
|
||||||
extra_bytes=$((2 * 1024 * 1024))
|
|
||||||
new_size=$((current_size + extra_bytes))
|
|
||||||
|
|
||||||
# Recreate the FAT image with extra headroom and copy the original payload
|
|
||||||
# back in before injecting the larger GRUB theme assets.
|
|
||||||
mcopy -s -i "$img" :: "$tmpdir" >/dev/null
|
|
||||||
truncate -s "$new_size" "$newimg"
|
|
||||||
mformat -i "$newimg" -F :: >/dev/null
|
|
||||||
mcopy -s -i "$newimg" "$tmpdir"/* :: >/dev/null
|
|
||||||
mv "$newimg" "$img"
|
|
||||||
rm -rf "$tmpdir"
|
|
||||||
}
|
|
||||||
|
|
||||||
sync_efi_grub_theme_assets() {
|
|
||||||
lb_dir="$1"
|
|
||||||
found=0
|
|
||||||
|
|
||||||
for img in $(find "$lb_dir" -type f \( -name '*.img' -o -name '*.ima' -o -name '*.fat' \) 2>/dev/null); do
|
|
||||||
if ! is_efi_grub_fat_image "$img"; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
found=1
|
|
||||||
echo "bootloader sync: patching EFI GRUB image $img"
|
|
||||||
grow_efi_grub_fat_image "$img"
|
|
||||||
mmd -i "$img" "::/boot" >/dev/null 2>&1 || true
|
|
||||||
mmd -i "$img" "::/boot/grub" >/dev/null 2>&1 || true
|
|
||||||
mmd -i "$img" "::/boot/grub/live-theme" >/dev/null 2>&1 || true
|
|
||||||
|
|
||||||
copy_file_to_fat_image "$img" "${BUILDER_DIR}/config/bootloaders/grub-efi/config.cfg" "::/boot/grub/config.cfg"
|
|
||||||
copy_file_to_fat_image "$img" "${BUILDER_DIR}/config/bootloaders/grub-efi/theme.cfg" "::/boot/grub/theme.cfg"
|
|
||||||
for asset in "${BUILDER_DIR}"/config/bootloaders/grub-efi/live-theme/*; do
|
|
||||||
[ -f "$asset" ] || continue
|
|
||||||
copy_file_to_fat_image "$img" "$asset" "::/boot/grub/live-theme/"
|
|
||||||
done
|
|
||||||
|
|
||||||
fat_image_has_file "$img" "::/boot/grub/config.cfg" || {
|
|
||||||
echo "ERROR: EFI GRUB image missing /boot/grub/config.cfg after sync: $img" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
fat_image_has_file "$img" "::/boot/grub/theme.cfg" || {
|
|
||||||
echo "ERROR: EFI GRUB image missing /boot/grub/theme.cfg after sync: $img" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
fat_image_has_file "$img" "::/boot/grub/live-theme/theme.txt" || {
|
|
||||||
echo "ERROR: EFI GRUB image missing /boot/grub/live-theme/theme.txt after sync: $img" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
fat_image_has_file "$img" "::/boot/grub/live-theme/bee-logo.tga" || {
|
|
||||||
echo "ERROR: EFI GRUB image missing /boot/grub/live-theme/bee-logo.tga after sync: $img" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$found" != "1" ]; then
|
|
||||||
echo "ERROR: no EFI GRUB FAT image found in live-build workdir; cannot sync theme assets" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
copy_memtest_from_deb() {
|
copy_memtest_from_deb() {
|
||||||
deb="$1"
|
deb="$1"
|
||||||
dst_boot="$2"
|
dst_boot="$2"
|
||||||
@@ -1707,14 +1439,6 @@ run_step_sh "live-build clean" "80-lb-clean" "lb clean --all 2>&1 | tail -3"
|
|||||||
run_step_sh "live-build config" "81-lb-config" "lb config 2>&1 | tail -5"
|
run_step_sh "live-build config" "81-lb-config" "lb config 2>&1 | tail -5"
|
||||||
dump_memtest_debug "pre-build" "${LB_DIR}"
|
dump_memtest_debug "pre-build" "${LB_DIR}"
|
||||||
run_step_sh "live-build build" "90-lb-build" "lb build 2>&1"
|
run_step_sh "live-build build" "90-lb-build" "lb build 2>&1"
|
||||||
echo "=== enforcing canonical bootloader assets ==="
|
|
||||||
enforce_live_build_bootloader_assets "${LB_DIR}"
|
|
||||||
reset_live_build_stage "${LB_DIR}" "binary_checksums"
|
|
||||||
reset_live_build_stage "${LB_DIR}" "binary_iso"
|
|
||||||
reset_live_build_stage "${LB_DIR}" "binary_zsync"
|
|
||||||
run_step_sh "rebuild live-build checksums after bootloader sync" "91b-lb-checksums" "lb binary_checksums 2>&1"
|
|
||||||
run_step_sh "rebuild ISO after bootloader sync" "91c-lb-binary-iso" "lb binary_iso 2>&1"
|
|
||||||
run_step_sh "rebuild zsync after bootloader sync" "91d-lb-zsync" "lb binary_zsync 2>&1"
|
|
||||||
|
|
||||||
# --- persist deb package cache back to shared location ---
|
# --- persist deb package cache back to shared location ---
|
||||||
# This allows the second variant to reuse all downloaded packages.
|
# This allows the second variant to reuse all downloaded packages.
|
||||||
|
|||||||
Reference in New Issue
Block a user