diff --git a/ubuntu/README.md b/ubuntu/README.md index 9eabdfb..416e715 100644 --- a/ubuntu/README.md +++ b/ubuntu/README.md @@ -81,8 +81,8 @@ kernel on deploy. ### Building different architectures -By default, images are produces for amd64. You can build for arm64 as well if -you specify the `architecture` parameter: +By default, images are produces for amd64. You can build for arm64 or riscv64 +as well if you specify the `architecture` parameter: ```shell packer init . @@ -149,7 +149,8 @@ Specify the Ubuntu Series to build. The default value is set to Jammy. #### ARCH -Target image architecture. Supported values are amd64 (default) and arm64. +Target image architecture. Supported values are amd64 (default), arm64, and +riscv64. #### URL diff --git a/ubuntu/ubuntu-cloudimg.pkr.hcl b/ubuntu/ubuntu-cloudimg.pkr.hcl index ba5ba7d..d5f559b 100644 --- a/ubuntu/ubuntu-cloudimg.pkr.hcl +++ b/ubuntu/ubuntu-cloudimg.pkr.hcl @@ -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 = [ @@ -46,10 +55,12 @@ 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${var.ovmf_suffix}.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${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"] + ["-drive", "file=output-cloudimg/packer-cloudimg,format=qcow2,if=none,id=disk1"], + ["-device", "virtio-blk-pci,drive=disk1,bootindex=1"], + ["-drive", "file=seeds-cloudimg.iso,format=raw,if=none,id=disk2"], + ["-device", "virtio-blk-pci,drive=disk2"] ] shutdown_command = "sudo -S shutdown -P now" ssh_handshake_attempts = 500 @@ -66,7 +77,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" diff --git a/ubuntu/ubuntu-cloudimg.variables.pkr.hcl b/ubuntu/ubuntu-cloudimg.variables.pkr.hcl index 5033221..98f10db 100644 --- a/ubuntu/ubuntu-cloudimg.variables.pkr.hcl +++ b/ubuntu/ubuntu-cloudimg.variables.pkr.hcl @@ -25,7 +25,7 @@ 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)" } variable "ovmf_suffix" {