2023-11-12 01:17:30 +02:00
|
|
|
#!/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
|
|
|
|
|
2023-11-13 18:53:38 +02:00
|
|
|
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)
|
|
|
|
|
2023-11-12 01:17:30 +02:00
|
|
|
CURRENT_DIR=$(dirname $(realpath $0))
|
|
|
|
|
|
|
|
INSTALLER_DIR=$CURRENT_DIR/installer
|
|
|
|
INSTALLER_BUILD_DIR=$INSTALLER_DIR/build
|
|
|
|
|
|
|
|
BUILD_DIR=$CURRENT_DIR/build
|
|
|
|
|
|
|
|
if ! [ -d $INSTALLER_BUILD_DIR ]; then
|
|
|
|
mkdir -p $INSTALLER_BUILD_DIR
|
|
|
|
cd $INSTALLER_BUILD_DIR
|
|
|
|
cmake ..
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $INSTALLER_BUILD_DIR
|
|
|
|
make
|
|
|
|
|
|
|
|
mkdir -p $BUILD_DIR
|
|
|
|
|
|
|
|
echo compiling bootloader
|
2023-11-14 03:26:03 +02:00
|
|
|
x86_64-banan_os-as $CURRENT_DIR/boot.S -o $BUILD_DIR/boot.o
|
|
|
|
x86_64-banan_os-as $CURRENT_DIR/command_line.S -o $BUILD_DIR/command_line.o
|
|
|
|
x86_64-banan_os-as $CURRENT_DIR/disk.S -o $BUILD_DIR/disk.o
|
|
|
|
x86_64-banan_os-as $CURRENT_DIR/memory_map.S -o $BUILD_DIR/memory_map.o
|
|
|
|
x86_64-banan_os-as $CURRENT_DIR/utils.S -o $BUILD_DIR/utils.o
|
2023-11-12 01:17:30 +02:00
|
|
|
|
|
|
|
echo linking bootloader
|
2023-11-14 03:26:03 +02:00
|
|
|
x86_64-banan_os-ld -nostdlib -T $CURRENT_DIR/linker.ld $BUILD_DIR/boot.o $BUILD_DIR/command_line.o $BUILD_DIR/disk.o $BUILD_DIR/memory_map.o $BUILD_DIR/utils.o -o $BUILD_DIR/bootloader
|
2023-11-12 01:17:30 +02:00
|
|
|
|
2023-11-13 18:53:38 +02:00
|
|
|
echo installing bootloader to
|
|
|
|
$INSTALLER_BUILD_DIR/x86_64-banan_os-bootloader-installer $BUILD_DIR/bootloader $BANAN_DISK_IMAGE_PATH $ROOT_PARTITION_GUID
|