From 2c66de888f19d141854d42a0eacfe1e677b4ced7 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 17 Aug 2026 06:07:59 +0300 Subject: [PATCH] BuildSystem: Add option to generate an ISO file This creates ISO file with compressed initrd and grub files that can be live booted easily --- script/build.sh | 9 +++++++++ script/config.sh | 1 + script/iso.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100755 script/iso.sh diff --git a/script/build.sh b/script/build.sh index 016e5ab8..1257583a 100755 --- a/script/build.sh +++ b/script/build.sh @@ -56,6 +56,12 @@ create_image () { $BANAN_SCRIPT_DIR/image.sh "$1" } +create_iso () { + build_target all + build_target install + $BANAN_SCRIPT_DIR/iso.sh +} + run_qemu () { create_image $BANAN_SCRIPT_DIR/qemu.sh $@ @@ -103,6 +109,9 @@ case $1 in image-full) create_image full ;; + iso) + create_iso + ;; qemu) run_qemu -serial stdio $QEMU_ACCEL ;; diff --git a/script/config.sh b/script/config.sh index 075c168c..52715e1c 100644 --- a/script/config.sh +++ b/script/config.sh @@ -26,6 +26,7 @@ export BANAN_SYSROOT="$BANAN_BUILD_DIR/sysroot" export BANAN_FAKEROOT="$BANAN_BUILD_DIR/fakeroot-context" export BANAN_DISK_IMAGE_PATH="$BANAN_BUILD_DIR/banan-os.img" +export BANAN_ISO_PATH="$BANAN_BUILD_DIR/banan-os.iso" if [[ -z $BANAN_UEFI_BOOT ]]; then export BANAN_UEFI_BOOT=0 diff --git a/script/iso.sh b/script/iso.sh new file mode 100755 index 00000000..0eae107a --- /dev/null +++ b/script/iso.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +if [ -z $BANAN_ISO_PATH ]; then + echo "You must set the BANAN_ISO_PATH environment variable" >&2 + exit 1 +fi + +if [ -z $BANAN_SYSROOT ]; then + echo "You must set the BANAN_SYSROOT environment variable" >&2 + exit 1 +fi + +if [ -z $BANAN_FAKEROOT ]; then + echo "You must set the BANAN_FAKEROOT environment variable" >&2 + exit 1 +fi + +if [ -z $BANAN_BUILD_DIR ]; then + echo "You must set the BANAN_BUILD_DIR environment variable" >&2 + exit 1 +fi + +set -u + +iso_dir="$BANAN_BUILD_DIR/iso" + +rm -rf "$iso_dir" +mkdir -p "$iso_dir/boot/grub" + +echo "Packing initrd" +fakeroot -i "$BANAN_FAKEROOT" tar -C "$BANAN_SYSROOT" --exclude='./boot' -zcf "$iso_dir/boot/banan-os.initrd" . + +strip -o "$iso_dir/boot/banan-os.kernel" --strip-unneeded "$BANAN_BUILD_DIR/kernel/banan-os.kernel" + +cat > "$iso_dir/boot/grub/grub.cfg" << EOF +insmod all_video +menuentry "banan-os" { + multiboot2 /boot/banan-os.kernel readonly + module2 --nounzip /boot/banan-os.initrd +} +EOF + +echo "Creating ISO" +grub-mkrescue --compress=gz -o "$BANAN_ISO_PATH" "$iso_dir" >/dev/null