From 86fd2c1e6a602a1086d164b1ab2676c91b3684c6 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Thu, 31 Oct 2019 23:18:02 +0100 Subject: Implement simple option to override grub-i386 dirs For people with some weird hipster-OS which doesn't have a `/usr/lib` the current script breaks. Allowing to override the path with an environment variable seems to be the easiest way to solve this issue for now. --- kernel/build.sh | 10 ++++++---- kernel/shell.nix | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/kernel/build.sh b/kernel/build.sh index bf8c971..9d48229 100755 --- a/kernel/build.sh +++ b/kernel/build.sh @@ -9,7 +9,8 @@ GRUB_CFG_PATH="src/grub.cfg" ARCH="x86_64" TARGET="$ARCH-uff" RUST_BIN="$TARGET_PATH/$TARGET/debug/libkernel.a" -QUEMU="qemu-system-x86_64 -cdrom $TARGET_PATH/uff.iso" +QEMU="qemu-system-x86_64 -cdrom $TARGET_PATH/uff.iso" +GRUB_i386="${GRUB_i386:-/usr/lib/grub/i386-pc}" cleanup_target() { rm -f $TARGET_PATH/uff.iso &> /dev/null @@ -48,7 +49,8 @@ build_kernel_iso() { mkdir $TMP_PATH/isofiles/boot/grub &> /dev/null cp $TARGET_PATH/kernel.bin $TMP_PATH/isofiles/boot &> /dev/null cp $GRUB_CFG_PATH $TMP_PATH/isofiles/boot/grub/grub.cfg &> /dev/null - grub-mkrescue -d /usr/lib/grub/i386-pc -o $TARGET_PATH/uff.iso $TMP_PATH/isofiles + [ -d "$GRUB_i386" ] || { echo "Grub img $GRUB_i386 does not exist!"; exit 1; } + grub-mkrescue -d "$GRUB_i386" -o $TARGET_PATH/uff.iso $TMP_PATH/isofiles cleanup_temp } @@ -57,11 +59,11 @@ build_init() { } build_launch() { - $QUEMU + $QEMU } build_launch_serial() { - $QUEMU -device isa-debug-exit,iobase=0xf4,iosize=0x04 -serial stdio #-display none + $QEMU -device isa-debug-exit,iobase=0xf4,iosize=0x04 -serial stdio #-display none } build_run() { diff --git a/kernel/shell.nix b/kernel/shell.nix index ba2647a..4fc72af 100644 --- a/kernel/shell.nix +++ b/kernel/shell.nix @@ -2,4 +2,7 @@ with import { }; mkShell { name = "uff-os"; buildInputs = [ rustup nasm grub2 cargo-xbuild gcc xorriso ]; + shellHook = '' + export GRUB_i386="${grub2}/lib/grub/i386-pc" + ''; } -- cgit v1.2.3-54-g00ecf