#!/usr/bin/env bash # OrionOS ARM64 ISO builder — for Apple Silicon Macs (runs natively, no emulation). # On Intel Macs, this uses QEMU arm64 emulation (much slower). # # Requirements: Docker Desktop with "Use Rosetta for x86_64/amd64 emulation" OFF # (Rosetta emulation is for x86, not needed here) # # Usage: ./build-iso-arm64.sh # Output: dist/orionos-arm64-.iso set -euo pipefail REPO="$(cd "$(dirname "$0")" && pwd)" DIST="$REPO/dist" IMAGE="orionos-builder-arm64" ISO_TAG="orionos-arm64-$(date +%Y%m%d)" # ── preflight ───────────────────────────────────────────────────────── if ! command -v docker &>/dev/null; then echo "" echo " Docker is not installed." echo " Install Docker Desktop: https://www.docker.com/products/docker-desktop/" exit 1 fi if ! docker info &>/dev/null; then echo "" echo " Docker is not running. Open Docker Desktop and re-run." exit 1 fi # Ensure buildx is available (ships with Docker Desktop) if ! docker buildx version &>/dev/null; then echo "" echo " docker buildx not found. Update Docker Desktop to a recent version." exit 1 fi echo "" echo "┌─────────────────────────────────────────────┐" echo "│ OrionOS ARM64 ISO Builder │" echo "│ Native on Apple Silicon — no emulation │" echo "└─────────────────────────────────────────────┘" echo "" # ── build the builder image ─────────────────────────────────────────── echo "Step 1/3: Building Docker image (ARM64, Arch Linux ARM base)" echo " First run downloads ~400MB — cached afterwards." echo "" docker buildx build \ --platform linux/arm64 \ --load \ -t "$IMAGE" \ -f "$REPO/iso/docker/Dockerfile.arm64" \ "$REPO" # ── run the ISO build inside the container ──────────────────────────── echo "" echo "Step 2/3: Building ISO inside ARM64 Arch Linux container..." echo " (5-15 min depending on internet speed)" echo "" mkdir -p "$DIST" docker run \ --rm \ --privileged \ --platform linux/arm64 \ --security-opt seccomp=unconfined \ -v "$DIST:/dist" \ -e DIST=/dist \ "$IMAGE" # ── rename with date tag ────────────────────────────────────────────── echo "" echo "Step 3/3: Finalizing..." ISO="$(find "$DIST" -name "orionos-arm64*.iso" | head -1)" if [[ -z "$ISO" ]]; then echo "ERROR: ISO not found in $DIST — check the build output above." exit 1 fi FINAL="$DIST/$ISO_TAG.iso" mv "$ISO" "$FINAL" SIZE="$(du -sh "$FINAL" | cut -f1)" echo "" echo "┌─────────────────────────────────────────────────────┐" echo "│ Done! │" echo "│ │" echo "│ ISO: dist/$ISO_TAG.iso" echo "│ Size: $SIZE" echo "│ │" echo "│ Load in UTM: │" echo "│ 1. Open UTM → New VM → Virtualize │" echo "│ 2. Choose Linux → enable Apple Virtualization │" echo "│ 3. Boot ISO: select the file above │" echo "│ 4. Display: VirtIO GPU (recommended) │" echo "│ 5. Boot — OrionOS will auto-login as 'orion' │" echo "│ │" echo "│ Copy-paste between macOS and VM: │" echo "│ spice-vdagent is pre-installed and auto-started │" echo "└─────────────────────────────────────────────────────┘" echo ""