Skip to content

Commit 86e42b5

Browse files
Add support for ARM64
1 parent d119ac6 commit 86e42b5

10 files changed

+93
-50
lines changed

.github/workflows/build.yml

+19-7
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ on:
1313

1414
jobs:
1515
build:
16-
name: Build
16+
name: ${{ matrix.version }}, ${{ matrix.architecture.name }}
1717
runs-on: ubuntu-latest
18+
container: alpine:edge
1819
strategy:
1920
matrix:
2021
version:
@@ -24,7 +25,21 @@ jobs:
2425

2526
architecture:
2627
- name: x86-64
27-
qemu: x86
28+
qemu: x86_64
29+
30+
- name: arm64
31+
qemu: aarch64
32+
33+
exclude:
34+
- version: 9.2
35+
architecture:
36+
name: arm64
37+
qemu: aarch64
38+
39+
- version: 9.3
40+
architecture:
41+
name: arm64
42+
qemu: aarch64
2843

2944
steps:
3045
- name: Clone Repository
@@ -33,16 +48,13 @@ jobs:
3348
persist-credentials: false
3449

3550
- name: Install Dependencies
36-
run: sudo apt update && sudo apt install curl unzip "qemu-system-${{ matrix.architecture.name }}" -y
51+
# run: sudo apt update && sudo apt install curl unzip "qemu-system-${{ matrix.architecture.qemu }}" -y
52+
run: apk add --no-cache qemu-img "qemu-system-${{ matrix.architecture.qemu }}"
3753

3854
- uses: hashicorp/setup-packer@main
3955
with:
4056
version: ${{ env.PACKER_VERSION }}
4157

42-
- name: Download QEMU UEFI
43-
if: matrix.architecture.name == 'arm64'
44-
run: curl -o resources/qemu_efi.fd -L https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd
45-
4658
# - name: Setup tmate session
4759
# uses: mxschmitt/action-tmate@v3
4860

build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env sh
22

33
set -euxo pipefail
44

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88
- Added support for NetBSD 10.0
9+
- Added support for NetBSD ARM64
910

1011
## [0.2.0] - 2023-05-28
1112
### Added

netbsd.pkr.hcl

+41-13
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@ variable "hostname_step" {
114114
description = "Step to set hostname"
115115
}
116116

117+
variable "keyboard_layout_steps" {
118+
type = list(list(string))
119+
description = "Step to select keyboard layout"
120+
}
121+
122+
variable "correct_geometry_steps" {
123+
type = list(list(string))
124+
description = "Step to say the geometry is correct"
125+
}
126+
127+
variable "bootblock_selection_steps" {
128+
type = list(list(string))
129+
description = "Step to select bootblock"
130+
}
131+
132+
variable "post_install_disk_device" {
133+
type = string
134+
description = "The disk device to mount during post install"
135+
}
136+
117137
locals {
118138
iso_target_extension = "iso"
119139
iso_target_path = "packer_cache"
@@ -139,27 +159,37 @@ source "qemu" "qemu" {
139159
display = var.display
140160
accelerator = var.accelerator
141161
qemu_binary = "qemu-system-${var.architecture.qemu}"
142-
// firmware = var.firmware
162+
firmware = var.firmware
143163

144164
boot_wait = "10s"
145165

146166
boot_steps = concat(
147167
[
148-
["a<enter><wait5>", "Installation messages in English"],
149-
["a<enter><wait5>", "Keyboard type: unchanged"],
168+
["1<wait20s>", "Boot normally"], // for x86-64, the boot delay is already over
169+
["a<enter><wait5>", "Installation messages in English"]
170+
],
171+
172+
var.keyboard_layout_steps,
150173

174+
[
151175
["a<enter><wait5>", "Install NetBSD to hard disk"],
152176
["b<enter><wait5>", "Yes"],
153177

154178
["a<enter><wait5>", "Available disks: sd0"],
155179
["a<enter><wait5>", "Guid Partition Table"],
156-
["a<enter><wait5>", "This is the correct geometry"],
180+
],
181+
182+
var.correct_geometry_steps,
183+
184+
[
157185
["b<enter><wait5>", "Use default partition sizes"],
158186
["x<enter><wait5>", "Partition sizes ok"],
159187
["b<enter><wait10>", "Yes"],
188+
],
160189

161-
["a<enter><wait>", "Bootblocks selection: Use BIOS console"],
190+
var.bootblock_selection_steps,
162191

192+
[
163193
["d<enter><wait>", "Custom installation"],
164194
// Distribution set:
165195
["f<enter><wait5>", "Compiler tools"],
@@ -170,7 +200,7 @@ source "qemu" "qemu" {
170200
// Distribution set:
171201
["x<enter><wait5>", "Install selected sets"],
172202

173-
["a<enter><wait4m>", "Install from: install image media"],
203+
["a<enter><wait5m>", "Install from: install image media"],
174204

175205
["<enter><wait5>", "Hit enter to continue"],
176206

@@ -181,7 +211,6 @@ source "qemu" "qemu" {
181211

182212
[
183213
// Change root password
184-
flatten(var.root_password_pre_steps),
185214
["${var.root_password}<enter><wait5>", "New password"],
186215
["${var.root_password}<enter><wait5>", "New password"],
187216
["${var.root_password}<enter><wait5>", "Retype new password"],
@@ -217,10 +246,10 @@ source "qemu" "qemu" {
217246
["a<enter><wait5>", "Are they OK, Yes"],
218247
["a<enter><wait5>", "Is the network information correct, Yes"],
219248

220-
// Enable installation of binary packages
221-
/*["e<enter><wait5>"],
222-
["x<enter><wait2m>", "Install pkgin and update package summary"],
223-
["<enter><wait5>", "Hit enter to continue"],*/
249+
// // Enable installation of binary packages
250+
// ["e<enter><wait5>"],
251+
// ["x<enter><wait2m>", "Install pkgin and update package summary"],
252+
// ["<enter><wait5>", "Hit enter to continue"],
224253

225254
["x<enter><wait5>", "Finished configuring"],
226255
["<enter><wait5>", "Hit enter to continue"],
@@ -231,7 +260,7 @@ source "qemu" "qemu" {
231260

232261
// shell
233262
["ftp -o /tmp/post_install.sh http://{{.HTTPIP}}:{{.HTTPPort}}/resources/post_install.sh<enter><wait10>"],
234-
["sh /tmp/post_install.sh && exit<enter><wait5>"],
263+
["DISK_DEVICE='${var.post_install_disk_device}' sh /tmp/post_install.sh && exit<enter><wait5>"],
235264

236265
["x<enter><wait5>", "Exit Utility menu"],
237266
["d<enter>", "Reboot the computer"],
@@ -251,7 +280,6 @@ source "qemu" "qemu" {
251280
["-device", "scsi-cd,drive=drive1,bootindex=1"],
252281
["-drive", "if=none,file={{ .OutputDir }}/{{ .Name }},id=drive0,cache=writeback,discard=ignore,format=qcow2"],
253282
["-drive", "if=none,file=${local.iso_full_target_path},id=drive1,media=disk,format=raw,readonly=on"],
254-
["-serial", "stdio"],
255283
["-netdev", "user,id=user.0,hostfwd=tcp::{{ .SSHHostPort }}-:22,ipv6=off"]
256284
]
257285

resources/post_install.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -eux
44
set -o pipefail
55

66
configure_ssh() {
7-
tee -a /mnt/etc/ssh/sshd_config <<EOF
7+
cat <<EOF >> /mnt/etc/ssh/sshd_config
88
PermitRootLogin yes
99
PasswordAuthentication yes
1010
PubkeyAuthentication yes
@@ -14,5 +14,5 @@ EOF
1414
}
1515

1616
dkctl sd0 makewedges
17-
mount /dev/dk0 /mnt
17+
mount "$DISK_DEVICE" /mnt
1818
configure_ssh

resources/provision.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ EOF
2222
}
2323

2424
configure_boot_flags() {
25-
sed -i -E 's/timeout=.+/timeout=0/' /boot.cfg
25+
if [ -f /boot.cfg ]; then
26+
sed -i -E 's/timeout=.+/timeout=0/' /boot.cfg
27+
else
28+
echo 'timeout=0' > /boot.cfg
29+
fi
2630
}
2731

2832
configure_boot_scripts() {

var_files/10.0/arm64.pkrvars.hcl

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
checksum = "sha512:36d223c9c0e433b2306e8b28cdfb6ce178c3b3bf8fe4b7f58a8a2e817f1197ffb35a0679e8eaec32995b07440f06c72efaf588732087372ceadfa75894c959a8"

var_files/10.0/common.pkrvars.hcl

+3-24
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
11
generate_entropy_steps = [
2-
["c<enter><wait>", "Load raw binary random data"],
3-
["a<enter>", "Download via HTTP"],
4-
5-
// Available interfaces
6-
["a<enter>", "vioif0"],
7-
8-
["<enter><wait>", "Network media type"],
9-
["a<enter><wait20s>", "Perform autoconfiguration"],
10-
11-
["<enter><wait>", "Your host name"],
12-
["<enter><wait>", "Your DNS domain"],
13-
14-
// The following are the values you entered - Are they OK?
15-
["a<enter><wait>", "Yes"],
16-
17-
//
18-
["a<enter><wait>", "Host"],
19-
["random-data-api.com<enter><wait>", "Host"],
20-
21-
["b<enter><wait>", "Path and filename"],
22-
["<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>api/v2/beers<enter><wait>", "Path and filename"],
23-
24-
["x<enter><wait10s>", "Start download"]
2+
["a<enter><wait>", "Manually input random characters"],
3+
["{{uuid}}{{uuid}}{{uuid}}{{uuid}}<enter><wait10>", "Enter one line of random characters"]
254
]
265

276
hostname_step = [
28-
["<enter><wait>", "Your host name"],
7+
["<enter><wait>", "Your host name"]
298
]

var_files/arm64.pkrvars.hcl

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
machine_type = "virt"
22
cpu_type = "cortex-a57"
3-
firmware = "resources/qemu_efi.fd"
3+
firmware = "edk2-aarch64-code.fd"
4+
post_install_disk_device = "/dev/dk1"
45

56
architecture = {
67
name = "arm64"
78
image = "evbarm-aarch64"
89
qemu = "aarch64"
910
}
11+
12+
keyboard_layout_steps = []
13+
correct_geometry_steps = []
14+
bootblock_selection_steps = []

var_files/x86-64.pkrvars.hcl

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
firmware = "resources/ovmf.fd"
1+
firmware = "bios-256k.bin"
2+
post_install_disk_device = "/dev/dk0"
23

34
architecture = {
45
name = "x86-64"
56
image = "amd64"
67
qemu = "x86_64"
78
}
9+
10+
keyboard_layout_steps = [
11+
["a<enter><wait5>", "Keyboard type: unchanged"]
12+
]
13+
14+
correct_geometry_steps = [
15+
["a<enter><wait5>", "This is the correct geometry"]
16+
]
17+
18+
bootblock_selection_steps = [
19+
["a<enter><wait>", "Bootblocks selection: Use BIOS console"]
20+
]

0 commit comments

Comments
 (0)