summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/boot-image.sh25
-rwxr-xr-xscripts/boot.sh22
-rw-r--r--scripts/lib-boot-args.sh38
-rwxr-xr-xscripts/test-disk.sh6
4 files changed, 50 insertions, 41 deletions
diff --git a/scripts/boot-image.sh b/scripts/boot-image.sh
index 913e5cb..e8c093c 100755
--- a/scripts/boot-image.sh
+++ b/scripts/boot-image.sh
@@ -34,29 +34,8 @@ GUI=""
34DEBUG="" 34DEBUG=""
35 35
36# ---- args ---- 36# ---- args ----
37while [ $# -gt 0 ]; do 37source "$SCRIPT_DIR/lib-boot-args.sh"
38 case "$1" in 38parse_boot_args "$@"
39 --gui | -g) GUI="-vga std" ;;
40 --debug | -d) DEBUG="-s -S" ;;
41 --mem)
42 shift
43 MEM="$1"
44 ;;
45 --smp)
46 shift
47 SMP="$1"
48 ;;
49 --help | -h)
50 head -20 "$0" | grep "^#" | sed 's/^# //'
51 exit 0
52 ;;
53 *)
54 echo "unknown: $1"
55 exit 1
56 ;;
57 esac
58 shift
59done
60 39
61# ---- build image if missing ---- 40# ---- build image if missing ----
62if [ ! -f "$IMAGE" ]; then 41if [ ! -f "$IMAGE" ]; then
diff --git a/scripts/boot.sh b/scripts/boot.sh
index 99fd103..5b8e6fa 100755
--- a/scripts/boot.sh
+++ b/scripts/boot.sh
@@ -45,33 +45,21 @@ GUI=""
45DEBUG="" 45DEBUG=""
46 46
47# ---- args ---- 47# ---- args ----
48while [ $# -gt 0 ]; do 48source "$SCRIPT_DIR/lib-boot-args.sh"
49# boot.sh-specific flags live here; everything else is shared.
50handle_arg() {
49 case "$1" in 51 case "$1" in
50 --gui | -g) GUI="-vga std" ;;
51 --debug | -d) DEBUG="-s -S" ;;
52 --release | -r) 52 --release | -r)
53 PROFILE="release" 53 PROFILE="release"
54 CARGO_FLAGS="--release" 54 CARGO_FLAGS="--release"
55 ;; 55 ;;
56 --mem)
57 shift
58 MEM="$1"
59 ;;
60 --smp)
61 shift
62 SMP="$1"
63 ;;
64 --help | -h)
65 head -20 "$0" | grep "^#" | sed 's/^# //'
66 exit 0
67 ;;
68 *) 56 *)
69 echo "unknown: $1" 57 echo "unknown: $1"
70 exit 1 58 exit 1
71 ;; 59 ;;
72 esac 60 esac
73 shift 61}
74done 62parse_boot_args "$@"
75 63
76OUT_DIR="target/x86_64-unknown-uefi/$PROFILE" 64OUT_DIR="target/x86_64-unknown-uefi/$PROFILE"
77KERNEL="$OUT_DIR/rsdos.efi" 65KERNEL="$OUT_DIR/rsdos.efi"
diff --git a/scripts/lib-boot-args.sh b/scripts/lib-boot-args.sh
new file mode 100644
index 0000000..ec97500
--- /dev/null
+++ b/scripts/lib-boot-args.sh
@@ -0,0 +1,38 @@
1#!/usr/bin/env bash
2#
3# scripts/lib-boot-args.sh — shared CLI parsing for the QEMU boot scripts.
4# Sourced, not executed. The caller sets default values for GUI/DEBUG/
5# MEM/SMP first, then calls `parse_boot_args "$@"`. A caller with extra
6# flags defines its own `handle_arg()` to intercept them before the
7# shared cases run (unknown args still fail loudly).
8set -euo pipefail
9
10parse_boot_args() {
11 while [ $# -gt 0 ]; do
12 case "$1" in
13 --gui | -g) GUI="-vga std" ;;
14 --debug | -d) DEBUG="-s -S" ;;
15 --mem)
16 shift
17 MEM="$1"
18 ;;
19 --smp)
20 shift
21 SMP="$1"
22 ;;
23 --help | -h)
24 head -20 "$0" | grep "^#" | sed 's/^# //'
25 exit 0
26 ;;
27 *) handle_arg "$1" ;;
28 esac
29 shift
30 done
31}
32
33# Default: no extra flags. A script with more defines its own before
34# calling parse_boot_args.
35handle_arg() {
36 echo "unknown: $1"
37 exit 1
38}
diff --git a/scripts/test-disk.sh b/scripts/test-disk.sh
index 11a9b05..0268fff 100755
--- a/scripts/test-disk.sh
+++ b/scripts/test-disk.sh
@@ -72,7 +72,11 @@ cargo build --package rsdos --target x86_64-unknown-uefi
72echo "==> 2/6 deploy to ESP + ensure disk image" 72echo "==> 2/6 deploy to ESP + ensure disk image"
73mkdir -p "$ESP_DIR/EFI/BOOT" 73mkdir -p "$ESP_DIR/EFI/BOOT"
74cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI" 74cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI"
75"$SCRIPT_DIR/mkdisk.sh" $([ "$FRESH" -eq 1 ] && echo --fresh) "$IMG" 75if [ "$FRESH" -eq 1 ]; then
76 "$SCRIPT_DIR/mkdisk.sh" --fresh "$IMG"
77else
78 "$SCRIPT_DIR/mkdisk.sh" "$IMG"
79fi
76 80
77echo "==> 3/6 boot QEMU (headless)" 81echo "==> 3/6 boot QEMU (headless)"
78kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true 82kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true