Skip to content

Commit

Permalink
resources: add build option to build riscv 24.04 image. (#41)
Browse files Browse the repository at this point in the history
- This change also removes http directory as we are not using it.
  • Loading branch information
Harshil2107 authored Jul 18, 2024
1 parent 4d0c757 commit 44d407b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
22 changes: 19 additions & 3 deletions src/riscv-ubuntu-22.04/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,28 @@ if [ ! -f ./packer ]; then
rm packer_${PACKER_VERSION}_linux_amd64.zip;
fi

# Check if the Ubuntu version variable is provided
if [ -z "$1" ]; then
echo "Usage: $0 <ubuntu_version>"
echo "Example: $0 22.04 or $0 24.04"
exit 1
fi

ubuntu_version="$1"

if [[ "$ubuntu_version" == "22.04" ]]; then
wget https://old-releases.ubuntu.com/releases/jammy/ubuntu-22.04.3-preinstalled-server-riscv64+unmatched.img.xz
unxz ubuntu-22.04.3-preinstalled-server-riscv64+unmatched.img.xz
fi

if [[ "$ubuntu_version" == "24.04" ]]; then
wget https://cdimage.ubuntu.com/releases/noble/release/ubuntu-24.04-preinstalled-server-riscv64.img.xz
unxz ubuntu-24.04-preinstalled-server-riscv64.img.xz
fi

wget https://old-releases.ubuntu.com/releases/jammy/ubuntu-22.04.3-preinstalled-server-riscv64+unmatched.img.xz
unxz ubuntu-22.04.3-preinstalled-server-riscv64+unmatched.img.xz

# Install the needed plugins
./packer init riscv-ubuntu.pkr.hcl

# Build the image
./packer build riscv-ubuntu.pkr.hcl
./packer build -var "ubuntu_version=${ubuntu_version}" riscv-ubuntu.pkr.hcl
31 changes: 27 additions & 4 deletions src/riscv-ubuntu-22.04/riscv-ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,36 @@ variable "ssh_username" {
default = "gem5"
}

variable "ubuntu_version" {
type = string
default = "22.04"
validation {
condition = contains(["22.04", "24.04"], var.ubuntu_version)
error_message = "Ubuntu version must be either 22.04 or 24.04."
}
}

locals {
iso_data = {
"22.04" = {
iso_url = "./ubuntu-22.04.3-preinstalled-server-riscv64+unmatched.img"
iso_checksum = "sha256:b6fc820db60fb7b55dfff62afd70b4d65ca9aa5b61fc4cf16314cce36934baf5"
output_dir = "disk-image"
}
"24.04" = {
iso_url = "./ubuntu-24.04-preinstalled-server-riscv64.img"
iso_checksum = "sha256:9f1010bfff3d3b2ed3b174f121c5b5002f76ae710a6647ebebbc1f7eb02e63f5"
output_dir = "disk-image-24.04"
}
}
}

source "qemu" "initialize" {
cpus = "4"
disk_size = "5000"
format = "raw"
headless = "true"
disk_image = "true"
http_directory = "http"
boot_command = [
"<wait120>",
"ubuntu<enter><wait>",
Expand All @@ -43,10 +66,10 @@ source "qemu" "initialize" {
"<enter><enter><enter><enter><enter>y<enter><wait>",
"sudo usermod -aG sudo gem5<enter><wait>"
]
iso_checksum = "sha256:32bb0ec61ed38998100ee25934b5c37da345708a09e1dd0d99c0a8a2da0739de"
iso_urls = ["./ubuntu-22.04.3-preinstalled-server-riscv64+unmatched.img"]
iso_checksum = local.iso_data[var.ubuntu_version].iso_checksum
iso_urls = [local.iso_data[var.ubuntu_version].iso_url]
memory = "8192"
output_directory = "disk-image"
output_directory = local.iso_data[var.ubuntu_version].output_dir
qemu_binary = "/usr/bin/qemu-system-riscv64"

qemuargs = [ ["-bios", "/usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf"],
Expand Down

0 comments on commit 44d407b

Please sign in to comment.