From 3dec306b15f4531ce35dca8b3c7c714865264385 Mon Sep 17 00:00:00 2001 From: ONE user Date: Mon, 16 Dec 2024 11:12:07 +0000 Subject: [PATCH] F #158: Introduce aarch64 images --- Makefile.config | 4 ++-- packer/alma/alma.pkr.hcl | 7 ++++++- packer/alma/variables.pkr.hcl | 10 ++++++++++ packer/build.sh | 8 ++++++++ packer/debian/debian.pkr.hcl | 6 +++++- packer/debian/variables.pkr.hcl | 11 +++++++++++ 6 files changed, 42 insertions(+), 4 deletions(-) diff --git a/Makefile.config b/Makefile.config index 83642c7b..e9186b57 100644 --- a/Makefile.config +++ b/Makefile.config @@ -7,11 +7,11 @@ VERBOSE := 1 PACKER_LOG := 0 PACKER_HEADLESS := true -DISTROS := alma8 alma9 \ +DISTROS := alma8 alma8.aarch64 alma9 alma9.aarch64 \ alpine316 alpine317 alpine318 alpine319 alpine320 \ alt10 \ amazon2 amazon2023 \ - debian11 debian12 \ + debian11 debian11.aarch64 debian12 debian12.aarch64 \ devuan4 devuan5 \ fedora38 fedora39 fedora40 \ freebsd13 freebsd14 \ diff --git a/packer/alma/alma.pkr.hcl b/packer/alma/alma.pkr.hcl index 96ea44c3..b5790ae6 100644 --- a/packer/alma/alma.pkr.hcl +++ b/packer/alma/alma.pkr.hcl @@ -14,12 +14,18 @@ build { # Build VM image source "qemu" "alma" { cpus = 2 + cpu_model = "host" memory = 2048 accelerator = "kvm" iso_url = lookup(lookup(var.alma, var.version, {}), "iso_url", "") iso_checksum = lookup(lookup(var.alma, var.version, {}), "iso_checksum", "") + firmware = lookup(lookup(var.arch_vars, var.arch, {}), "firmware", "") + use_pflash = lookup(lookup(var.arch_vars, var.arch, {}), "use_pflash", "") + machine_type = lookup(lookup(var.arch_vars, var.arch, {}), "machine_type", "") + qemu_binary = lookup(lookup(var.arch_vars, var.arch, {}), "qemu_binary", "") + headless = var.headless disk_image = true @@ -33,7 +39,6 @@ source "qemu" "alma" { output_directory = var.output_dir qemuargs = [ - ["-cpu", "host"], ["-cdrom", "${var.input_dir}/${var.appliance_name}-cloud-init.iso"], ["-serial", "stdio"], ] diff --git a/packer/alma/variables.pkr.hcl b/packer/alma/variables.pkr.hcl index 0a7338a0..2395c05a 100644 --- a/packer/alma/variables.pkr.hcl +++ b/packer/alma/variables.pkr.hcl @@ -30,9 +30,19 @@ variable "alma" { iso_checksum = "file:https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/CHECKSUM" } + "8.aarch64" = { + iso_url = "https://repo.almalinux.org/almalinux/8/cloud/aarch64/images/AlmaLinux-8-GenericCloud-latest.aarch64.qcow2" + iso_checksum = "file:https://repo.almalinux.org/almalinux/8/cloud/aarch64/images/CHECKSUM" + } + "9" = { iso_url = "https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2" iso_checksum = "file:https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/CHECKSUM" } + + "9.aarch64" = { + iso_url = "https://repo.almalinux.org/almalinux/9/cloud/aarch64/images/AlmaLinux-9-GenericCloud-latest.aarch64.qcow2" + iso_checksum = "file:https://repo.almalinux.org/almalinux/9/cloud/aarch64/images/CHECKSUM" + } } } diff --git a/packer/build.sh b/packer/build.sh index d7a6ae97..396e85d2 100755 --- a/packer/build.sh +++ b/packer/build.sh @@ -7,6 +7,12 @@ INPUT_DIR="$(dirname "$0")/$DISTRO_NAME" # e.g. packer/debian OUTPUT_DIR="$DIR_BUILD/$DISTRO" # e.g. build/debian11 (working dir) mkdir -p "$OUTPUT_DIR" +# detect architecture using `arch` +ARCH='x86_64' +if type arch 2>&1 >/dev/null; then + ARCH=$(arch) +fi + packer init "$INPUT_DIR" packer build -force \ @@ -15,6 +21,8 @@ packer build -force \ -var "input_dir=${INPUT_DIR}" \ -var "output_dir=${OUTPUT_DIR}" \ -var "headless=${PACKER_HEADLESS}" \ + -var "arch=${ARCH}" \ + -var "arch=${ARCH}" \ "$INPUT_DIR" # loads all *.pkr.hcl from dir # delete potential temporary cloud-init files diff --git a/packer/debian/debian.pkr.hcl b/packer/debian/debian.pkr.hcl index 978d5914..b5b1e418 100644 --- a/packer/debian/debian.pkr.hcl +++ b/packer/debian/debian.pkr.hcl @@ -20,6 +20,11 @@ source "qemu" "debian" { iso_url = lookup(lookup(var.debian, var.version, {}), "iso_url", "") iso_checksum = lookup(lookup(var.debian, var.version, {}), "iso_checksum", "") + firmware = lookup(lookup(var.arch_vars, var.arch, {}), "firmware", "") + use_pflash = lookup(lookup(var.arch_vars, var.arch, {}), "use_pflash", "") + machine_type = lookup(lookup(var.arch_vars, var.arch, {}), "machine_type", "") + qemu_binary = lookup(lookup(var.arch_vars, var.arch, {}), "qemu_binary", "") + headless = var.headless disk_image = true @@ -33,7 +38,6 @@ source "qemu" "debian" { output_directory = var.output_dir qemuargs = [ - ["-cpu", "host"], ["-cdrom", "${var.input_dir}/${var.appliance_name}-cloud-init.iso"], ["-serial", "stdio"], ] diff --git a/packer/debian/variables.pkr.hcl b/packer/debian/variables.pkr.hcl index bcdaf4de..28474265 100644 --- a/packer/debian/variables.pkr.hcl +++ b/packer/debian/variables.pkr.hcl @@ -29,9 +29,20 @@ variable "debian" { iso_url = "https://cdimage.debian.org/cdimage/cloud/bullseye/latest/debian-11-generic-amd64.qcow2" iso_checksum = "file:https://cdimage.debian.org/cdimage/cloud/bullseye/latest/SHA512SUMS" } + + "11.aarch64" = { + iso_url = "https://cdimage.debian.org/cdimage/cloud/bullseye/latest/debian-11-generic-arm64.qcow2" + iso_checksum = "file:https://cdimage.debian.org/cdimage/cloud/bullseye/latest/SHA512SUMS" + } + "12" = { iso_url = "https://cdimage.debian.org/cdimage/cloud/bookworm/latest/debian-12-generic-amd64.qcow2" iso_checksum = "file:https://cdimage.debian.org/cdimage/cloud/bookworm/latest/SHA512SUMS" } + + "12.aarch64" = { + iso_url = "https://cdimage.debian.org/cdimage/cloud/bookworm/latest/debian-12-generic-arm64.qcow2" + iso_checksum = "file:https://cdimage.debian.org/cdimage/cloud/bookworm/latest/SHA512SUMS" + } } }