common.sh (1728B)
1 # Shared by the vm/ scripts; sourced, not run. 2 3 set -euo pipefail 4 5 ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) 6 OUT="$ROOT/out" 7 8 # Nothing here is pushed: `make build` makes two local images and only `make publish` (publish.sh) 9 # sends anything to the registry. SYSTEM_IMAGE is the real image, the one the ISO carries and 10 # publish.sh pushes. IMAGE is the same plus a test login (the Containerfile's `dev` stage), for the 11 # VM only; it never leaves this machine. VM_IMAGE is what the installed VM follows for updates: the 12 # published image, so `make upgrade` works once something is published. 13 REPO=${PUBLISH_REPO:-ghcr.io/sector-f-labs/sector-f-linux} 14 SYSTEM_IMAGE="$REPO:build" 15 IMAGE="$REPO-dev:build" 16 VM_IMAGE="$REPO:latest" 17 18 DISK="$OUT/disk.raw" 19 DISK_SIZE=20G 20 # A second, empty disk, which the VM sees as /dev/disk/by-id/virtio-patina-data. It is where the 21 # live ISO is built (live/build.sh): container storage and osbuild's work need tens of GB, and the 22 # disk is sparse, so it costs nothing until used. 23 DATA="$OUT/data.qcow2" 24 DATA_SIZE=50G 25 KEY="$OUT/id_ed25519" 26 SSH_PORT=2222 27 SERIAL_LOG="$OUT/serial.log" 28 # The screen, over VNC on localhost:5901, and QEMU's monitor, for screenshots. 29 VNC_DISPLAY=1 30 MONITOR="$OUT/monitor.sock" 31 PIDFILE="$OUT/qemu.pid" 32 33 OVMF_CODE=/usr/share/OVMF/OVMF_CODE_4M.fd 34 OVMF_VARS_TEMPLATE=/usr/share/OVMF/OVMF_VARS_4M.fd 35 OVMF_VARS="$OUT/OVMF_VARS.fd" 36 37 mkdir -p "$OUT" 38 39 say() { printf '==> %s\n' "$*"; } 40 die() { printf 'error: %s\n' "$*" >&2; exit 1; } 41 42 vm_running() { [[ -f "$PIDFILE" ]] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; } 43 44 vm_ssh() { 45 ssh -i "$KEY" -p "$SSH_PORT" \ 46 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR \ 47 root@127.0.0.1 "$@" 48 }