From 7d4cdcd1fde827a3caa1ce60cf8c479121d19f18 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 20 Nov 2023 13:55:01 +0200 Subject: [PATCH] BuildSystem: Add missing bootloader install script --- script/install-bootloader.sh | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 script/install-bootloader.sh diff --git a/script/install-bootloader.sh b/script/install-bootloader.sh new file mode 100755 index 0000000000..41d890f3a9 --- /dev/null +++ b/script/install-bootloader.sh @@ -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