update main 21.11.23 #2

Merged
Sinipelto merged 3 commits from Bananymous/banan-os:main into main 2023-11-21 14:58:13 +02:00
3 changed files with 46 additions and 5 deletions

View File

@ -41,7 +41,7 @@ MOUNT_DIR="${MOUNT_DIR:-$BANAN_BUILD_DIR/bananmnt}"
truncate -s 0 "$BANAN_DISK_IMAGE_PATH" truncate -s 0 "$BANAN_DISK_IMAGE_PATH"
truncate -s $DISK_SIZE "$BANAN_DISK_IMAGE_PATH" truncate -s $DISK_SIZE "$BANAN_DISK_IMAGE_PATH"
if [ "$BANAN_UEFI_BOOT" == "1" ]; then if (($BANAN_UEFI_BOOT)); then
sed -e 's/\s*\([-\+[:alnum:]]*\).*/\1/' << EOF | fdisk "$BANAN_DISK_IMAGE_PATH" > /dev/null sed -e 's/\s*\([-\+[:alnum:]]*\).*/\1/' << EOF | fdisk "$BANAN_DISK_IMAGE_PATH" > /dev/null
g # gpt g # gpt
n # new partition n # new partition
@ -92,7 +92,7 @@ sudo mkfs.ext2 -b 1024 -q $PARTITION2
sudo mkdir -p $MOUNT_DIR || { echo "Failed to create banan mount dir."; exit 1; } sudo mkdir -p $MOUNT_DIR || { echo "Failed to create banan mount dir."; exit 1; }
if [[ "$BANAN_BOOTLOADER" == "GRUB" ]]; then if [[ "$BANAN_BOOTLOADER" == "GRUB" ]]; then
if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then if (($BANAN_UEFI_BOOT)); then
sudo mkfs.fat $PARTITION1 > /dev/null sudo mkfs.fat $PARTITION1 > /dev/null
sudo mount $PARTITION1 "$MOUNT_DIR" sudo mount $PARTITION1 "$MOUNT_DIR"
sudo mkdir -p "$MOUNT_DIR/EFI/BOOT" sudo mkdir -p "$MOUNT_DIR/EFI/BOOT"
@ -119,7 +119,7 @@ sudo rm -rf $MOUNT_DIR || { echo "Failed to remove banan mount dir."; exit 1; }
if [[ "$BANAN_BOOTLOADER" == "GRUB" ]]; then if [[ "$BANAN_BOOTLOADER" == "GRUB" ]]; then
echo > /dev/null echo > /dev/null
elif [[ "$BANAN_BOOTLOADER" == "BANAN" ]]; then elif [[ "$BANAN_BOOTLOADER" == "BANAN" ]]; then
if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then if (($BANAN_UEFI_BOOT)); then
echo "banan bootloader does not support UEFI" >&2 echo "banan bootloader does not support UEFI" >&2
exit 1 exit 1
fi fi
@ -128,4 +128,3 @@ else
echo "unrecognized bootloader $BANAN_BOOTLOADER" >&2 echo "unrecognized bootloader $BANAN_BOOTLOADER" >&2
exit 1 exit 1
fi fi

42
script/install-bootloader.sh Executable file
View File

@ -0,0 +1,42 @@
#!/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
if [[ -z $BANAN_ROOT_DIR ]]; then
echo "You must set the BANAN_ROOT_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=$BANAN_ROOT_DIR/bootloader/installer/build
BOOTLOADER_ELF=$BANAN_BUILD_DIR/bootloader/bios/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

View File

@ -9,7 +9,7 @@ if [[ -z $OVMF_PATH ]]; then
OVMF_PATH="/usr/share/ovmf/x64/OVMF.fd" OVMF_PATH="/usr/share/ovmf/x64/OVMF.fd"
fi fi
if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then if (($BANAN_UEFI_BOOT)); then
BIOS_ARGS="-bios $OVMF_PATH -net none" BIOS_ARGS="-bios $OVMF_PATH -net none"
fi fi