From e2515c1109071f5d9d068fcccf57a9f16d53bc91 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 18 Nov 2023 17:18:03 +0200 Subject: [PATCH] Buildsystem: default bootloader is not my custom one You can set BANAN_BOOTLOADER=GRUB to use grub instead. Image creation does not convert disk image now automatically between bootloaders and calling ./bos image-full is now required. --- bootloader/install.sh | 37 ----------------------------- script/config.sh | 4 ++++ script/image-create.sh | 53 +++++++++++++++++++++++++++++------------- script/image.sh | 8 ------- 4 files changed, 41 insertions(+), 61 deletions(-) delete mode 100755 bootloader/install.sh diff --git a/bootloader/install.sh b/bootloader/install.sh deleted file mode 100755 index a0c6aeffcb..0000000000 --- a/bootloader/install.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -set -e - -if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then - echo "You must set the BANAN_DISK_IMAGE_PATH 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 - -ROOT_PARTITION_INDEX=2 -ROOT_PARTITION_INFO=$(fdisk -x $BANAN_DISK_IMAGE_PATH | grep "^$BANAN_DISK_IMAGE_PATH" | head -$ROOT_PARTITION_INDEX | tail -1) -ROOT_PARTITION_GUID=$(echo $ROOT_PARTITION_INFO | cut -d' ' -f6) - -INSTALLER_BUILD_DIR=$(dirname $(realpath $0))/installer/build -BOOTLOADER_ELF=$BANAN_BUILD_DIR/bootloader/bootloader - -if ! [ -f $BOOTLOADER_ELF ]; then - echo "You must build the bootloader first" >&2 - exit 1 -fi - -if ! [ -d $INSTALLER_BUILD_DIR ]; then - mkdir -p $INSTALLER_BUILD_DIR - cd $INSTALLER_BUILD_DIR - cmake .. -fi - -cd $INSTALLER_BUILD_DIR -make - -echo installing bootloader -$INSTALLER_BUILD_DIR/x86_64-banan_os-bootloader-installer $BOOTLOADER_ELF $BANAN_DISK_IMAGE_PATH $ROOT_PARTITION_GUID diff --git a/script/config.sh b/script/config.sh index a42f8a5177..2c4ee7e259 100644 --- a/script/config.sh +++ b/script/config.sh @@ -25,3 +25,7 @@ export BANAN_DISK_IMAGE_PATH=$BANAN_BUILD_DIR/banan-os.img if [[ -z $BANAN_UEFI_BOOT ]]; then export BANAN_UEFI_BOOT=0 fi + +if [[ -z $BANAN_BOOTLOADER ]]; then + export BANAN_BOOTLOADER="BANAN" +fi diff --git a/script/image-create.sh b/script/image-create.sh index bce3e00114..246df4ca8e 100755 --- a/script/image-create.sh +++ b/script/image-create.sh @@ -15,6 +15,11 @@ if [[ -z $BANAN_TOOLCHAIN_PREFIX ]]; then exit 1 fi +if [[ -z $BANAN_BOOTLOADER ]]; then + echo "You must set the BANAN_BOOTLOADER environment variable" >&2 + exit 1 +fi + if [[ -z $BANAN_ARCH ]]; then echo "You must set the BANAN_ARCH environment variable" >&2 exit 1 @@ -74,23 +79,39 @@ PARTITION2=${LOOP_DEV}p2 sudo mkfs.ext2 -b 1024 -q $PARTITION2 -if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then - sudo mkfs.fat $PARTITION1 > /dev/null - sudo mount $PARTITION1 "$MOUNT_DIR" - sudo mkdir -p "$MOUNT_DIR/EFI/BOOT" - sudo "$BANAN_TOOLCHAIN_PREFIX/bin/grub-mkstandalone" -O "$BANAN_ARCH-efi" -o "$MOUNT_DIR/EFI/BOOT/BOOTX64.EFI" "boot/grub/grub.cfg=$BANAN_TOOLCHAIN_DIR/grub-memdisk.cfg" - sudo umount "$MOUNT_DIR" +if [[ "$BANAN_BOOTLOADER" == "GRUB" ]]; then + if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then + sudo mkfs.fat $PARTITION1 > /dev/null + sudo mount $PARTITION1 "$MOUNT_DIR" + sudo mkdir -p "$MOUNT_DIR/EFI/BOOT" + sudo "$BANAN_TOOLCHAIN_PREFIX/bin/grub-mkstandalone" -O "$BANAN_ARCH-efi" -o "$MOUNT_DIR/EFI/BOOT/BOOTX64.EFI" "boot/grub/grub.cfg=$BANAN_TOOLCHAIN_DIR/grub-memdisk.cfg" + sudo umount "$MOUNT_DIR" - sudo mount $PARTITION2 "$MOUNT_DIR" - sudo mkdir -p "$MOUNT_DIR/boot/grub" - sudo cp "$BANAN_TOOLCHAIN_DIR/grub-uefi.cfg" "$MOUNT_DIR/boot/grub/grub.cfg" - sudo umount "$MOUNT_DIR" -else - sudo mount $PARTITION2 "$MOUNT_DIR" - sudo grub-install --no-floppy --target=i386-pc --modules="normal ext2 multiboot" --boot-directory="$MOUNT_DIR/boot" $LOOP_DEV - sudo mkdir -p "$MOUNT_DIR/boot/grub" - sudo cp "$BANAN_TOOLCHAIN_DIR/grub-legacy-boot.cfg" "$MOUNT_DIR/boot/grub/grub.cfg" - sudo umount "$MOUNT_DIR" + sudo mount $PARTITION2 "$MOUNT_DIR" + sudo mkdir -p "$MOUNT_DIR/boot/grub" + sudo cp "$BANAN_TOOLCHAIN_DIR/grub-uefi.cfg" "$MOUNT_DIR/boot/grub/grub.cfg" + sudo umount "$MOUNT_DIR" + else + sudo mount $PARTITION2 "$MOUNT_DIR" + sudo grub-install --no-floppy --target=i386-pc --modules="normal ext2 multiboot" --boot-directory="$MOUNT_DIR/boot" $LOOP_DEV + sudo mkdir -p "$MOUNT_DIR/boot/grub" + sudo cp "$BANAN_TOOLCHAIN_DIR/grub-legacy-boot.cfg" "$MOUNT_DIR/boot/grub/grub.cfg" + sudo umount "$MOUNT_DIR" + fi fi sudo losetup -d $LOOP_DEV + +if [[ "$BANAN_BOOTLOADER" == "GRUB" ]]; then + echo > /dev/null +elif [[ "$BANAN_BOOTLOADER" == "BANAN" ]]; then + if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then + echo "banan bootloader does not support UEFI" >&2 + exit 1 + fi + $BANAN_SCRIPT_DIR/install-bootloader.sh +else + echo "unrecognized bootloader $BANAN_BOOTLOADER" >&2 + exit 1 +fi + diff --git a/script/image.sh b/script/image.sh index ae39bdfbad..9b7760ee1b 100755 --- a/script/image.sh +++ b/script/image.sh @@ -12,14 +12,6 @@ fi if [[ "$1" == "full" ]] || [[ ! -f $BANAN_DISK_IMAGE_PATH ]]; then $BANAN_SCRIPT_DIR/image-create.sh -else - fdisk -l $BANAN_DISK_IMAGE_PATH | grep -q 'EFI System'; IMAGE_IS_UEFI=$? - [[ $BANAN_UEFI_BOOT == 1 ]]; CREATE_IS_UEFI=$? - - if [[ $IMAGE_IS_UEFI -ne $CREATE_IS_UEFI ]]; then - echo Converting disk image to/from UEFI - $BANAN_SCRIPT_DIR/image-create.sh - fi fi LOOP_DEV=$(sudo losetup --show -f "$BANAN_DISK_IMAGE_PATH")