aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile55
1 files changed, 55 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1b5c630
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,55 @@
+SHELL := /bin/sh
+
+VARS_FILE := openbsd79-arm64-macos.pkvars.hcl
+BUILD_DIR := build
+DISK := $(BUILD_DIR)/openbsd-7.9-aarch64.qcow2
+EFIVARS_RUN := $(BUILD_DIR)/efivars-run.fd
+EDK2_DIR := /opt/homebrew/share/qemu
+EDK2_CODE := $(EDK2_DIR)/edk2-aarch64-code.fd
+EDK2_VARS := edk2-arm-vars.fd
+SSH_PORT := 2222
+SSH_USER := eugene
+CPU := 1
+MEMORY := 4096M
+PACKER_LOG := 1
+
+export PACKER_LOG
+
+.PHONY: all init build run ssh clean
+
+all: build
+
+init:
+ packer init .
+
+build: init
+ rm -rf $(BUILD_DIR)
+ cp $(EDK2_DIR)/$(EDK2_VARS) ./$(EDK2_VARS)
+ packer build -var-file=$(VARS_FILE) .
+
+# Run the headless VM (SSH via port-forwarded localhost:$(SSH_PORT))
+run:
+ cp ./$(EDK2_VARS) $(EFIVARS_RUN)
+ # If you want to run with a GUI, replace -nographic
+ # with `-display cocoa`.
+ qemu-system-aarch64 \
+ -machine type=virt,accel=hvf \
+ -cpu host \
+ -m $(MEMORY) \
+ -smp $(CPU) \
+ -nographic \
+ -device qemu-xhci,id=xhci \
+ -device usb-kbd,bus=xhci.0 \
+ -device virtio-gpu-pci \
+ -netdev user,id=net0,hostfwd=tcp::$(SSH_PORT)-:22 \
+ -device virtio-net,netdev=net0 \
+ -drive file=$(DISK),if=virtio,cache=writeback,discard=ignore,format=qcow2 \
+ -drive file=$(EDK2_CODE),if=pflash,unit=0,format=raw,readonly=on \
+ -drive file=$(EFIVARS_RUN),if=pflash,unit=1,format=raw
+
+ssh:
+ ssh -p $(SSH_PORT) $(SSH_USER)@127.0.0.1
+
+clean:
+ rm -rf $(BUILD_DIR)
+