Build the Omarchy appliance for UTM SE on iPad and iPhone

omarchy-utm-make runs builder/build-utm.sh in a privileged linux/arm64
container: a 32G sparse GPT disk with the ISO's Btrfs subvolume layout,
Arch Linux ARM plus the aarch64 Omarchy packages, Limine on the UEFI
fallback path, omarchy-apply-system --defer-provisioning in the chroot,
first-boot provisioning staged with the arm64 Node tarball, one
limine-update, then a sealed and checked disk converted to compressed
qcow2. The host wraps it as a .utm bundle (no serial device: iOS has no
Ptty mode), zips it, and writes a sha256. omarchy-utm-boot boots the
result under qemu's interpreter, the closest stand-in for UTM SE.

fstab is written from the partition UUIDs directly: genfstab named the
hand-made loop device nodes, which sent the first boot into emergency
mode.

Claude-Session: https://claude.ai/code/session_019krxFwnSbEM2n2QNQ1rG1K
This commit is contained in:
雷电芽衣 committed 2026-09-03 04:50:14 -04:00
1 parent 2673c613d9
commit 70cbcb558c
12 files changed
+594

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
#!/bin/bash
set -e
usage() {
echo "Usage: $0 <omarchy-utm-se.qcow2|Omarchy.utm> [--hvf]" >&2
echo "Boots the appliance disk under qemu-system-aarch64 with the devices the UTM bundle declares." >&2
echo "TCG emulation is the default, the closest stand-in for UTM SE; --hvf uses Apple's hypervisor instead." >&2
exit 1
}
(( $# >= 1 )) || usage
disk="$1"
shift
accel=tcg
cpu=cortex-a72
if (( $# > 0 )); then
[[ $1 == "--hvf" ]] || usage
accel=hvf
cpu=host
fi
if [[ -d $disk ]]; then
disk=$(ls "$disk"/Data/*.qcow2 | head -n1)
fi
[[ -f $disk ]] || { echo "Error: $disk is not a disk image" >&2; exit 1; }
firmware=""
for candidate in "$(brew --prefix 2>/dev/null)/share/qemu" /usr/share/qemu /usr/share/edk2/aarch64; do
if [[ -f $candidate/edk2-aarch64-code.fd ]]; then
firmware="$candidate"
break
fi
done
[[ -n $firmware ]] || { echo "Error: no edk2-aarch64-code.fd found; install qemu" >&2; exit 1; }
run_dir="${TMPDIR:-/tmp}/omarchy-utm-boot"
mkdir -p "$run_dir"
vars="$run_dir/efi_vars.fd"
[[ -f $vars ]] || cp "$firmware/edk2-arm-vars.fd" "$vars"
echo "QMP socket: $run_dir/qmp.sock serial log: $run_dir/serial.log ssh: localhost:2222"
exec qemu-system-aarch64 \
-machine virt -cpu "$cpu" -accel "$accel" -smp 2 -m 2048 \
-drive if=pflash,format=raw,readonly=on,file="$firmware/edk2-aarch64-code.fd" \
-drive if=pflash,format=raw,file="$vars" \
-drive file="$disk",format=qcow2,if=none,id=drive0 \
-device virtio-blk-pci,drive=drive0 \
-device virtio-gpu-pci -device virtio-keyboard-pci -device virtio-mouse-pci \
-netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-:22 -device virtio-net-pci,netdev=net0 \
-device virtio-rng-pci \
-serial file:"$run_dir/serial.log" \
-qmp unix:"$run_dir/qmp.sock",server,nowait \
-display default
+66
View File
@@ -0,0 +1,66 @@
#!/bin/bash
set -e
BUILD_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
RELEASE_DIR="$BUILD_ROOT/release"
CACHE_DIR="$HOME/.cache/omarchy/utm-se"
BUILDER_IMAGE="menci/archlinuxarm:base"
if (( $# > 0 )); then
echo "Usage: $0" >&2
echo "Builds the Omarchy appliance for UTM SE into $RELEASE_DIR: a zipped .utm bundle and its sha256." >&2
exit 1
fi
DOCKER=(docker)
if ! docker version &>/dev/null; then
DOCKER=(sudo docker)
fi
# The build partitions a loop device and mounts btrfs inside the container, so the engine's kernel must offer both.
if ! "${DOCKER[@]}" run --rm --privileged --platform linux/arm64 "$BUILDER_IMAGE" \
sh -c 'grep -q btrfs /proc/filesystems && losetup -f >/dev/null'; then
echo "Error: the Docker engine's kernel needs btrfs and loop devices (colima: colima ssh -- sudo modprobe btrfs)" >&2
exit 1
fi
efi_vars=""
for candidate in "$(brew --prefix 2>/dev/null)/share/qemu/edk2-arm-vars.fd" /usr/share/qemu/edk2-arm-vars.fd /usr/share/edk2/aarch64/QEMU_VARS.fd; do
if [[ -f $candidate ]]; then
efi_vars="$candidate"
break
fi
done
if [[ -z $efi_vars ]]; then
echo "Error: no UEFI variable store template found; install qemu" >&2
exit 1
fi
mkdir -p "$RELEASE_DIR" "$CACHE_DIR/pkg"
rm -f "$RELEASE_DIR/omarchy-utm-se.qcow2" "$RELEASE_DIR/omarchy-utm-se.version"
"${DOCKER[@]}" run --rm --privileged --platform linux/arm64 \
-v "$BUILD_ROOT/builder:/builder:ro" \
-v "$RELEASE_DIR:/out" \
-v "$CACHE_DIR/pkg:/var/cache/pacman/pkg" \
"$BUILDER_IMAGE" bash /builder/build-utm.sh
version=$(cat "$RELEASE_DIR/omarchy-utm-se.version")
name="Omarchy-$version-aarch64-utm-se"
bundle="$RELEASE_DIR/$name/Omarchy.utm"
vm_uuid=$(uuidgen | tr '[:lower:]' '[:upper:]')
disk_uuid=$(uuidgen | tr '[:lower:]' '[:upper:]')
mac=$(printf '02:%02X:%02X:%02X:%02X:%02X' $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256)))
rm -rf "$RELEASE_DIR/$name"
mkdir -p "$bundle/Data"
mv "$RELEASE_DIR/omarchy-utm-se.qcow2" "$bundle/Data/$disk_uuid.qcow2"
cp "$efi_vars" "$bundle/Data/efi_vars.fd"
"$BUILD_ROOT/builder/utm/render" "$vm_uuid" "$disk_uuid" "$mac" "$version" >"$bundle/config.plist"
rm -f "$RELEASE_DIR/$name.utm.zip"
(cd "$RELEASE_DIR/$name" && zip -qr "../$name.utm.zip" Omarchy.utm)
(cd "$RELEASE_DIR" && shasum -a 256 "$name.utm.zip" >"$name.utm.zip.sha256")
rm -rf "$RELEASE_DIR/$name" "$RELEASE_DIR/omarchy-utm-se.version"
echo "Built $RELEASE_DIR/$name.utm.zip"