Move source to packer, add board spec.

This commit is contained in:
Kyle Isom 2023-04-12 05:15:34 +00:00
parent fa9f06cb9a
commit 262f82aa64
12 changed files with 72 additions and 17 deletions

View File

@ -1,18 +1,18 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "ubuntu-board-gen_lib",
srcs = ["main.go"],
importpath = "git.wntrmute.dev/kyle/bladerunner/src/cmd/ubuntu-board-gen",
name = "packer_lib",
srcs = ["ubuntu-board-gen.go"],
importpath = "git.wntrmute.dev/kyle/bladerunner/packer",
visibility = ["//visibility:private"],
deps = [
"//src/packer",
"//packer/packerlib",
"@ht_sr_git_kisom_goutils//die",
],
)
go_binary(
name = "ubuntu-board-gen",
embed = [":ubuntu-board-gen_lib"],
embed = [":packer_lib"],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,54 @@
{
"variables": {},
"builders": [
{
"type": "arm",
"file_urls": [
"build/ubuntu-22.04.2-preinstalled-server-arm64+raspi.img.xz",
"https://cdimage.ubuntu.com/releases/22.04.2/release/ubuntu-22.04.2-preinstalled-server-arm64+raspi.img.xz"
],
"file_checksum_url": "http://cdimage.ubuntu.com/releases/22.04.2/release/SHA256SUMS",
"file_checksum_type": "sha256",
"file_target_extension": "xz",
"file_unarchive_cmd": [
"xz",
"--decompress",
"$ARCHIVE_PATH"
],
"image_build_method": "reuse",
"image_path": "build/cm4-cluster-ubuntu-22.04.2.img",
"image_size": "32G",
"image_type": "dos",
"image_partitions": [
{
"name": "boot",
"type": "c",
"start_sector": 2048,
"size": "256M",
"mountpoint": "/boot/firmware"
},
{
"name": "root",
"type": "83",
"start_sector": 526336,
"size": "31.7G",
"mountpoint": "/"
}
],
"image_chroot_env": [
"PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
],
"qemu_binary_source_path": "/usr/bin/qemu-aarch64-static",
"qemu_binary_destination_path": "/usr/bin/qemu-aarch64-static"
}
],
"provisioners": [
{
"scripts": [
"scripts/install-base.sh"
],
"type": "shell"
}
],
"post-processors": null
}

View File

@ -11,7 +11,7 @@ errmsg () {
preflight () {
case "${IMAGE_TYPE}" in
ubuntu) PACKER_BUILD_FILE="boards/pi-cm4-ubuntu-22.04.2.json" ;;
ubuntu) PACKER_BUILD_FILE="boards/cm4-cluster-ubuntu-22.04.2.json" ;;
raspbian) PACKER_BUILD_FILE="boards/raspberry-pi/raspios-lite-arm.json" ;;
custom)
if [ -z "${PACKER_BUILD_FILE}" ]

View File

@ -1,7 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "packer",
name = "packerlib",
srcs = [
"board.go",
"builder.go",
@ -9,7 +9,7 @@ go_library(
"provisioner.go",
"ubuntu.go",
],
importpath = "git.wntrmute.dev/kyle/bladerunner/src/packer",
importpath = "git.wntrmute.dev/kyle/bladerunner/packer/packerlib",
visibility = ["//visibility:public"],
deps = ["@in_gopkg_yaml_v2//:yaml_v2"],
)

View File

@ -1,4 +1,4 @@
package packer
package packerlib
type Board struct {
Variables map[string]string `json:"variables"`

View File

@ -1,4 +1,4 @@
package packer
package packerlib
// RootPartitionSizes describes how big a single root partition should
// be given a standard 256M boot partition. This should cover standard

View File

@ -0,0 +1,3 @@
// Package packerlib contains utilities for interacting with Packer
// in the context of building images for the computeblade cluster.
package packerlib

View File

@ -1,4 +1,4 @@
package packer
package packerlib
type Provisioner map[string]interface{}

View File

@ -1,4 +1,4 @@
package packer
package packerlib
import (
"bytes"
@ -96,7 +96,7 @@ func (spec UbuntuBoardSpec) Board() Board {
}
func LoadUbuntuSpecs(path string) (specFile UbuntuBoardSpecFile, err error) {
log.Println("loading from", specFile)
log.Println("loading from", path)
data, err := ioutil.ReadFile(path)
if err != nil {
return

View File

@ -3,6 +3,7 @@
set -euxo pipefail
echo "==> Setting nameserver"
rm /etc/resolv.conf
echo 'nameserver 8.8.8.8' > /etc/resolv.conf
echo "==> installing base updates"

View File

@ -4,7 +4,7 @@ import (
"flag"
"git.sr.ht/~kisom/goutils/die"
"git.wntrmute.dev/kyle/bladerunner/src/packer"
packer "git.wntrmute.dev/kyle/bladerunner/packer/packerlib"
)
func main() {

View File

@ -1,3 +0,0 @@
// Package packer contains utilities for interacting with Packer
// in the context of building images for the computeblade cluster.
package packer