-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·61 lines (51 loc) · 1.87 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# build.sh - compile OnyxShell and convert to OnyxExec v2 (.onx) format.
#
# Usage:
# ./build.sh
#
# Prerequisites:
# - Rust nightly with riscv64gc-unknown-none-elf target
# - elf2onx tool (built from OnyxKernel/tools)
#
# Output:
# build/onyx-osh - raw RISC-V ELF
# build/osh.onx - OnyxExec v2 binary (place at /bin/osh in the disk image)
set -e
HERE="$(cd "$(dirname "$0")" && pwd)"
ONYXKERNEL_DIR="${ONYXKERNEL_DIR:-$(cd "$HERE/../OnyxKernel" && pwd)}"
HOST_TARGET=$(rustc -vV | sed -ne 's/^host: //p')
ELF2ONX="$ONYXKERNEL_DIR/target/$HOST_TARGET/release/elf2onx"
# Build the shell (release mode, riscv64gc target).
echo "==> Building OnyxShell"
cd "$HERE"
cargo build --release 2>&1 | tail -5
ELF="$HERE/target/riscv64gc-unknown-none-elf/release/onyx-osh"
if [ ! -f "$ELF" ]; then
echo "ERROR: $ELF not found - build failed?"
exit 1
fi
# Prepare output directory.
mkdir -p "$HERE/build"
cp "$ELF" "$HERE/build/onyx-osh"
# Check for elf2onx.
if [ ! -f "$ELF2ONX" ]; then
echo "==> elf2onx not found at $ELF2ONX"
echo " Building elf2onx from OnyxKernel..."
HOST_TARGET=$(rustc -vV | sed -ne 's/^host: //p')
(cd "$ONYXKERNEL_DIR" && cargo build --release -p onyx_tools --target "$HOST_TARGET")
fi
if [ ! -f "$ELF2ONX" ]; then
echo "ERROR: elf2onx still not found. Build OnyxKernel tools first:"
echo " cd $ONYXKERNEL_DIR && cargo build --release -p onyx_tools"
exit 1
fi
# Convert ELF → OnyxExec v2 (compressed, ring 1 = root space).
# --ring=1 is required so the shell retains root privileges after
# /bin/login execs it. Without --ring=1, exec drops the process
# to ring 2 (user space), and file-mutation commands (rm, mkdir,
# cp, mv, touch) will fail with EPERM.
echo "==> Converting ELF → osh.onx"
"$ELF2ONX" --ring=1 --compress "$ELF" "$HERE/build/osh.onx"
echo "==> Done: $HERE/build/osh.onx"
ls -la "$HERE/build/osh.onx"