Compare commits

..

8 Commits

Author SHA1 Message Date
46a31b8efa Merge pull request 'update main 21.11.23' (#2) from Bananymous/banan-os:main into main
Reviewed-on: #2
2023-11-21 14:58:13 +02:00
85a5e81224 BuildSystem: Check value of BANAN_UEFI_BOOT with if ((...)); then 2023-11-21 14:58:13 +02:00
7d4cdcd1fd BuildSystem: Add missing bootloader install script 2023-11-21 14:58:13 +02:00
d72db1f81c BuildSystem: image sh
mount in build dir

Signed-off-by: Sinipelto <sinipelto@noreply.bananymous.com>
2023-11-20 14:12:35 +02:00
6cfa56dcec BuildSystem: image create sh
use banan build dir

Signed-off-by: Sinipelto <sinipelto@noreply.bananymous.com>
2023-11-20 14:11:29 +02:00
f97922a2b5 Update script/image.sh
mount dir default value

Signed-off-by: Sinipelto <sinipelto@noreply.bananymous.com>
2023-11-20 13:28:53 +02:00
566724d986 Update script/image-create.sh
custom mount dir

Signed-off-by: Sinipelto <sinipelto@noreply.bananymous.com>
2023-11-20 13:28:10 +02:00
a7b1810aa2 Update script/image.sh
handle custom mount dir

Signed-off-by: Sinipelto <sinipelto@noreply.bananymous.com>
2023-11-20 13:24:15 +02:00
4 changed files with 76 additions and 12 deletions

View File

@@ -25,13 +25,23 @@ if [[ -z $BANAN_ARCH ]]; then
exit 1 exit 1
fi fi
if [[ -z $BANAN_UEFI_BOOT ]]; then
echo "You must set the BANAN_UEFI_BOOT 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
DISK_SIZE=$[50 * 1024 * 1024] DISK_SIZE=$[50 * 1024 * 1024]
MOUNT_DIR=/mnt 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
@@ -79,8 +89,10 @@ PARTITION2=${LOOP_DEV}p2
sudo mkfs.ext2 -b 1024 -q $PARTITION2 sudo mkfs.ext2 -b 1024 -q $PARTITION2
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"
@@ -100,12 +112,14 @@ if [[ "$BANAN_BOOTLOADER" == "GRUB" ]]; then
fi fi
fi fi
sudo losetup -d $LOOP_DEV sudo losetup -d $LOOP_DEV || { echo "Failed to remove loop device for banan mount."; exit 1; }
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
@@ -114,4 +128,3 @@ else
echo "unrecognized bootloader $BANAN_BOOTLOADER" >&2 echo "unrecognized bootloader $BANAN_BOOTLOADER" >&2
exit 1 exit 1
fi fi

View File

@@ -10,15 +10,22 @@ if [[ -z $BANAN_SYSROOT_TAR ]]; then
exit 1 exit 1
fi fi
if [[ -z $BANAN_BUILD_DIR ]]; then
echo "You must set the BANAN_BUILD_DIR environment variable" >&2
exit 1
fi
if [[ "$1" == "full" ]] || [[ ! -f $BANAN_DISK_IMAGE_PATH ]]; then if [[ "$1" == "full" ]] || [[ ! -f $BANAN_DISK_IMAGE_PATH ]]; then
$BANAN_SCRIPT_DIR/image-create.sh $BANAN_SCRIPT_DIR/image-create.sh
fi fi
LOOP_DEV=$(sudo losetup --show -f "$BANAN_DISK_IMAGE_PATH") LOOP_DEV="$(sudo losetup --show -f $BANAN_DISK_IMAGE_PATH)"
sudo partprobe $LOOP_DEV sudo partprobe $LOOP_DEV
ROOT_PARTITION=${LOOP_DEV}p2 ROOT_PARTITION="${LOOP_DEV}p2"
MOUNT_DIR=/mnt MOUNT_DIR="${MOUNT_DIR:-$BANAN_BUILD_DIR/bananmnt}"
sudo mkdir -p $MOUNT_DIR || { echo "Failed to create mount point dir."; exit 1; }
sudo mount $ROOT_PARTITION $MOUNT_DIR sudo mount $ROOT_PARTITION $MOUNT_DIR
@@ -26,6 +33,8 @@ cd $MOUNT_DIR
sudo tar xf $BANAN_SYSROOT_TAR sudo tar xf $BANAN_SYSROOT_TAR
cd cd
sudo umount $MOUNT_DIR sudo umount $MOUNT_DIR || { echo "Failed to unmount banan mount."; exit 1; }
sudo losetup -d $LOOP_DEV sudo losetup -d $LOOP_DEV || { echo "Failed to remove loop device for banan mount."; exit 1; }
sudo rm -rf "$MOUNT_DIR"

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