Skip to content

Commit

Permalink
- add riscv64 architecture to ubuntu-cloudimg
Browse files Browse the repository at this point in the history
Signed-off-by: Heinrich Schuchardt <[email protected]>
  • Loading branch information
xypron committed Mar 20, 2024
1 parent 8a9ad20 commit c3b1bb9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions ubuntu/ubuntu-cloudimg.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@ locals {
qemu_arch = {
"amd64" = "x86_64"
"arm64" = "aarch64"
"riscv64" = "riscv64"
}
uefi_dir = {
"amd64" = "OVMF"
"arm64" = "AAVMF"
"riscv64" = "qemu-efi-riscv64"
}
uefi_imp = {
"amd64" = "OVMF"
"arm64" = "AAVMF"
"riscv64" = "RISCV_VIRT"
}
qemu_machine = {
"amd64" = "ubuntu,accel=kvm"
"arm64" = "virt"
"riscv64" = "virt,acpi=off"
}
qemu_cpu = {
"amd64" = "host"
"arm64" = "cortex-a57"
"riscv64" = "rv64"
}

proxy_env = [
Expand Down Expand Up @@ -46,7 +55,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_dir, var.architecture, "")}/${lookup(local.uefi_imp, var.architecture, "")}_CODE.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"]
Expand All @@ -66,7 +75,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_dir, var.architecture, "")}/${lookup(local.uefi_imp, var.architecture, "")}_VARS.fd ${lookup(local.uefi_imp, var.architecture, "")}_VARS.fd",
"cloud-localds seeds-cloudimg.iso user-data-cloudimg meta-data"
]
inline_shebang = "/bin/bash -e"
Expand Down
2 changes: 1 addition & 1 deletion ubuntu/ubuntu-cloudimg.variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ variable "customize_script" {
variable "architecture" {
type = string
default = "amd64"
description = "The architecture to build the image for (amd64 or arm64)"
description = "The architecture to build the image for (amd64, arm64, or riscv64)"
}

0 comments on commit c3b1bb9

Please sign in to comment.