From 81f387c34077b96d028f3a5d28f3b7e6d572f905 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Mon, 12 Jun 2023 00:47:58 -0400 Subject: [PATCH] Updated debianzfs for Debian 12 (Bookworm) - Shifted release info to packer variables - Doubled boot_command initial wait to 20s - Renamed Packer source to debian-live - Removed .sh from debianzfs script path - Tweaked comment wording - Replaced hardcoded codename - Used 'ln -fs' for existing /etc/mtab --- Makefile | 9 ++++++++- debianzfs.pkr.hcl | 16 +++++++++------- debianzfs.sh | 6 +++--- scripts/setup.sh | 2 +- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index aa2b1b7..317764e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,13 @@ all: debianzfs.qcow2 -debianzfs.qcow2: export PKR_VAR_password = "$(pwgen -s 8 1)" +# Generate password +debianzfs.qcow2: export PKR_VAR_password="$(pwgen -s 8 1)" + +# Release info +debianzfs.qcow2: export PKR_VAR_release=12.0.0 +debianzfs.qcow2: export PKR_VAR_codename=bookworm +debianzfs.qcow2: export PKR_VAR_sha256=fa3960f6f692fc60a43eec4362d60f754b4a246ab64aa662270dd879a946de84 + debianzfs.qcow2: packer build -color=false . | tee debianzfs.log diff --git a/debianzfs.pkr.hcl b/debianzfs.pkr.hcl index ef23090..f5c54cb 100644 --- a/debianzfs.pkr.hcl +++ b/debianzfs.pkr.hcl @@ -1,9 +1,11 @@ # Set 'password' using shell var: PKR_VAR_password=$(pwgen -s 8 1) variable "password" {} +variable "release" {} +variable "sha256" {} -source "qemu" "bullseye-live" { - iso_url = "https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-11.5.0-amd64-standard.iso" - iso_checksum = "sha256:8172b188061d098080bb315972becbe9bd387c856866746cee018102cd00fc9b" +source "qemu" "debian-live" { + iso_url = "https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-${var.release}-amd64-standard.iso" + iso_checksum = "sha256:${var.sha256}" output_directory = "output" shutdown_command = "echo 'packer' | sudo -S shutdown -P now" disk_size = "5000M" @@ -19,7 +21,7 @@ source "qemu" "bullseye-live" { disk_interface = "virtio" boot_wait = "5s" boot_command = [ - "", + "", "", "sudo -i", "read -s userpw", @@ -33,11 +35,11 @@ source "qemu" "bullseye-live" { build { name = "zfs" - sources = ["source.qemu.bullseye-live"] + sources = ["source.qemu.debian-live"] provisioner "file" { source = "debianzfs.sh" - destination = "/tmp/debianzfs.sh" + destination = "/tmp/debianzfs" } provisioner "shell" { @@ -45,7 +47,7 @@ build { } provisioner "shell" { - inline = ["sudo /tmp/debianzfs.sh -i -s0 -p changeme -P letmeinzfs! /dev/vda debianzfs"] + inline = ["sudo /tmp/debianzfs -i -s0 -p 'changeme' -P 'letmeinzfs!' /dev/vda debianzfs"] } } diff --git a/debianzfs.sh b/debianzfs.sh index bd0e11a..30c7d49 100755 --- a/debianzfs.sh +++ b/debianzfs.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Script is based off official guide: see "Debian Bullseye Root on ZFS" +# This script is originally based off the "Debian Bullseye Root on ZFS" guide # https://openzfs.github.io/openzfs-docs/Getting%20Started/Debian/Debian%20Bullseye%20Root%20on%20ZFS.html ################# @@ -151,7 +151,7 @@ function disk_byid_check () { ################ # Static export DEBIAN_FRONTEND=noninteractive -CODENAME="bullseye" +CODENAME="bookworm" # Options while getopts ':ghim:p:P:r:s:' OPTION; do @@ -422,7 +422,7 @@ unset CDPATH cd # 5. Configure a basic system environment -ln -s /proc/self/mounts /etc/mtab +ln -fs /proc/self/mounts /etc/mtab apt-get update && apt-get upgrade -y apt-get install -y console-setup locales diff --git a/scripts/setup.sh b/scripts/setup.sh index 0f325d7..43124ac 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1,3 +1,3 @@ #!/bin/bash sudo passwd -d user -sudo chmod u+x /tmp/debianzfs.sh +sudo chmod u+x /tmp/debianzfs