From e42b0f1234f6ffa89a18d87aae0762ccbb6ef249 Mon Sep 17 00:00:00 2001 From: Hector Cao Date: Tue, 26 Nov 2024 14:30:11 +0000 Subject: [PATCH] fix missing ovmf file for debian image generation on ubuntu noble onwards, _4M ovmf image is now the default one and the OVMF_CODE.fd has been removed. --- debian/Makefile | 7 +++++++ debian/debian-cloudimg.pkr.hcl | 4 ++-- debian/debian-cloudimg.variables.pkr.hcl | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/debian/Makefile b/debian/Makefile index 89bd345f..4c03d362 100644 --- a/debian/Makefile +++ b/debian/Makefile @@ -26,6 +26,12 @@ ifeq ($(strip $(ARCH)),arm64) boot = uefi endif +ifeq ($(wildcard /usr/share/OVMF/OVMF_CODE.fd),) + OVMF_SFX ?= _4M +else + OVMF_SFX ?= +endif + .PHONY: all clean all: debian @@ -47,6 +53,7 @@ debian: check-deps clean -var debian_series=${SERIES} \ -var debian_version=${VERSION} \ -var architecture=${ARCH} \ + -var ovmf_suffix=${OVMF_SFX} \ -var boot_mode=${BOOT} \ -var timeout=${TIMEOUT} . diff --git a/debian/debian-cloudimg.pkr.hcl b/debian/debian-cloudimg.pkr.hcl index 9c9c8bd6..5902e131 100644 --- a/debian/debian-cloudimg.pkr.hcl +++ b/debian/debian-cloudimg.pkr.hcl @@ -46,7 +46,7 @@ source "qemu" "cloudimg" { ["-machine", "${lookup(local.qemu_machine, var.architecture, "")}"], ["-cpu", "${lookup(local.qemu_cpu, var.architecture, "")}"], ["-device", "virtio-gpu-pci"], - ["-drive", "if=pflash,format=raw,id=ovmf_code,readonly=on,file=/usr/share/${lookup(local.uefi_imp, var.architecture, "")}/${lookup(local.uefi_imp, var.architecture, "")}_CODE.fd"], + ["-drive", "if=pflash,format=raw,id=ovmf_code,readonly=on,file=/usr/share/${lookup(local.uefi_imp, var.architecture, "")}/${lookup(local.uefi_imp, var.architecture, "")}_CODE${var.ovmf_suffix}.fd"], ["-drive", "if=pflash,format=raw,id=ovmf_vars,file=${lookup(local.uefi_imp, var.architecture, "")}_VARS.fd"], ["-drive", "file=output-cloudimg/packer-cloudimg,format=qcow2"], ["-drive", "file=seeds-cloudimg.iso,format=raw"] @@ -66,7 +66,7 @@ build { provisioner "shell-local" { inline = [ - "cp /usr/share/${lookup(local.uefi_imp, var.architecture, "")}/${lookup(local.uefi_imp, var.architecture, "")}_VARS.fd ${lookup(local.uefi_imp, var.architecture, "")}_VARS.fd", + "cp /usr/share/${lookup(local.uefi_imp, var.architecture, "")}/${lookup(local.uefi_imp, var.architecture, "")}_VARS${var.ovmf_suffix}.fd ${lookup(local.uefi_imp, var.architecture, "")}_VARS.fd", "cloud-localds seeds-cloudimg.iso user-data-cloudimg meta-data" ] inline_shebang = "/bin/bash -e" diff --git a/debian/debian-cloudimg.variables.pkr.hcl b/debian/debian-cloudimg.variables.pkr.hcl index 4f5a79fd..80cf0341 100644 --- a/debian/debian-cloudimg.variables.pkr.hcl +++ b/debian/debian-cloudimg.variables.pkr.hcl @@ -39,3 +39,9 @@ variable "architecture" { default = "amd64" description = "The architecture to build the image for (amd64 or arm64)" } + +variable "ovmf_suffix" { + type = string + default = "" + description = "Suffix for OVMF CODE and VARS files. Newer systems such as Noble use _4M." +}