From 729dc7756b8ed1a1b305f0b7b6ab8a3aa92bd469 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 7 Mar 2024 06:30:51 +0100 Subject: [PATCH 1/3] - add riscv64 architecture to ubuntu-cloudimg Signed-off-by: Heinrich Schuchardt --- ubuntu/ubuntu-cloudimg.pkr.hcl | 13 +++++++++++-- ubuntu/ubuntu-cloudimg.variables.pkr.hcl | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ubuntu/ubuntu-cloudimg.pkr.hcl b/ubuntu/ubuntu-cloudimg.pkr.hcl index ba5ba7d..f37344e 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,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${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"] @@ -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" 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" { From 98fe6496c54221d4f7ece42150f0d0d40f4f8b5e Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 7 Mar 2024 08:02:50 +0100 Subject: [PATCH 2/3] - ubuntu: set bootindex=1 for packer-cloudimg Signed-off-by: Heinrich Schuchardt --- ubuntu/ubuntu-cloudimg.pkr.hcl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ubuntu/ubuntu-cloudimg.pkr.hcl b/ubuntu/ubuntu-cloudimg.pkr.hcl index f37344e..d5f559b 100644 --- a/ubuntu/ubuntu-cloudimg.pkr.hcl +++ b/ubuntu/ubuntu-cloudimg.pkr.hcl @@ -57,8 +57,10 @@ source "qemu" "cloudimg" { ["-device", "virtio-gpu-pci"], ["-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 From e31993403b5355b005ca868bdc40ae469964279f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 9 Mar 2024 08:30:12 +0100 Subject: [PATCH 3/3] ubuntu: mention riscv64 architecture in README.md Signed-off-by: Heinrich Schuchardt --- ubuntu/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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