Skip to content

Commit

Permalink
Add support for ARM64
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-carlborg committed Jul 5, 2023
1 parent e360e3d commit 262779c
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 19 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ jobs:
- '13.2'

architecture:
- x86-64
- name: x86-64
qemu: x86_64

- name: arm64
qemu: aarch64

exclude:
- version: '12.2'
architecture:
name: arm64
qemu: aarch64

steps:
- name: Clone Repository
Expand All @@ -33,23 +43,17 @@ jobs:
persist-credentials: false

- name: Install Dependencies
run: apt update && apt install curl unzip "qemu-system-$QEMU_ARCHITECTURE" -y
env:
QEMU_ARCHITECTURE: ${{
matrix.architecture == 'x86-64' && 'x86' ||
matrix.architecture == 'arm64' && 'aarch64' ||
matrix.architecture
}}
run: apt update && apt install curl unzip "qemu-system-${{ matrix.architecture.qemu }}" -y

- uses: hashicorp/setup-packer@main
with:
version: "1.7.1"
version: "1.9.1"

# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Build Image
run: PACKER_LOG=1 ./build.sh '${{ matrix.version }}' '${{ matrix.architecture }}' -var 'headless=true'
run: PACKER_LOG=1 ./build.sh '${{ matrix.version }}' '${{ matrix.architecture.name }}' -var 'headless=true'

- name: Extract Version
id: version
Expand Down
32 changes: 23 additions & 9 deletions freebsd.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ variable "architecture" {
description = "The architecture of CPU to use when building"
}

variable "image_architecture" {
default = "amd64"
type = string
description = "The name of the architecture used by the ISO image"
}

variable "qemu_architecture" {
default = "x86_64"
type = string
description = "The name of the architecture in the QEMU binary"
}

variable "machine_type" {
default = "pc"
type = string
Expand Down Expand Up @@ -84,19 +96,18 @@ variable "accelerator" {
description = "The accelerator type to use when running the VM"
}

variable "firmware" {
type = string
description = "The firmware file to be used by QEMU"
}

locals {
image_architecture = var.architecture == "x86-64" ? "amd64" : (
var.architecture == "arm64" ? "arm64-aarch64" : var.architecture
)
vm_name = "freebsd-${var.os_version}-${var.architecture}.qcow2"
iso_path = "ISO-IMAGES/${var.os_version}/FreeBSD-${var.os_version}-RELEASE-${local.image_architecture}-disc1.iso"
qemu_architecture = var.architecture == "arm64" ? "aarch64" : (
var.architecture == "x86-64" ? "x86_64" : var.architecture
)
iso_path = "ISO-IMAGES/${var.os_version}/FreeBSD-${var.os_version}-RELEASE-${var.image_architecture}-disc1.iso"
}

source "qemu" "qemu" {
machine_type = var.machine_type
machine_type = "${var.machine_type}"
cpus = var.cpus
memory = var.memory
net_device = "virtio-net"
Expand All @@ -110,12 +121,14 @@ source "qemu" "qemu" {
use_default_display = var.use_default_display
display = var.display
accelerator = var.accelerator
qemu_binary = "qemu-system-${var.qemu_architecture}"
firmware = var.firmware

boot_wait = "5s"

boot_command = [
"2<enter><wait30s>",
"<enter><wait>",
"<enter><wait10>",
"mdmfs -s 100m md1 /tmp<enter><wait>",
"dhclient -l /tmp/dhclient.leases -p /tmp/dhclient.pid vtnet0<enter><wait5>",
"fetch -o /tmp/installerconfig http://{{.HTTPIP}}:{{.HTTPPort}}/resources/installerconfig<enter><wait>",
Expand All @@ -132,6 +145,7 @@ source "qemu" "qemu" {

qemuargs = [
["-cpu", var.cpu_type],
["-boot", "strict=off"],
["-monitor", "none"]
]

Expand Down
1 change: 1 addition & 0 deletions var_files/12.4/arm64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checksum = "sha256:daa57f093f43804087b79f98aa7751c33b56c91c1f593041a015a59f4cbe3dbc"
1 change: 1 addition & 0 deletions var_files/13.0/arm64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checksum = "sha256:a69840e22239a12138c0fda01f242bab201ed474414905554189ec87caf81ff0"
1 change: 1 addition & 0 deletions var_files/13.1/arm64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checksum = "sha256:ae8f9139153f31b193fff267f4935a64706c3dfc5015b4a2662c5663b77b4173"
1 change: 1 addition & 0 deletions var_files/13.2/arm64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checksum = "sha256:edfaf27a4f33134691bdf782298a9dd11d173b7042363f1432f0f2e87807a648"
7 changes: 7 additions & 0 deletions var_files/arm64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
architecture = "arm64"
image_architecture = "arm64-aarch64"
qemu_architecture = "aarch64"
machine_type = "virt"
cpu_type = "cortex-a57"
/*firmware = "qemu_efi.fd"*/
firmware = "edk2-aarch64-code.fd"
3 changes: 3 additions & 0 deletions var_files/x86-64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
architecture = "x86-64"
image_architecture = "amd64"
qemu_architecture = "x86_64""
firmware = "bios-256k.bin

0 comments on commit 262779c

Please sign in to comment.