2022-07-30 05:28:29 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
2022-09-12 08:46:31 +00:00
|
|
|
: ${TMPDIR:=$XDG_RUNTIME_DIR}
|
|
|
|
: ${TMPDIR:=/tmp}
|
|
|
|
|
2022-08-29 07:59:56 +00:00
|
|
|
if [ "$1" == "-k" ]; then
|
|
|
|
kernel="$(realpath "$2")"
|
|
|
|
shift 2
|
|
|
|
fi
|
|
|
|
|
2022-07-30 05:28:29 +00:00
|
|
|
if [ ! -d "$1" ]; then
|
|
|
|
echo "Usage:"
|
|
|
|
echo " $0 <kernel build root> [kernel commandline] [initramfs]"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
kernel_base="$(realpath "$1")"
|
|
|
|
args="$2"
|
|
|
|
initramfs=""
|
2022-08-30 12:42:16 +00:00
|
|
|
shift 2
|
|
|
|
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
initramfs="$(realpath "$1")"
|
|
|
|
shift
|
2022-07-30 05:28:29 +00:00
|
|
|
fi
|
|
|
|
|
2022-08-29 07:59:56 +00:00
|
|
|
if [ -z "$kernel" ]; then
|
|
|
|
kernel="$kernel_base"/arch/arm64/boot/Image.gz
|
|
|
|
fi
|
|
|
|
|
2022-08-17 17:05:49 +00:00
|
|
|
base="$(dirname "$0")"
|
2022-07-30 05:28:29 +00:00
|
|
|
|
|
|
|
echo "Creating m1n1+kernel image"
|
2022-09-12 08:46:31 +00:00
|
|
|
cp "$base"/../../build/m1n1.bin "$TMPDIR/m1n1-linux.bin"
|
2022-08-29 07:59:56 +00:00
|
|
|
if [ -n "$args" ]; then
|
2022-09-12 08:46:31 +00:00
|
|
|
echo "chosen.bootargs=$args" >>"$TMPDIR/m1n1-linux.bin"
|
2022-07-30 05:28:29 +00:00
|
|
|
fi
|
|
|
|
|
2022-09-12 08:46:31 +00:00
|
|
|
cat "$kernel_base"/arch/arm64/boot/dts/apple/*.dtb >>"$TMPDIR/m1n1-linux.bin"
|
2022-08-29 07:59:56 +00:00
|
|
|
if [[ "$kernel" == *.gz ]]; then
|
2022-09-12 08:46:31 +00:00
|
|
|
cat "$kernel" >>"$TMPDIR/m1n1-linux.bin"
|
2022-08-29 07:59:56 +00:00
|
|
|
else
|
2022-09-12 08:46:31 +00:00
|
|
|
gzip -c <"$kernel" >>"$TMPDIR/m1n1-linux.bin"
|
2022-08-29 07:59:56 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$initramfs" ]; then
|
2022-09-12 08:46:31 +00:00
|
|
|
cat "$initramfs" >>"$TMPDIR/m1n1-linux.bin"
|
2022-07-30 06:59:21 +00:00
|
|
|
fi
|
2022-08-29 07:59:56 +00:00
|
|
|
|
2022-07-30 05:28:29 +00:00
|
|
|
echo "Chainloading to updated m1n1..."
|
2022-08-17 17:05:49 +00:00
|
|
|
python "$base"/chainload.py -r "$base"/../../build/m1n1.bin
|
2022-07-30 05:28:29 +00:00
|
|
|
echo "Starting guest..."
|
2022-09-12 08:46:31 +00:00
|
|
|
exec python "$base"/run_guest.py \
|
|
|
|
-c "load_system_map('$kernel_base/System.map')" "$@" \
|
|
|
|
-r "$TMPDIR/m1n1-linux.bin"
|