Skip to content

Commit

Permalink
try snapshot building
Browse files Browse the repository at this point in the history
Signed-off-by: Aisha Tammy <[email protected]>
  • Loading branch information
epsilon-0 committed Sep 19, 2022
1 parent 962d3ed commit 2b6d11c
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 3 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,44 @@ jobs:
fail-fast: false
matrix:
version:
- snapshots
- 6.8
- 6.9
- 7.1


architecture:
- x86-64
- arm64

if: ${{ github.event_name != 'schedule' || matrix.version == 'snapshots' }}
steps:
- name: Clone Repository
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Install Dependecies
run: apt update && apt install curl unzip "qemu-system-$QEMU_ARCHITECTURE" -y
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
}}

- name: Find snapshot variables
if: ${{ matrix.version == 'snapshots' }}
run: |
bash create_vars.sh ${OBSD_ARCH} ${LOCAL_ARCH}
echo "SNAP_SUM=$(cat checksum)" >> ${GITHUB_ENV}
env:
OBSD_ARCH: ${{
matrix.architecture == 'x86-64' && 'amd64' ||
matrix.architecture == 'arm64' && 'arm64' ||
matrix.architecture
}}
LOCAL_ARCH: ${{ matrix.architecture }}

- name: Install Packer
run: |
curl -o packer.zip -L https://releases.hashicorp.com/packer/1.7.1/packer_1.7.1_linux_amd64.zip
Expand Down
15 changes: 15 additions & 0 deletions create_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -xeuo pipefail

OBSD_ARCH="${1:-amd64}"
LOCAL_ARCH="${2:-x86-64}"

snap_line="$(curl https://cdn.openbsd.org/pub/OpenBSD/snapshots/${OBSD_ARCH}/SHA256.sig 2>/dev/null | grep miniroot)"
snap_sum="$(echo $snap_line | awk '{ print $NF; }')"
snap_num="$(echo $snap_line | grep -Po 'miniroot\K(\d{2})')"

echo "${snap_sum}" > checksum

echo "checksum = \"sha256:${snap_sum}\"" > "var_files/snapshots/${LOCAL_ARCH}.pkrvars.hcl"
echo "os_number = \"${snap_num}\"" >> "var_files/snapshots/${LOCAL_ARCH}.pkrvars.hcl"
7 changes: 6 additions & 1 deletion openbsd.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ variable "os_version" {
description = "The version of the operating system to download and install"
}

variable "os_number" {
type = string
description = "The version suffix for minirootXX.img from upstream"
}

variable "architecture" {
default = "x86-64"
type = string
Expand Down Expand Up @@ -118,7 +123,7 @@ variable "rsync_version" {

locals {
image_architecture = var.architecture == "x86-64" ? "amd64" : var.architecture
image = "miniroot${replace(var.os_version, ".", "")}.img"
image = "miniroot${var.os_number}.img"
vm_name = "openbsd-${var.os_version}-${var.architecture}.qcow2"

iso_target_extension = "img"
Expand Down
1 change: 1 addition & 0 deletions var_files/6.8/common.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
os_version = "6.8"
os_number = "68"
sudo_version = "1.9.5.2p0"
rsync_version = "3.2.3"
1 change: 1 addition & 0 deletions var_files/6.9/common.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
os_version = "6.9"
os_number = "69"
sudo_version = "1.9.6.1"
rsync_version = "3.2.3p0"
1 change: 1 addition & 0 deletions var_files/7.1/common.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
os_version = "7.1"
os_number = "71"
sudo_version = "1.9.10"
rsync_version = "3.2.3p1"
1 change: 1 addition & 0 deletions var_files/snapshots/arm64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checksum = "sha256:XXXX"
3 changes: 3 additions & 0 deletions var_files/snapshots/common.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
os_version = "snapshots"
sudo_version = "1.9.11.2"
rsync_version = "3.2.5pl0"
1 change: 1 addition & 0 deletions var_files/snapshots/x86-64.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checksum = "sha256:XXX"

0 comments on commit 2b6d11c

Please sign in to comment.