variable "iso_name" { default = "debian-12.4.0-amd64-netinst.iso" } variable "iso_checksum" { default = "64d727dd5785ae5fcfd3ae8ffbede5f40cca96f1580aaa2820e8b99dae989d94" } variable "pack" { default = "lean" } variable "github_user" { default = "raspiblitz" } variable "branch" { default = "dev" } variable "desktop" { default = "none" } variable "boot" { default = "uefi" } variable "preseed_file" { default = "preseed.cfg" } variable "hostname" { default = "raspiblitz-amd64" } variable "disk_size" { default = "30000" } variable "memory" { default = "4096" } variable "cpus" { default = "4" } locals { name_template = "${var.hostname}-debian-${var.pack}" bios_file = var.boot == "uefi" ? "OVMF.fd" : "bios-256k.bin" boot_command = var.boot == "uefi" ? [ "c", "linux /install.amd/vmlinuz ", "auto=true ", "url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/${var.preseed_file} ", "hostname=${var.hostname} ", "domain=${var.hostname}.local ", "interface=auto ", "vga=788 noprompt quiet --", "initrd /install.amd/initrd.gz", "boot" ] : [ "install ", " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/${var.preseed_file} ", "debian-installer=en_US.UTF-8 ", "auto ", "locale=en_US.UTF-8 ", "kbd-chooser/method=us ", "keyboard-configuration/xkb-keymap=us ", "netcfg/get_hostname=${var.hostname} ", "netcfg/get_domain=${var.hostname}.local ", "fb=false ", "debconf/frontend=noninteractive ", "console-setup/ask_detect=false ", "console-keymaps-at/keymap=us ", "grub-installer/bootdev=default ", "" ] } source "qemu" "debian" { boot_command = local.boot_command boot_wait = "5s" cpus = var.cpus disk_size = var.disk_size http_directory = "./http" iso_checksum = var.iso_checksum iso_url = "https://cdimage.debian.org/cdimage/release/current/amd64/iso-cd/${var.iso_name}" memory = var.memory output_directory = "../builds/${local.name_template}-qemu" shutdown_command = "echo 'raspiblitz' | sudo /sbin/shutdown -hP now" ssh_password = "raspiblitz" ssh_port = 22 ssh_timeout = "10000s" ssh_username = "pi" format = "qcow2" vm_name = "${local.name_template}.qcow2" headless = false vnc_bind_address = "127.0.0.1" vnc_port_max = 5900 vnc_port_min = 5900 qemuargs = [ ["-m", var.memory], ["-bios", local.bios_file], ["-display", "none"] ] } build { description = "Can't use variables here yet!" sources = ["source.qemu.debian"] provisioner "shell" { environment_vars = [ "HOME_DIR=/home/pi", "github_user=${var.github_user}", "branch=${var.branch}", "pack=${var.pack}", "desktop=${var.desktop}" ] execute_command = "echo 'raspiblitz' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'" expect_disconnect = true scripts = [ "./../_common/env.sh", "./scripts/update.sh", "./../_common/sshd.sh", "./scripts/networking.sh", "./scripts/sudoers.sh", "./scripts/systemd.sh", "./scripts/build.raspiblitz.sh", "./scripts/cleanup.sh" ] } } packer { required_version = ">= 1.7.0, < 2.0.0" required_plugins { qemu = { source = "github.com/hashicorp/qemu" version = ">= 1.0.0, < 2.0.0" } } }