|
|
|
|
@@ -126,6 +126,37 @@ resolve_iso_version() {
|
|
|
|
|
resolve_audit_version
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sync_builder_workdir() {
|
|
|
|
|
src_dir="$1"
|
|
|
|
|
dst_dir="$2"
|
|
|
|
|
|
|
|
|
|
mkdir -p "$dst_dir"
|
|
|
|
|
|
|
|
|
|
# Historical bug: old workdirs could keep config/bootloaders/grub-pc even
|
|
|
|
|
# after the source tree moved to grub-efi only. Remove bootloaders eagerly
|
|
|
|
|
# so reused workdirs cannot leak stale templates into a new ISO build.
|
|
|
|
|
rm -rf "$dst_dir/config/bootloaders"
|
|
|
|
|
|
|
|
|
|
rsync -a --delete \
|
|
|
|
|
--exclude='cache/' \
|
|
|
|
|
--exclude='chroot/' \
|
|
|
|
|
--exclude='.build/' \
|
|
|
|
|
--exclude='*.iso' \
|
|
|
|
|
--exclude='*.packages' \
|
|
|
|
|
--exclude='*.contents' \
|
|
|
|
|
--exclude='*.files' \
|
|
|
|
|
"$src_dir/" "$dst_dir/"
|
|
|
|
|
|
|
|
|
|
if [ ! -f "$dst_dir/config/bootloaders/grub-efi/grub.cfg" ]; then
|
|
|
|
|
echo "ERROR: staged workdir is missing config/bootloaders/grub-efi/grub.cfg" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
if [ -e "$dst_dir/config/bootloaders/grub-pc" ]; then
|
|
|
|
|
echo "ERROR: stale config/bootloaders/grub-pc remained in staged workdir" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iso_list_files() {
|
|
|
|
|
iso_path="$1"
|
|
|
|
|
|
|
|
|
|
@@ -466,6 +497,75 @@ validate_iso_memtest() {
|
|
|
|
|
echo "=== memtest validation OK ==="
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
validate_iso_live_boot_entries() {
|
|
|
|
|
iso_path="$1"
|
|
|
|
|
echo "=== validating live boot entries in ISO ==="
|
|
|
|
|
|
|
|
|
|
[ -f "$iso_path" ] || {
|
|
|
|
|
echo "ERROR: ISO not found for live boot validation: $iso_path" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
require_iso_reader "$iso_path" >/dev/null 2>&1 || {
|
|
|
|
|
echo "ERROR: ISO reader unavailable for live boot validation" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grub_cfg="$(mktemp)"
|
|
|
|
|
isolinux_cfg="$(mktemp)"
|
|
|
|
|
|
|
|
|
|
iso_read_member "$iso_path" boot/grub/grub.cfg "$grub_cfg" || {
|
|
|
|
|
echo "ERROR: failed to read boot/grub/grub.cfg from ISO" >&2
|
|
|
|
|
rm -f "$grub_cfg" "$isolinux_cfg"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
iso_read_member "$iso_path" isolinux/live.cfg "$isolinux_cfg" || {
|
|
|
|
|
echo "ERROR: failed to read isolinux/live.cfg from ISO" >&2
|
|
|
|
|
rm -f "$grub_cfg" "$isolinux_cfg"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if grep -q '@APPEND_LIVE@\|@KERNEL_LIVE@\|@INITRD_LIVE@' "$grub_cfg" "$isolinux_cfg"; then
|
|
|
|
|
echo "ERROR: unresolved live-build placeholders remain in ISO bootloader config" >&2
|
|
|
|
|
rm -f "$grub_cfg" "$isolinux_cfg"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
grep -q 'menuentry "EASY-BEE"' "$grub_cfg" || {
|
|
|
|
|
echo "ERROR: GRUB default EASY-BEE entry is missing" >&2
|
|
|
|
|
rm -f "$grub_cfg" "$isolinux_cfg"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
grep -q 'menuentry "EASY-BEE — load to RAM (toram)"' "$grub_cfg" || {
|
|
|
|
|
echo "ERROR: GRUB toram entry is missing" >&2
|
|
|
|
|
rm -f "$grub_cfg" "$isolinux_cfg"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
grep -q 'linux .*boot=live ' "$grub_cfg" || {
|
|
|
|
|
echo "ERROR: GRUB live entry is missing boot=live" >&2
|
|
|
|
|
rm -f "$grub_cfg" "$isolinux_cfg"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
grep -q 'linux .*boot=live .*toram ' "$grub_cfg" || {
|
|
|
|
|
echo "ERROR: GRUB toram entry is missing boot=live or toram" >&2
|
|
|
|
|
rm -f "$grub_cfg" "$isolinux_cfg"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grep -q 'append .*boot=live ' "$isolinux_cfg" || {
|
|
|
|
|
echo "ERROR: isolinux live entry is missing boot=live" >&2
|
|
|
|
|
rm -f "$grub_cfg" "$isolinux_cfg"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
grep -q 'append .*boot=live .*toram ' "$isolinux_cfg" || {
|
|
|
|
|
echo "ERROR: isolinux toram entry is missing boot=live or toram" >&2
|
|
|
|
|
rm -f "$grub_cfg" "$isolinux_cfg"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rm -f "$grub_cfg" "$isolinux_cfg"
|
|
|
|
|
echo "=== live boot validation OK ==="
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
validate_iso_nvidia_runtime() {
|
|
|
|
|
iso_path="$1"
|
|
|
|
|
[ "$BEE_GPU_VENDOR" = "nvidia" ] || return 0
|
|
|
|
|
@@ -558,6 +658,21 @@ extract_live_grub_entry() {
|
|
|
|
|
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")"
|
|
|
|
|
@@ -699,13 +814,18 @@ 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
|
|
|
|
|
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" "$grub_append" "$grub_initrd"
|
|
|
|
|
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
|
|
|
|
|
@@ -714,7 +834,7 @@ 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" "$isolinux_append"
|
|
|
|
|
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
|
|
|
|
|
@@ -1112,15 +1232,7 @@ echo "=== preparing staged overlay (${BUILD_VARIANT}) ==="
|
|
|
|
|
mkdir -p "${BUILD_WORK_DIR}" "${OVERLAY_STAGE_DIR}"
|
|
|
|
|
|
|
|
|
|
# Sync builder config into variant work dir, preserving lb cache.
|
|
|
|
|
rsync -a --delete \
|
|
|
|
|
--exclude='cache/' \
|
|
|
|
|
--exclude='chroot/' \
|
|
|
|
|
--exclude='.build/' \
|
|
|
|
|
--exclude='*.iso' \
|
|
|
|
|
--exclude='*.packages' \
|
|
|
|
|
--exclude='*.contents' \
|
|
|
|
|
--exclude='*.files' \
|
|
|
|
|
"${BUILDER_DIR}/" "${BUILD_WORK_DIR}/"
|
|
|
|
|
sync_builder_workdir "${BUILDER_DIR}" "${BUILD_WORK_DIR}"
|
|
|
|
|
|
|
|
|
|
# Share deb package cache across variants.
|
|
|
|
|
# Restore: populate work dir cache from shared cache before build.
|
|
|
|
|
@@ -1441,6 +1553,7 @@ if [ -f "$ISO_RAW" ]; then
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
validate_iso_memtest "$ISO_RAW"
|
|
|
|
|
validate_iso_live_boot_entries "$ISO_RAW"
|
|
|
|
|
validate_iso_nvidia_runtime "$ISO_RAW"
|
|
|
|
|
cp "$ISO_RAW" "$ISO_OUT"
|
|
|
|
|
echo ""
|
|
|
|
|
|