From ae9bbd656a6085af12f26d411eef7d62c212bc7a Mon Sep 17 00:00:00 2001 From: Mike Ripley Date: Wed, 2 Jun 2021 17:42:38 -0400 Subject: [PATCH 1/9] Add support for AARCH64 builds via QEMU --- .github/workflows/lint.yml | 1 + packer/ubuntu-kvm.json | 90 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 packer/ubuntu-kvm.json diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 463d07e7..89c19d69 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -52,6 +52,7 @@ jobs: packer validate -var-file=mint-beta.pkrvars.hcl . || true # This runs last to ensure it's exit status is captured packer validate . + packer validate ubuntu-kvm.json working-directory: packer - name: Check Packer HCL formatting run: | diff --git a/packer/ubuntu-kvm.json b/packer/ubuntu-kvm.json new file mode 100644 index 00000000..ed0ac417 --- /dev/null +++ b/packer/ubuntu-kvm.json @@ -0,0 +1,90 @@ +{ + "min_packer_version": "1.6.0", + "variables": { + "vm_name": "JMU Ubuntu", + "semester": "Fa22", + + "build_id": "{{isotime \"2006-01-02\"}}", + + "git_repo": "https://github.com/jmunixusers/cs-vm-build", + "git_branch": "main", + + "headless": "false", + + "output_dir": "{{pwd}}/{{user `vm_name`}} {{user `semester`}}.utm/Images", + "mirror_url": "http://cdimage.ubuntu.com/jammy/daily-live/current", + "iso_file": "jammy-desktop-arm64.iso", + + "ssh_user": "oem", + "ssh_pass": "oem" + }, + "builders": [ + { + "type": "qemu", + "headless": "{{user `headless`}}", + "cpus": 2, + "accelerator": "kvm", + "memory": 4096, + "machine_type": "virt", + "qemu_binary": "qemu-system-aarch64", + "qemuargs": [ + [ "-bios", "/usr/share/qemu-efi-aarch64/QEMU_EFI.fd" ], + [ "-boot", "strict=off" ], + [ "-cpu", "host" ], + [ "-display", "gtk" ], + [ "-device", "virtio-rng-pci" ], + [ "-device", "virtio-gpu" ], + [ "-device", "nec-usb-xhci,id=xhci" ], + [ "-device", "usb-kbd,bus=xhci.0" ], + [ "-device", "usb-tablet,bus=xhci.0" ] + ], + "iso_url": "{{user `mirror_url`}}/{{user `iso_file`}}", + "iso_checksum": "file:{{user `mirror_url`}}/SHA256SUMS", + "output_directory": "{{user `output_dir`}}", + "shutdown_command": "echo -e \"{{user `ssh_pass`}}\\n\" | sudo -S poweroff", + "disk_cache": "unsafe", + "disk_compression": "true", + "disk_detect_zeroes": "unmap", + "disk_discard": "unmap", + "disk_size": "20G", + "format": "qcow2", + "qemu_img_args": { + "create": ["-o", "preallocation=falloc"], + "convert": ["-o", "compression_type=zstd"] + }, + "http_directory": "http", + "ssh_username": "{{user `ssh_user`}}", + "ssh_password": "{{user `ssh_pass`}}", + "ssh_timeout": "100m", + "vm_name": "image.qcow2", + "net_device": "virtio-net", + "disk_interface": "virtio", + "boot_wait": "45s", + "boot_command": [ + "c", + "linux /casper/vmlinuz", + " auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/oem-preseed.cfg", + " automatic-ubiquity only-ubiquity", + " debug-ubiquity oem-config/enable=true", + " keymap=us fsck.mode=skip", + " noprompt splash --", + "initrd /casper/initrd ", + "boot" + ] + } + ], + "provisioners": [{ + "type": "shell", + "execute_command": "echo 'oem' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'", + "inline": [ + "while(pgrep -a apt-get); do sleep 1; done", + "export DEBIAN_FRONTEND=noninteractive", + "apt-get update", + "apt-get install -y git ansible aptitude", + "git clone -b {{user `git_branch`}} {{user `git_repo`}}", + "cd /home/oem/cs-vm-build/scripts", + "./oem-build", + "/usr/sbin/oem-config-prepare" + ] + }] +} From cbe6e695ea5f570c7b07f03c7fd556670acfb13e Mon Sep 17 00:00:00 2001 From: Kyle Laker Date: Sat, 2 Sep 2023 08:53:05 -0400 Subject: [PATCH 2/9] Convert QEMU build to HCL This is still super early phase but I'd been meaning to get around to this for awhile. I need to actually try to run it; this is purely theoretical at the moment. --- .github/workflows/lint.yml | 1 - README.md | 3 +- packer/main.pkr.hcl | 70 ++++++++++++++++++++++++++++- packer/ubuntu-kvm.json | 90 -------------------------------------- packer/variables.pkr.hcl | 34 ++++++++++++++ 5 files changed, 105 insertions(+), 93 deletions(-) delete mode 100644 packer/ubuntu-kvm.json diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 89c19d69..463d07e7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -52,7 +52,6 @@ jobs: packer validate -var-file=mint-beta.pkrvars.hcl . || true # This runs last to ensure it's exit status is captured packer validate . - packer validate ubuntu-kvm.json working-directory: packer - name: Check Packer HCL formatting run: | diff --git a/README.md b/README.md index 746ffca2..f782b3b6 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,8 @@ Linux and Windows hosts, but feedback on other platforms is always welcome. Due to difficulties with Packer packaging, this VM is frequently built with the latest version of Packer available directly from Hashicorp. Check the -`main.pkr.hcl` file for the current minimum version required. +`main.pkr.hcl` file for the current minimum version required. To install the +required plugins, run `packer init .` within the `cs-vm-build/packer` directory. Once the prerequisites are installed, change into the `cs-vm-build/packer` directory and execute `packer build -only "*.mint" .`. This will take a diff --git a/packer/main.pkr.hcl b/packer/main.pkr.hcl index 1237ae19..17dc33d5 100644 --- a/packer/main.pkr.hcl +++ b/packer/main.pkr.hcl @@ -1,6 +1,10 @@ packer { - required_version = ">= 1.7.0" + required_version = ">= 1.9.0" required_plugins { + qemu = { + source = "github.com/hashicorp/qemu" + version = "~> 1" + } virtualbox = { version = "~> 1" source = "github.com/hashicorp/virtualbox" @@ -8,6 +12,62 @@ packer { } } +source "qemu" "kvm" { + cpus = 2 + memory = 4096 + disk_size = 20480 + machine_type = "virt" + accelerator = var.qemu_accelerator + + format = "qcow2" + headless = "${var.headless}" + http_directory = "http" + qemu_binary = "qemu-system-aarch64" + + efi_firmware_code = "${var.qemu_firmware_directory}/QEMU_EFI.fd" + efi_firmware_vars = "${var.qemu_firmware_directory}/QEMU_VARS.fd" + qemuargs = [ + ["-boot", "strict=off"], + ["-cpu", "host"], + ["-display", var.headless ? "none" : "gtk"], + ["-device", "virtio-rng-pci"], + ["-device", "virtio-gpu"], + ["-device", "nec-usb-xhci,id=xhci"], + ["-device", "usb-kbd,bus=xhci.0"], + ["-device", "usb-tablet,bus=xhci.0"] + ] + qemu_img_args { + create = ["-o", "preallocation=falloc"] + convert = ["-o", "compression_type=zstd"] + } + disk_cache = "unsafe" + disk_compression = "true" + disk_detect_zeroes = "unmap" + disk_discard = "unmap" + disk_interface = "virtio" + net_device = "virtio-net" + ssh_username = var.ssh_user + ssh_password = var.ssh_pass + ssh_timeout = "100m" + + boot_wait = var.aarch64_boot_wait + boot_command = [ + # Enter the command line + "c", + # Configure the kernel + "linux /casper/vmlinuz", + " auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/oem-preseed.cfg", + " automatic-ubiquity only-ubiquity", + " debug-ubiquity oem-config/enable=true", + " keymap=us fsck.mode=skip", + " noprompt splash --", + # Configure initrd & boot + "initrd /casper/initrd ", + "boot" + ] + shutdown_command = "echo -e \"${var.ssh_pass}\\n\" | sudo -S poweroff" +} + source "virtualbox-iso" "base-build" { cpus = 2 memory = 4096 @@ -113,6 +173,14 @@ build { ] } + source "source.qemu.kvm" { + name = "ubuntu-aarch64" + vm_name = "image.qcow2" + iso_url = "${local.ubuntu_aarch64_info.mirror_url}/${local.ubuntu_aarch64_info.iso_file}" + iso_checksum = "file:${local.ubuntu_aarch64_info.mirror_url}/SHA256SUMS" + output_directory = "${local.artifact_dir_prefix}ubuntu-aarch64" + } + provisioner "shell" { execute_command = "echo 'oem' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'" environment_vars = [ diff --git a/packer/ubuntu-kvm.json b/packer/ubuntu-kvm.json deleted file mode 100644 index ed0ac417..00000000 --- a/packer/ubuntu-kvm.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "min_packer_version": "1.6.0", - "variables": { - "vm_name": "JMU Ubuntu", - "semester": "Fa22", - - "build_id": "{{isotime \"2006-01-02\"}}", - - "git_repo": "https://github.com/jmunixusers/cs-vm-build", - "git_branch": "main", - - "headless": "false", - - "output_dir": "{{pwd}}/{{user `vm_name`}} {{user `semester`}}.utm/Images", - "mirror_url": "http://cdimage.ubuntu.com/jammy/daily-live/current", - "iso_file": "jammy-desktop-arm64.iso", - - "ssh_user": "oem", - "ssh_pass": "oem" - }, - "builders": [ - { - "type": "qemu", - "headless": "{{user `headless`}}", - "cpus": 2, - "accelerator": "kvm", - "memory": 4096, - "machine_type": "virt", - "qemu_binary": "qemu-system-aarch64", - "qemuargs": [ - [ "-bios", "/usr/share/qemu-efi-aarch64/QEMU_EFI.fd" ], - [ "-boot", "strict=off" ], - [ "-cpu", "host" ], - [ "-display", "gtk" ], - [ "-device", "virtio-rng-pci" ], - [ "-device", "virtio-gpu" ], - [ "-device", "nec-usb-xhci,id=xhci" ], - [ "-device", "usb-kbd,bus=xhci.0" ], - [ "-device", "usb-tablet,bus=xhci.0" ] - ], - "iso_url": "{{user `mirror_url`}}/{{user `iso_file`}}", - "iso_checksum": "file:{{user `mirror_url`}}/SHA256SUMS", - "output_directory": "{{user `output_dir`}}", - "shutdown_command": "echo -e \"{{user `ssh_pass`}}\\n\" | sudo -S poweroff", - "disk_cache": "unsafe", - "disk_compression": "true", - "disk_detect_zeroes": "unmap", - "disk_discard": "unmap", - "disk_size": "20G", - "format": "qcow2", - "qemu_img_args": { - "create": ["-o", "preallocation=falloc"], - "convert": ["-o", "compression_type=zstd"] - }, - "http_directory": "http", - "ssh_username": "{{user `ssh_user`}}", - "ssh_password": "{{user `ssh_pass`}}", - "ssh_timeout": "100m", - "vm_name": "image.qcow2", - "net_device": "virtio-net", - "disk_interface": "virtio", - "boot_wait": "45s", - "boot_command": [ - "c", - "linux /casper/vmlinuz", - " auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/oem-preseed.cfg", - " automatic-ubiquity only-ubiquity", - " debug-ubiquity oem-config/enable=true", - " keymap=us fsck.mode=skip", - " noprompt splash --", - "initrd /casper/initrd ", - "boot" - ] - } - ], - "provisioners": [{ - "type": "shell", - "execute_command": "echo 'oem' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'", - "inline": [ - "while(pgrep -a apt-get); do sleep 1; done", - "export DEBIAN_FRONTEND=noninteractive", - "apt-get update", - "apt-get install -y git ansible aptitude", - "git clone -b {{user `git_branch`}} {{user `git_repo`}}", - "cd /home/oem/cs-vm-build/scripts", - "./oem-build", - "/usr/sbin/oem-config-prepare" - ] - }] -} diff --git a/packer/variables.pkr.hcl b/packer/variables.pkr.hcl index ff4f0bb1..3824e7b2 100644 --- a/packer/variables.pkr.hcl +++ b/packer/variables.pkr.hcl @@ -71,6 +71,36 @@ variable "vm_name" { default = "JMU CS" } +variable "aarch64_boot_wait" { + type = string + default = "25s" + description = "The length of time to wait after boot before entering commands" + + validation { + condition = can(regex("\\d+s", var.aarch64_boot_wait)) + error_message = "The value should be a number of seconds followed by 's'." + } +} + +variable "qemu_accelerator" { + type = string + default = "kvm" + description = < Date: Mon, 2 Aug 2021 11:13:13 -0400 Subject: [PATCH 3/9] First attempt at config.plist --- packer/config.plist | 111 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 packer/config.plist diff --git a/packer/config.plist b/packer/config.plist new file mode 100644 index 00000000..a9025471 --- /dev/null +++ b/packer/config.plist @@ -0,0 +1,111 @@ + + + + + ConfigurationVersion + 2 + Debug + + DebugLog + + + Display + + ConsoleFont + Menlo + ConsoleFontSize + 12 + ConsoleTheme + Default + DisplayCard + virtio-ramfb-gl + DisplayDownscaler + linear + DisplayFitScreen + + DisplayRetina + + DisplayUpscaler + linear + + Drives + + + DriveName + drive0 + ImagePath + image.qcow2 + ImageType + disk + InterfaceType + virtio + + + Info + + Icon + ubuntu + IconCustom + + Notes + + + Input + + InputLegacy + + + Networking + + NetworkCard + virtio-net-pci + NetworkMode + emulated + + Printing + + Sharing + + ClipboardSharing + + DirectoryName + + DirectorySharing + + Usb3Support + + UsbRedirectMax + 3 + + Sound + + SoundCard + intel-hda + SoundEnabled + + + System + + Architecture + aarch64 + BootDevice + + CPU + cortex-a72 + CPUCount + 0 + ForceMulticore + + JITCacheSize + 0 + MachineProperties + highmem=off + Memory + 4096 + SystemUUID + 1A9B879C-CDA8-4728-AA9A-4717B646E9AC + Target + virt + + + From 9042483eab6f869612fa4a244b8da23228978030 Mon Sep 17 00:00:00 2001 From: Mike Ripley Date: Sun, 15 Aug 2021 10:09:36 -0400 Subject: [PATCH 4/9] Refuse to remove empty string snaps --- roles/oem/tasks/ubuntu_only.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/oem/tasks/ubuntu_only.yml b/roles/oem/tasks/ubuntu_only.yml index 23af26b9..a38613f5 100644 --- a/roles/oem/tasks/ubuntu_only.yml +++ b/roles/oem/tasks/ubuntu_only.yml @@ -13,9 +13,11 @@ errors=0 changed="" while read snapname revision; do - snap remove "$snapname" --revision="$revision" + if [[ -n "$snapname" ]] && [[ -n "$revision" ]]; then + snap remove "$snapname" --revision="$revision" + changed="Snap removed" + fi errors=$((errors + $?)) - changed="Snap removed" done <<< "$(snap list --all | awk '/disabled/{print $1, $3}')" echo $changed exit $errors From 3428c588a595141c76be847bf58b9f936dc31c46 Mon Sep 17 00:00:00 2001 From: Mike Ripley Date: Wed, 7 Feb 2024 16:14:32 -0500 Subject: [PATCH 5/9] aarch64 cleanups --- packer/http/oem-preseed.cfg | 1 + packer/main.pkr.hcl | 4 ++-- packer/variables.pkr.hcl | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packer/http/oem-preseed.cfg b/packer/http/oem-preseed.cfg index c2f7392d..04d4261d 100644 --- a/packer/http/oem-preseed.cfg +++ b/packer/http/oem-preseed.cfg @@ -66,6 +66,7 @@ ubiquity ubiquity/success_command string svcfile="/target/etc/systemd/system/ssh echo "ExecStart=/usr/bin/apt-get -y install openssh-server" >> "$svcfile"; \ echo "ExecStartPost=/bin/systemctl disable ssh-install.service" >> "$svcfile"; \ echo "ExecStartPost=/bin/rm /etc/systemd/system/ssh-install.service" >> "$svcfile"; \ + echo "TimeoutSec=300" >> "$svcfile"; \ echo "[Install]" >> "$svcfile"; \ echo "WantedBy=multi-user.target" >> "$svcfile"; \ in-target systemctl enable ssh-install.service diff --git a/packer/main.pkr.hcl b/packer/main.pkr.hcl index 17dc33d5..daed9249 100644 --- a/packer/main.pkr.hcl +++ b/packer/main.pkr.hcl @@ -24,8 +24,8 @@ source "qemu" "kvm" { http_directory = "http" qemu_binary = "qemu-system-aarch64" - efi_firmware_code = "${var.qemu_firmware_directory}/QEMU_EFI.fd" - efi_firmware_vars = "${var.qemu_firmware_directory}/QEMU_VARS.fd" + efi_firmware_code = "${var.qemu_firmware_directory}/AAVMF_CODE.fd" + efi_firmware_vars = "${var.qemu_firmware_directory}/AAVMF_VARS.fd" qemuargs = [ ["-boot", "strict=off"], ["-cpu", "host"], diff --git a/packer/variables.pkr.hcl b/packer/variables.pkr.hcl index 3824e7b2..bb3bde6a 100644 --- a/packer/variables.pkr.hcl +++ b/packer/variables.pkr.hcl @@ -93,7 +93,7 @@ variable "qemu_accelerator" { variable "qemu_firmware_directory" { type = string - default = "/usr/share/edk2/aarch64" + default = "/usr/share/AAVMF/" description = < Date: Mon, 3 Nov 2025 18:43:02 -0500 Subject: [PATCH 6/9] cloud-init --- packer/http/meta-data | 0 packer/http/network-config | 0 packer/http/user-data | 18 ++++++++++++++++++ packer/http/vendor-data | 0 packer/main.pkr.hcl | 4 +--- 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 packer/http/meta-data create mode 100644 packer/http/network-config create mode 100644 packer/http/user-data create mode 100644 packer/http/vendor-data diff --git a/packer/http/meta-data b/packer/http/meta-data new file mode 100644 index 00000000..e69de29b diff --git a/packer/http/network-config b/packer/http/network-config new file mode 100644 index 00000000..e69de29b diff --git a/packer/http/user-data b/packer/http/user-data new file mode 100644 index 00000000..e1449ea7 --- /dev/null +++ b/packer/http/user-data @@ -0,0 +1,18 @@ +#cloud-config +autoinstall: + version: 1 + codecs: + install: true + identity: + hostname: ubuntu + username: oem + password: $6$250qJD2ObtCZAp.v$8nYXTi6MJo.Qd3dQNQgcz136tbrfza3p8RqXF47T1A1PYlwJ91ug5sJAMy.kCAlWRyQJb8PptIFQ0EmipHltk. + packages: + - ansible + - git + shutdown: reboot + source: + id: ubuntu-server-minimal + ssh: + install-server: true + timezone: "US/Eastern" diff --git a/packer/http/vendor-data b/packer/http/vendor-data new file mode 100644 index 00000000..e69de29b diff --git a/packer/main.pkr.hcl b/packer/main.pkr.hcl index daed9249..db3ab962 100644 --- a/packer/main.pkr.hcl +++ b/packer/main.pkr.hcl @@ -56,9 +56,7 @@ source "qemu" "kvm" { "c", # Configure the kernel "linux /casper/vmlinuz", - " auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/oem-preseed.cfg", - " automatic-ubiquity only-ubiquity", - " debug-ubiquity oem-config/enable=true", + " ds=nocloud;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/", " keymap=us fsck.mode=skip", " noprompt splash --", # Configure initrd & boot From 8097b8d1745e7035d510005a2a9d14c5783a8762 Mon Sep 17 00:00:00 2001 From: Mike Ripley Date: Wed, 5 Nov 2025 14:31:11 -0500 Subject: [PATCH 7/9] aarch64 v.next --- packer/main.pkr.hcl | 11 +++++------ packer/ubuntu-version.auto.pkrvars.hcl | 4 ++-- packer/variables.pkr.hcl | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packer/main.pkr.hcl b/packer/main.pkr.hcl index db3ab962..d266b3f0 100644 --- a/packer/main.pkr.hcl +++ b/packer/main.pkr.hcl @@ -13,7 +13,7 @@ packer { } source "qemu" "kvm" { - cpus = 2 + cpus = 4 memory = 4096 disk_size = 20480 machine_type = "virt" @@ -28,7 +28,7 @@ source "qemu" "kvm" { efi_firmware_vars = "${var.qemu_firmware_directory}/AAVMF_VARS.fd" qemuargs = [ ["-boot", "strict=off"], - ["-cpu", "host"], + ["-cpu", "max"], ["-display", var.headless ? "none" : "gtk"], ["-device", "virtio-rng-pci"], ["-device", "virtio-gpu"], @@ -55,10 +55,9 @@ source "qemu" "kvm" { # Enter the command line "c", # Configure the kernel - "linux /casper/vmlinuz", - " ds=nocloud;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/", - " keymap=us fsck.mode=skip", - " noprompt splash --", + "linux /casper/vmlinuz ", + " autoinstall 'ds=nocloud;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/'", + " ", # Configure initrd & boot "initrd /casper/initrd ", "boot" diff --git a/packer/ubuntu-version.auto.pkrvars.hcl b/packer/ubuntu-version.auto.pkrvars.hcl index 510f6cfd..f30e5616 100644 --- a/packer/ubuntu-version.auto.pkrvars.hcl +++ b/packer/ubuntu-version.auto.pkrvars.hcl @@ -1,4 +1,4 @@ ubuntu_version = { - version = "jammy" - patched_version = "22.04.5" + version = "noble" + patched_version = "24.04.3" } diff --git a/packer/variables.pkr.hcl b/packer/variables.pkr.hcl index bb3bde6a..0ce8d259 100644 --- a/packer/variables.pkr.hcl +++ b/packer/variables.pkr.hcl @@ -84,7 +84,7 @@ variable "aarch64_boot_wait" { variable "qemu_accelerator" { type = string - default = "kvm" + default = "tcg" description = < Date: Wed, 12 Nov 2025 07:34:33 -0500 Subject: [PATCH 8/9] test2 --- packer/http/user-data | 11 +++++++++++ packer/main.pkr.hcl | 20 +++++++++++++++----- packer/variables.pkr.hcl | 4 ++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/packer/http/user-data b/packer/http/user-data index e1449ea7..69e29c48 100644 --- a/packer/http/user-data +++ b/packer/http/user-data @@ -9,10 +9,21 @@ autoinstall: password: $6$250qJD2ObtCZAp.v$8nYXTi6MJo.Qd3dQNQgcz136tbrfza3p8RqXF47T1A1PYlwJ91ug5sJAMy.kCAlWRyQJb8PptIFQ0EmipHltk. packages: - ansible + - cinnamon-desktop-environment + - gdm3 - git + - ubuntucinnamon-wallpapers-noble shutdown: reboot source: id: ubuntu-server-minimal ssh: install-server: true + storage: + layout: + name: lvm + sizing-policy: all timezone: "US/Eastern" + late-commands: + - curtin in-target -- locale-gen en_US.UTF-8 + - curtin in-target -- git clone -b aarch64-support https://github.com/ripleymj/cs-vm-build + - curtin in-target -- bash -c "export LC_ALL=en_US.UTF-8; cs-vm-build/scripts/oem-build" diff --git a/packer/main.pkr.hcl b/packer/main.pkr.hcl index d266b3f0..c1d47c07 100644 --- a/packer/main.pkr.hcl +++ b/packer/main.pkr.hcl @@ -16,16 +16,16 @@ source "qemu" "kvm" { cpus = 4 memory = 4096 disk_size = 20480 - machine_type = "virt" - accelerator = var.qemu_accelerator + machine_type = "q35" + accelerator = "kvm" format = "qcow2" headless = "${var.headless}" http_directory = "http" - qemu_binary = "qemu-system-aarch64" +# qemu_binary = "qemu-system-aarch64" - efi_firmware_code = "${var.qemu_firmware_directory}/AAVMF_CODE.fd" - efi_firmware_vars = "${var.qemu_firmware_directory}/AAVMF_VARS.fd" +# efi_firmware_code = "${var.qemu_firmware_directory}/AAVMF_CODE.fd" +# efi_firmware_vars = "${var.qemu_firmware_directory}/AAVMF_VARS.fd" qemuargs = [ ["-boot", "strict=off"], ["-cpu", "max"], @@ -178,7 +178,17 @@ build { output_directory = "${local.artifact_dir_prefix}ubuntu-aarch64" } + source "source.qemu.kvm" { + name = "ubuntu-amd64" + vm_name = "image.qcow2" + iso_url = "${local.ubuntu_aarch64_info.mirror_url}/${local.ubuntu_amd64_info.iso_file}" + iso_checksum = "file:${local.ubuntu_amd64_info.mirror_url}/SHA256SUMS" + output_directory = "${local.artifact_dir_prefix}ubuntu-amd64" + } + provisioner "shell" { + only = ["virtualbox-iso.base-build"] + execute_command = "echo 'oem' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'" environment_vars = [ "DEBIAN_FRONTEND=noninteractive" diff --git a/packer/variables.pkr.hcl b/packer/variables.pkr.hcl index 0ce8d259..644b6ef0 100644 --- a/packer/variables.pkr.hcl +++ b/packer/variables.pkr.hcl @@ -103,9 +103,9 @@ variable "qemu_firmware_directory" { locals { build_id = formatdate("YYYY-MM-DD", timestamp()) - ubuntu_info = { + ubuntu_amd64_info = { mirror_url = "${var.mirror.base}/${var.mirror.ubuntu_path}/${var.ubuntu_version.version}" - iso_file = "ubuntu-${var.ubuntu_version.patched_version}-desktop-amd64.iso" + iso_file = "ubuntu-${var.ubuntu_version.patched_version}-live-server-amd64.iso" } mint_info = { mirror_url = "${var.mirror.base}/${var.mirror.mint_path}/${var.mint_version.build_type == "beta" ? "testing" : "stable/${var.mint_version.version}"}" From c065ffcbd59424a234c48ab9a3c88601ad19c16d Mon Sep 17 00:00:00 2001 From: Mike Ripley Date: Fri, 12 Dec 2025 10:38:14 -0500 Subject: [PATCH 9/9] test3 --- packer/http/user-data | 21 +++++++++++++++++---- packer/main.pkr.hcl | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packer/http/user-data b/packer/http/user-data index 69e29c48..fbb0733e 100644 --- a/packer/http/user-data +++ b/packer/http/user-data @@ -7,15 +7,26 @@ autoinstall: hostname: ubuntu username: oem password: $6$250qJD2ObtCZAp.v$8nYXTi6MJo.Qd3dQNQgcz136tbrfza3p8RqXF47T1A1PYlwJ91ug5sJAMy.kCAlWRyQJb8PptIFQ0EmipHltk. + network: + version: 2 + ethernets: + eth0: + dhcp4: true + match: + name: en* packages: - ansible - - cinnamon-desktop-environment - - gdm3 + - bash-completion +# - cinnamon-desktop-environment +# - gdm3 +# - gnome-initial-setup - git - - ubuntucinnamon-wallpapers-noble + - linux-image-virtual +# - ubuntucinnamon-wallpapers-noble + - vim shutdown: reboot source: - id: ubuntu-server-minimal + id: ubuntu-server ssh: install-server: true storage: @@ -25,5 +36,7 @@ autoinstall: timezone: "US/Eastern" late-commands: - curtin in-target -- locale-gen en_US.UTF-8 + - curtin in-target -- apt-get -y --autoremove --purge remove linux-generic linux-image-generic linux-headers* linux-modules-extra* linux-tools* linux-firmware + - curtin in-target -- apt-get -y install cinnamon-desktop-environment gdm3 gnome-initial-setup ubuntucinnamon-wallpapers-noble - curtin in-target -- git clone -b aarch64-support https://github.com/ripleymj/cs-vm-build - curtin in-target -- bash -c "export LC_ALL=en_US.UTF-8; cs-vm-build/scripts/oem-build" diff --git a/packer/main.pkr.hcl b/packer/main.pkr.hcl index c1d47c07..a0fc46f4 100644 --- a/packer/main.pkr.hcl +++ b/packer/main.pkr.hcl @@ -110,7 +110,7 @@ source "virtualbox-iso" "base-build" { "initrd /casper/initrd.lz", "boot" ] - shutdown_command = "echo -e \"${var.ssh_pass}\\n\" | sudo -S poweroff" + shutdown_command = "echo -e \"${var.ssh_pass}\\n\" | sudo -S userdel -rf oem; echo -e \"${var.ssh_pass}\\n\" | sudo -S poweroff" vboxmanage = [ ["modifyvm", "{{ .Name }}", "--audioin", "off"],