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 Jan 16, 2024
1 parent 36f6e29 commit 1659236
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 50 deletions.
26 changes: 19 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ on:

jobs:
build:
name: Build
name: ${{ matrix.version }}, ${{ matrix.architecture.name }}
runs-on: ubuntu-latest
container: alpine:edge
strategy:
matrix:
version:
Expand All @@ -24,7 +25,21 @@ jobs:

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

- name: arm64
qemu: aarch64

exclude:
- version: 9.2
architecture:
name: arm64
qemu: aarch64

- version: 9.3
architecture:
name: arm64
qemu: aarch64

steps:
- name: Clone Repository
Expand All @@ -33,16 +48,13 @@ jobs:
persist-credentials: false

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

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

- name: Download QEMU UEFI
if: matrix.architecture.name == 'arm64'
run: curl -o resources/qemu_efi.fd -L https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd

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

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env sh

set -euxo pipefail

Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
- Added support for NetBSD 10.0
- Added support for NetBSD ARM64

## [0.2.0] - 2023-05-28
### Added
Expand Down
54 changes: 41 additions & 13 deletions netbsd.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ variable "hostname_step" {
description = "Step to set hostname"
}

variable "keyboard_layout_steps" {
type = list(list(string))
description = "Step to select keyboard layout"
}

variable "correct_geometry_steps" {
type = list(list(string))
description = "Step to say the geometry is correct"
}

variable "bootblock_selection_steps" {
type = list(list(string))
description = "Step to select bootblock"
}

variable "post_install_disk_device" {
type = string
description = "The disk device to mount during post install"
}

locals {
iso_target_extension = "iso"
iso_target_path = "packer_cache"
Expand All @@ -139,27 +159,37 @@ source "qemu" "qemu" {
display = var.display
accelerator = var.accelerator
qemu_binary = "qemu-system-${var.architecture.qemu}"
// firmware = var.firmware
firmware = var.firmware

boot_wait = "10s"

boot_steps = concat(
[
["a<enter><wait5>", "Installation messages in English"],
["a<enter><wait5>", "Keyboard type: unchanged"],
["1<wait20s>", "Boot normally"], // for x86-64, the boot delay is already over
["a<enter><wait5>", "Installation messages in English"]
],

var.keyboard_layout_steps,

[
["a<enter><wait5>", "Install NetBSD to hard disk"],
["b<enter><wait5>", "Yes"],

["a<enter><wait5>", "Available disks: sd0"],
["a<enter><wait5>", "Guid Partition Table"],
["a<enter><wait5>", "This is the correct geometry"],
],

var.correct_geometry_steps,

[
["b<enter><wait5>", "Use default partition sizes"],
["x<enter><wait5>", "Partition sizes ok"],
["b<enter><wait10>", "Yes"],
],

["a<enter><wait>", "Bootblocks selection: Use BIOS console"],
var.bootblock_selection_steps,

[
["d<enter><wait>", "Custom installation"],
// Distribution set:
["f<enter><wait5>", "Compiler tools"],
Expand All @@ -170,7 +200,7 @@ source "qemu" "qemu" {
// Distribution set:
["x<enter><wait5>", "Install selected sets"],

["a<enter><wait4m>", "Install from: install image media"],
["a<enter><wait5m>", "Install from: install image media"],

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

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

[
// Change root password
flatten(var.root_password_pre_steps),
["${var.root_password}<enter><wait5>", "New password"],
["${var.root_password}<enter><wait5>", "New password"],
["${var.root_password}<enter><wait5>", "Retype new password"],
Expand Down Expand Up @@ -217,10 +246,10 @@ source "qemu" "qemu" {
["a<enter><wait5>", "Are they OK, Yes"],
["a<enter><wait5>", "Is the network information correct, Yes"],

// Enable installation of binary packages
/*["e<enter><wait5>"],
["x<enter><wait2m>", "Install pkgin and update package summary"],
["<enter><wait5>", "Hit enter to continue"],*/
// // Enable installation of binary packages
// ["e<enter><wait5>"],
// ["x<enter><wait2m>", "Install pkgin and update package summary"],
// ["<enter><wait5>", "Hit enter to continue"],

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions resources/post_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eux
set -o pipefail

configure_ssh() {
tee -a /mnt/etc/ssh/sshd_config <<EOF
cat <<EOF >> /mnt/etc/ssh/sshd_config
PermitRootLogin yes
PasswordAuthentication yes
PubkeyAuthentication yes
Expand All @@ -14,5 +14,5 @@ EOF
}

dkctl sd0 makewedges
mount /dev/dk0 /mnt
mount "$DISK_DEVICE" /mnt
configure_ssh
6 changes: 5 additions & 1 deletion resources/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ EOF
}

configure_boot_flags() {
sed -i -E 's/timeout=.+/timeout=0/' /boot.cfg
if [ -f /boot.cfg ]; then
sed -i -E 's/timeout=.+/timeout=0/' /boot.cfg
else
echo 'timeout=0' > /boot.cfg
fi
}

configure_boot_scripts() {
Expand Down
1 change: 1 addition & 0 deletions var_files/10.0_RC2/arm64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checksum = "sha512:1d2f4ec01555c0e76b5b3183203353b48cfb0256962ed90376233135434cf5059622fcdf64a8360ee1bc81e478cd487456482593e1795419f74c79ca41f2cef1"
27 changes: 3 additions & 24 deletions var_files/10.0_RC2/common.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
generate_entropy_steps = [
["c<enter><wait>", "Load raw binary random data"],
["a<enter>", "Download via HTTP"],

// Available interfaces
["a<enter>", "vioif0"],

["<enter><wait>", "Network media type"],
["a<enter><wait20s>", "Perform autoconfiguration"],

["<enter><wait>", "Your host name"],
["<enter><wait>", "Your DNS domain"],

// The following are the values you entered - Are they OK?
["a<enter><wait>", "Yes"],

//
["a<enter><wait>", "Host"],
["random-data-api.com<enter><wait>", "Host"],

["b<enter><wait>", "Path and filename"],
["<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>api/v2/beers<enter><wait>", "Path and filename"],

["x<enter><wait10s>", "Start download"]
["a<enter><wait>", "Manually input random characters"],
["{{uuid}}{{uuid}}{{uuid}}{{uuid}}<enter><wait10>", "Enter one line of random characters"]
]

hostname_step = [
["<enter><wait>", "Your host name"],
["<enter><wait>", "Your host name"]
]
7 changes: 6 additions & 1 deletion var_files/arm64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
machine_type = "virt"
cpu_type = "cortex-a57"
firmware = "resources/qemu_efi.fd"
firmware = "edk2-aarch64-code.fd"
post_install_disk_device = "/dev/dk1"

architecture = {
name = "arm64"
image = "evbarm-aarch64"
qemu = "aarch64"
}

keyboard_layout_steps = []
correct_geometry_steps = []
bootblock_selection_steps = []
15 changes: 14 additions & 1 deletion var_files/x86-64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
firmware = "resources/ovmf.fd"
firmware = "bios-256k.bin"
post_install_disk_device = "/dev/dk0"

architecture = {
name = "x86-64"
image = "amd64"
qemu = "x86_64"
}

keyboard_layout_steps = [
["a<enter><wait5>", "Keyboard type: unchanged"]
]

correct_geometry_steps = [
["a<enter><wait5>", "This is the correct geometry"]
]

bootblock_selection_steps = [
["a<enter><wait>", "Bootblocks selection: Use BIOS console"]
]

0 comments on commit 1659236

Please sign in to comment.