diff options
Diffstat (limited to 'build-openbsd-image.sh')
| -rwxr-xr-x | build-openbsd-image.sh | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/build-openbsd-image.sh b/build-openbsd-image.sh index a7bce6f..ca140b9 100755 --- a/build-openbsd-image.sh +++ b/build-openbsd-image.sh @@ -8,12 +8,13 @@ set -o nounset set -o errexit -_SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd) -. "$_SCRIPT_DIR/lib.sh" +SCRIPT_DIR="$(realpath "$(dirname "$0")")" +. "$SCRIPT_DIR/lib.sh" VERSION=8.0 ARCH=amd64 -DISK_SIZE_GB=38 +DISK_SIZE_GB=64 +DISK_FORMAT=qcow2 SSH_KEY="$HOME/.ssh/id_rsa.pub" DISKLABEL_TEMPLATE="" @@ -21,11 +22,14 @@ export PACKER_LOG=1 main() ( parse_args "$@" + cd openbsd-image/ require_readable_file "$SSH_KEY" + if [ -n "$DISKLABEL_TEMPLATE" ]; then require_readable_file "$DISKLABEL_TEMPLATE" fi + if [ -d build/ ]; then printf 'Build directory exists. Must delete before re-building. Proceed? (y/N)' read -r answer @@ -40,14 +44,21 @@ main() ( ;; esac fi + + if [ "$ARCH" = "arm64" ]; then + rm -f "$SCRIPT_DIR/openbsd-image/edk2-arm-vars.fd" + cp /opt/homebrew/share/qemu/edk2-arm-vars.fd "$SCRIPT_DIR/openbsd-image/edk2-arm-vars.fd" + fi + packer init . packer build \ -only "qemu.openbsd-$ARCH" \ -var "arch=$ARCH" \ -var "disk_size=$DISK_SIZE_GB" \ -var "version=$VERSION" \ + -var "disk_format=$DISK_FORMAT" \ -var "ssh_key=$(cat "$SSH_KEY")" \ - -var "cpus=$(get_ncpus)" \ + -var "cpus=2" \ ${DISKLABEL_TEMPLATE:+-var "disklabel_template=$(cat "$DISKLABEL_TEMPLATE")"} \ . ) @@ -71,6 +82,10 @@ parse_args() { DISK_SIZE_GB="$2" shift 2 ;; + --disk-format) + DISK_FORMAT="$2" + shift 2 + ;; --ssh-key) SSH_KEY="$2" shift 2 @@ -97,6 +112,7 @@ Options: --version VERSION OpenBSD version to build (default: $VERSION) --arch ARCH Target architecture: amd64 or arm64 (default: $ARCH) --disk-size-gb SIZE Disk size in GB (default: $DISK_SIZE_GB) + --disk-format FORMAT Format to use for the VM image (default: qcow2) --ssh-key PATH Path to SSH key (default: $SSH_KEY) --disklabel-template PATH Path to a custom disklabel autopartition template. If omitted, uses OpenBSD's default auto layout. |