From 97241ba1798c8c52a58cfd75066919b10c919edb Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 29 Jun 2024 23:37:19 -0500 Subject: [PATCH 01/24] Add Ubuntu 24.04 --- distros/ubuntu/24.04/amd64.pkrvars.hcl | 20 +++++++++++ distros/ubuntu/24.04/disc/meta-data | 0 distros/ubuntu/24.04/disc/user-data | 47 ++++++++++++++++++++++++++ distros/ubuntu/24.04/finalize.sh | 16 +++++++++ distros/ubuntu/24.04/qemu.sh | 6 ++++ distros/ubuntu/24.04/virtualbox.sh | 4 +++ distros/ubuntu/24.04/vmware.sh | 4 +++ distros/ubuntu/default.nix | 4 +++ 8 files changed, 101 insertions(+) create mode 100644 distros/ubuntu/24.04/amd64.pkrvars.hcl create mode 100644 distros/ubuntu/24.04/disc/meta-data create mode 100644 distros/ubuntu/24.04/disc/user-data create mode 100644 distros/ubuntu/24.04/finalize.sh create mode 100644 distros/ubuntu/24.04/qemu.sh create mode 100644 distros/ubuntu/24.04/virtualbox.sh create mode 100644 distros/ubuntu/24.04/vmware.sh diff --git a/distros/ubuntu/24.04/amd64.pkrvars.hcl b/distros/ubuntu/24.04/amd64.pkrvars.hcl new file mode 100644 index 0000000..b1feba3 --- /dev/null +++ b/distros/ubuntu/24.04/amd64.pkrvars.hcl @@ -0,0 +1,20 @@ +distro = "ubuntu" +version = "24.04" +iso = { + url = "http://releases.ubuntu.com/24.04/ubuntu-24.04-live-server-amd64.iso" + checksum = "8762f7e74e4d64d72fceb5f70682e6b069932deedb4949c6975d0f0fe0a91be3" +} +boot_command = [ + "e", + "console=ttyS0 ", + "fsck.mode=skip ", + "locale=en_US ", + "auto=true ", + "priority=critical ", + "autoinstall", + "", +] +cd_files = [ + "distros/ubuntu/24.04/disc/*" +] +vbox_os_type = "Ubuntu24_64" diff --git a/distros/ubuntu/24.04/disc/meta-data b/distros/ubuntu/24.04/disc/meta-data new file mode 100644 index 0000000..e69de29 diff --git a/distros/ubuntu/24.04/disc/user-data b/distros/ubuntu/24.04/disc/user-data new file mode 100644 index 0000000..4b96996 --- /dev/null +++ b/distros/ubuntu/24.04/disc/user-data @@ -0,0 +1,47 @@ +#cloud-config +# vim: set ft=yaml: +autoinstall: + version: 1 + network: # Should disable networking, workaround for unattended-updates failing in install + version: 2 + ethernets: + eth0: + match: + name: e* + dhcp4: yes + dhcp6: no + refresh-installer: + update: no + keyboard: + layout: us + toggle: null + variant: '' + locale: en_US.UTF-8 + identity: + hostname: vagrant + username: vagrant + password: $6$rounds=4096$mJTRlY/vwPMquLe0$s4Ld3ZnvF.pM86xzbAgQD7Xpi/NMVgyQNb5CEfabFgL6nLRsP56WtwA.o.Jg/xC6HaJmM2p5fCGIo37jmKVRI0 + ssh: + install-server: yes + authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key + allow-pw: yes + user-data: + disable_root: false + package_update: false + package_upgrade: false + late-commands: + - echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant + - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /target/etc/sudoers.d/vagrant + - chmod 440 /target/etc/sudoers.d/vagrant + - >- + curtin in-target --target=/target -- + bash -c 'if [ "$(systemd-detect-virt)" == "microsoft" ]; then + apt-get update; + apt-get install -y linux-azure; + fi' + - curtin in-target --target=/target -- logger "finished late-commands" + packages: + - ca-certificates + - curl + - sudo diff --git a/distros/ubuntu/24.04/finalize.sh b/distros/ubuntu/24.04/finalize.sh new file mode 100644 index 0000000..f79a717 --- /dev/null +++ b/distros/ubuntu/24.04/finalize.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -ex + +apt remove cloud-init -y + +apt update +apt upgrade -y + +# Make sshd faster +cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +UseDNS no +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + +# Clean up after ourselves +apt-get clean diff --git a/distros/ubuntu/24.04/qemu.sh b/distros/ubuntu/24.04/qemu.sh new file mode 100644 index 0000000..4ef2dee --- /dev/null +++ b/distros/ubuntu/24.04/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +apt install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/ubuntu/24.04/virtualbox.sh b/distros/ubuntu/24.04/virtualbox.sh new file mode 100644 index 0000000..2813d68 --- /dev/null +++ b/distros/ubuntu/24.04/virtualbox.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +apt install -y virtualbox-guest-utils diff --git a/distros/ubuntu/24.04/vmware.sh b/distros/ubuntu/24.04/vmware.sh new file mode 100644 index 0000000..9560300 --- /dev/null +++ b/distros/ubuntu/24.04/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +apt install -y open-vm-tools diff --git a/distros/ubuntu/default.nix b/distros/ubuntu/default.nix index c0643db..a45aa86 100644 --- a/distros/ubuntu/default.nix +++ b/distros/ubuntu/default.nix @@ -14,4 +14,8 @@ version = "23.10"; arch = "amd64"; eol = false; +} { + version = "24.04"; + arch = "amd64"; + eol = false; } ] From a1228d376d6c49736cc338a406c2ff9f57a54a8a Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 29 Jun 2024 23:54:13 -0500 Subject: [PATCH 02/24] Be sure to init sources --- .gitlab-ci-build.yml.in | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci-build.yml.in b/.gitlab-ci-build.yml.in index cf9f0cf..74ee9d2 100644 --- a/.gitlab-ci-build.yml.in +++ b/.gitlab-ci-build.yml.in @@ -40,6 +40,7 @@ stages: ${EXCEPT} sources script: + - packer init sources - echo $COMMAND > build.sh - bash build.sh || exit 1 From c0e98b3b116b6e4e33cd7033840157c364eade36 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 29 Jun 2024 23:59:16 -0500 Subject: [PATCH 03/24] Move opensuse to DVD --- distros/opensuse/15.5/amd64.pkrvars.hcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distros/opensuse/15.5/amd64.pkrvars.hcl b/distros/opensuse/15.5/amd64.pkrvars.hcl index ce2b718..63a8629 100644 --- a/distros/opensuse/15.5/amd64.pkrvars.hcl +++ b/distros/opensuse/15.5/amd64.pkrvars.hcl @@ -1,8 +1,8 @@ distro = "opensuse" version = "15.5" iso = { - url = "https://download.opensuse.org/distribution/leap/15.5/iso/openSUSE-Leap-15.5-NET-x86_64-Media.iso" - checksum = "a2f7f2f1b6b3d3ef96f5c8f804d87ebd01e5cf982357c533f4c39c33cd20ec56" + url = "http://download.opensuse.org/distribution/leap/15.5/iso/openSUSE-Leap-15.5-DVD-x86_64-Current.iso" + checksum = "53bcbcb82361c5261c9d0994ab0f94101bf28e61c06fe12d320984601be35a8f" } boot_command = [ "e", From de5dc1ae7ec58e349334f1669749470aa1645365 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 30 Jun 2024 00:04:39 -0500 Subject: [PATCH 04/24] Add OpenSUSE 15.6 --- distros/opensuse/15.6/amd64.pkrvars.hcl | 4 ++-- distros/opensuse/default.nix | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/distros/opensuse/15.6/amd64.pkrvars.hcl b/distros/opensuse/15.6/amd64.pkrvars.hcl index 8e158a1..f738b6a 100644 --- a/distros/opensuse/15.6/amd64.pkrvars.hcl +++ b/distros/opensuse/15.6/amd64.pkrvars.hcl @@ -1,8 +1,8 @@ distro = "opensuse" version = "15.6" iso = { - url = "https://download.opensuse.org/distribution/leap/15.6/iso/openSUSE-Leap-15.6-NET-x86_64-Media.iso" - checksum = "4631636c43297951f1a0a3a2a804e30f4bf1790f892d0f0ac46f62ec82ac2075" + url = "https://download.opensuse.org/distribution/leap/15.6/iso/openSUSE-Leap-15.6-DVD-x86_64-Current.iso" + checksum = "a74d4072e639c75ca127df3d869c1e57bcc44a093a969550f348a3ead561fe4f" } boot_command = [ "e", diff --git a/distros/opensuse/default.nix b/distros/opensuse/default.nix index 01de93d..d8245ba 100644 --- a/distros/opensuse/default.nix +++ b/distros/opensuse/default.nix @@ -2,6 +2,10 @@ version = "15.5"; arch = "amd64"; eol = false; +} { + version = "15.6"; + arch = "amd64"; + eol = false; } { version = "tumbleweed"; arch = "amd64"; From cea0d3fb180abdb9d8ebd2285f1c795def33d415 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 30 Jun 2024 00:08:38 -0500 Subject: [PATCH 05/24] Add NixOS 24.05 --- distros/nixos/24.05/amd64.pkrvars.hcl.sh | 41 +++++++++++++ distros/nixos/24.05/finalize.sh | 2 + distros/nixos/24.05/http/configuration.nix | 67 ++++++++++++++++++++++ distros/nixos/24.05/http/flake.nix | 15 +++++ distros/nixos/24.05/http/ga-kvm.nix | 1 + distros/nixos/24.05/http/ga-microsoft.nix | 4 ++ distros/nixos/24.05/http/ga-oracle.nix | 7 +++ distros/nixos/24.05/http/ga-qemu.nix | 4 ++ distros/nixos/24.05/http/ga-vmware.nix | 7 +++ distros/nixos/24.05/http/in-chroot.sh | 10 ++++ distros/nixos/24.05/http/install.sh | 64 +++++++++++++++++++++ distros/nixos/24.05/qemu.sh | 2 + distros/nixos/24.05/virtualbox.sh | 2 + distros/nixos/24.05/vmware.sh | 2 + distros/nixos/default.nix | 4 ++ 15 files changed, 232 insertions(+) create mode 100755 distros/nixos/24.05/amd64.pkrvars.hcl.sh create mode 100644 distros/nixos/24.05/finalize.sh create mode 100644 distros/nixos/24.05/http/configuration.nix create mode 100644 distros/nixos/24.05/http/flake.nix create mode 120000 distros/nixos/24.05/http/ga-kvm.nix create mode 100644 distros/nixos/24.05/http/ga-microsoft.nix create mode 100644 distros/nixos/24.05/http/ga-oracle.nix create mode 100644 distros/nixos/24.05/http/ga-qemu.nix create mode 100644 distros/nixos/24.05/http/ga-vmware.nix create mode 100644 distros/nixos/24.05/http/in-chroot.sh create mode 100644 distros/nixos/24.05/http/install.sh create mode 100644 distros/nixos/24.05/qemu.sh create mode 100644 distros/nixos/24.05/virtualbox.sh create mode 100644 distros/nixos/24.05/vmware.sh diff --git a/distros/nixos/24.05/amd64.pkrvars.hcl.sh b/distros/nixos/24.05/amd64.pkrvars.hcl.sh new file mode 100755 index 0000000..3939820 --- /dev/null +++ b/distros/nixos/24.05/amd64.pkrvars.hcl.sh @@ -0,0 +1,41 @@ +#!env bash +set -exo pipefail + +# Name of the file to write out +name="${0%.sh}" + +version="24.05" + +# Base URL +base="https://channels.nixos.org/nixos-${version}/latest-nixos-minimal-x86_64-linux.iso" + +# Working directory +tmp="$(mktemp -d)" +checksums="${tmp}/checksums" + +# Read the SHA256 sum value +curl -L -o "${checksums}" "${base}.sha256" +until curl -f -L -o "${checksums}" "${base}.sha256"; do + sleep 1 +done +sha="$(grep -e minimal "${checksums}" | cut -d' ' -f 1)" + +# Write out HCL file +cat << EOF > "${name}" +distro = "nixos" +version = "${version}" +iso = { + url = "${base}" + checksum = "${sha}" +} +boot_command = [ + "curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh", + "", + "sudo bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}" +] +http_directory = "distros/nixos/${version}/http/" +boot_wait = "90s" +EOF + +rm -r "${tmp}" +rm -f "cache/latest-nixos-minimal-x86_64-linux.iso" diff --git a/distros/nixos/24.05/finalize.sh b/distros/nixos/24.05/finalize.sh new file mode 100644 index 0000000..4cfad53 --- /dev/null +++ b/distros/nixos/24.05/finalize.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +set -ex diff --git a/distros/nixos/24.05/http/configuration.nix b/distros/nixos/24.05/http/configuration.nix new file mode 100644 index 0000000..2cc98aa --- /dev/null +++ b/distros/nixos/24.05/http/configuration.nix @@ -0,0 +1,67 @@ +{config, pkgs, lib, ...}: + +{ + imports = [ + ./hardware-configuration.nix + ./guest-agent.nix + ]; + + system.stateVersion = "24.05"; + + # Packages installed on the whole system + environment.systemPackages = with pkgs; [ + curl + nano + python3 + ]; + # Services that are running + services = { + openssh.enable = true; + #xserver.enable = true; + }; + # User setup + users.groups.vagrant = {}; + users.users.vagrant = { + isNormalUser = true; + group = "vagrant"; + extraGroups = [ "wheel" ]; + password = "vagrant"; + }; + security.sudo.extraRules = [ + { + users = [ "vagrant" ]; + groups = [ "vagrant" ]; + commands = [ + { command = "ALL"; options = [ "NOPASSWD" ]; } + ]; + } + ]; + + boot.loader = { + systemd-boot = { + enable = true; + }; + efi.canTouchEfiVariables = true; + }; + networking = { + hostName = "vagrant"; + networkmanager.enable = true; + #proxy.default = "http://user:password@proxy:port/"; + #proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + }; + time.timeZone = "UTC"; + + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminux16"; + keyMap = lib.mkForce "us"; + useXkbConfig = true; + }; + + nix = { + package = pkgs.nixFlakes; + settings = { + experimental-features = "nix-command flakes"; + }; + }; +} diff --git a/distros/nixos/24.05/http/flake.nix b/distros/nixos/24.05/http/flake.nix new file mode 100644 index 0000000..f8b0e18 --- /dev/null +++ b/distros/nixos/24.05/http/flake.nix @@ -0,0 +1,15 @@ +{ + description = "A basic NixOS Vagrant install"; + + inputs = { + nixstable.url = "github:nixos/nixpkgs/nixos-24.05"; + }; + + outputs = { nixstable, self, ... }@inputs: + { + nixosConfigurations.vagrant = nixstable.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ ./configuration.nix ]; + }; + }; +} diff --git a/distros/nixos/24.05/http/ga-kvm.nix b/distros/nixos/24.05/http/ga-kvm.nix new file mode 120000 index 0000000..15276b3 --- /dev/null +++ b/distros/nixos/24.05/http/ga-kvm.nix @@ -0,0 +1 @@ +ga-qemu.nix \ No newline at end of file diff --git a/distros/nixos/24.05/http/ga-microsoft.nix b/distros/nixos/24.05/http/ga-microsoft.nix new file mode 100644 index 0000000..a477797 --- /dev/null +++ b/distros/nixos/24.05/http/ga-microsoft.nix @@ -0,0 +1,4 @@ +{...}: +{ + virtualisation.hypervGuest.enable = true; +} \ No newline at end of file diff --git a/distros/nixos/24.05/http/ga-oracle.nix b/distros/nixos/24.05/http/ga-oracle.nix new file mode 100644 index 0000000..06bc077 --- /dev/null +++ b/distros/nixos/24.05/http/ga-oracle.nix @@ -0,0 +1,7 @@ +{...}: +{ + virtualisation.virtualbox.guest = { + enable = true; + x11 = false; + }; +} \ No newline at end of file diff --git a/distros/nixos/24.05/http/ga-qemu.nix b/distros/nixos/24.05/http/ga-qemu.nix new file mode 100644 index 0000000..7389b6d --- /dev/null +++ b/distros/nixos/24.05/http/ga-qemu.nix @@ -0,0 +1,4 @@ +{...}: +{ + services.qemuGuest.enable = true; +} \ No newline at end of file diff --git a/distros/nixos/24.05/http/ga-vmware.nix b/distros/nixos/24.05/http/ga-vmware.nix new file mode 100644 index 0000000..8599f81 --- /dev/null +++ b/distros/nixos/24.05/http/ga-vmware.nix @@ -0,0 +1,7 @@ +{...}: +{ + virtualisation.vmware.guest = { + enable = true; + headless = false; + } +} \ No newline at end of file diff --git a/distros/nixos/24.05/http/in-chroot.sh b/distros/nixos/24.05/http/in-chroot.sh new file mode 100644 index 0000000..60c21f1 --- /dev/null +++ b/distros/nixos/24.05/http/in-chroot.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -ex + +# Set passwords +echo "vagrant:vagrant" | chpasswd +echo "root:vagrant" | chpasswd + +# Set ownership of things vagrant should own +chown -R vagrant:vagrant ~vagrant/ +chown -R vagrant:wheel /etc/nixos diff --git a/distros/nixos/24.05/http/install.sh b/distros/nixos/24.05/http/install.sh new file mode 100644 index 0000000..abd1c6c --- /dev/null +++ b/distros/nixos/24.05/http/install.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +#vim: set ft=bash: +set -ex + +port="${1}" # HTTP port that packer is running on +host="${2}" + +if [ -e /dev/vda ]; then + disk="/dev/vda" +elif [ -e /dev/sda ]; then + disk="/dev/sda" +else + exit 1 # Need to teach the script which device to use in this case +fi + +# The sed bit is just to strip out the extra fluff, like comments +sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${disk} + g # create new GPT partition table + n # new + # default partition number + # default start + +512M # size + t # set type + 1 # EFI system partition + n # second partition + # default partition number + # start at first free sector + # default to full disk + p # print, for debugging + w # write the partition table and exit +EOF + +sleep 10 # Let me at least read it! + #t # set partition type + #1 # on partition 1 + #4 # BIOS boot + +# Format and mount partitions +mkfs.vfat "${disk}1" +mkfs.ext4 "${disk}2" + +mount "${disk}2" /mnt +mkdir -p /mnt/boot +mount "${disk}1" /mnt/boot + +# Bootstrap system +virt="$(systemd-detect-virt)" +nixos-generate-config --root /mnt +curl -o /mnt/etc/nixos/configuration.nix "http://${host}:${port}/configuration.nix" +curl -o /mnt/etc/nixos/flake.nix "http://${host}:${port}/flake.nix" +curl -o /mnt/etc/nixos/guest-agent.nix "http://${host}:${port}/ga-${virt}.nix" +sed -i -E -e "s,@BOOT_DEVICE@,${disk}," /mnt/etc/nixos/configuration.nix + +nixos-install --no-root-password --flake "/mnt/etc/nixos/#vagrant" + +# Run stuff in the chroot +curl -o /mnt/root/in-chroot.sh "http://${host}:${port}/in-chroot.sh" +nixos-enter --root /mnt -c 'bash /root/in-chroot.sh' +rm /mnt/root/in-chroot.sh + +umount /mnt/boot +umount /mnt +efibootmgr --bootnext "$(efibootmgr | grep Linux | awk '{print $1}' | sed -E 's/[^0-9]//g')" +reboot \ No newline at end of file diff --git a/distros/nixos/24.05/qemu.sh b/distros/nixos/24.05/qemu.sh new file mode 100644 index 0000000..087d718 --- /dev/null +++ b/distros/nixos/24.05/qemu.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +set -ex \ No newline at end of file diff --git a/distros/nixos/24.05/virtualbox.sh b/distros/nixos/24.05/virtualbox.sh new file mode 100644 index 0000000..087d718 --- /dev/null +++ b/distros/nixos/24.05/virtualbox.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +set -ex \ No newline at end of file diff --git a/distros/nixos/24.05/vmware.sh b/distros/nixos/24.05/vmware.sh new file mode 100644 index 0000000..087d718 --- /dev/null +++ b/distros/nixos/24.05/vmware.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +set -ex \ No newline at end of file diff --git a/distros/nixos/default.nix b/distros/nixos/default.nix index f9e89b8..e4294ff 100644 --- a/distros/nixos/default.nix +++ b/distros/nixos/default.nix @@ -6,4 +6,8 @@ version = "23.11"; arch = "amd64"; eol = false; +} { + version = "24.05"; + arch = "amd64"; + eol = false; } ] From f3c6cfe08deabdf166b01105d6ac3b0f0d777e64 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 30 Jun 2024 00:11:35 -0500 Subject: [PATCH 06/24] Update Archlinux boot disk --- distros/archlinux/rolling/amd64.pkrvars.hcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distros/archlinux/rolling/amd64.pkrvars.hcl b/distros/archlinux/rolling/amd64.pkrvars.hcl index 60f9fdb..5889869 100644 --- a/distros/archlinux/rolling/amd64.pkrvars.hcl +++ b/distros/archlinux/rolling/amd64.pkrvars.hcl @@ -1,8 +1,8 @@ distro = "archlinux" version = "rolling" iso = { - url = "http://mirror.rackspace.com/archlinux/iso/2024.04.01/archlinux-2024.04.01-x86_64.iso" - checksum = "52aea58f88c9a80afe64f0536da868251ef4878de5a5e0227fcada9f132bd7ab" + url = "http://mirror.rackspace.com/archlinux/iso/2024.06.01/archlinux-2024.06.01-x86_64.iso" + checksum = "4cc7e1c9f4e97b384f0d8731f317b5995bde256fcc17160d32359cab923c5892" } boot_command = [ "e net.ifnames=0 biosdevnames=0 console=ttyS0", From ad8d0c9bc46346d6838002f7dccac12a8f317752 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 30 Jun 2024 00:20:08 -0500 Subject: [PATCH 07/24] Update Alpine 3.19 to patch 2 --- distros/alpine/3.19.0/amd64.pkrvars.hcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distros/alpine/3.19.0/amd64.pkrvars.hcl b/distros/alpine/3.19.0/amd64.pkrvars.hcl index 894f4fd..b475795 100644 --- a/distros/alpine/3.19.0/amd64.pkrvars.hcl +++ b/distros/alpine/3.19.0/amd64.pkrvars.hcl @@ -1,8 +1,8 @@ distro = "alpine" version = "3.19.0" iso = { - url = "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-standard-3.19.0-x86_64.iso" - checksum = "4cf7cd3bad64122a8a2423e78369a486a02334d4d88645aab9d08120bb76b0f9" + url = "http://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-extended-3.19.2-x86_64.iso" + checksum = "508944822217be4c2c7b947a64220271055b1883a025e5cb351950b27f046a15" } boot_command = [ "root", From 42fabf124bb1fa62e74f6738c7dac006c9e6f73f Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 30 Jun 2024 00:20:12 -0500 Subject: [PATCH 08/24] Init Alpine 3.20 at patch 1 --- distros/alpine/3.20/amd64.pkrvars.hcl | 19 ++++++++ distros/alpine/3.20/finalize.sh | 2 + distros/alpine/3.20/http/answers.cfg.sh | 61 +++++++++++++++++++++++++ distros/alpine/3.20/http/in-chroot.sh | 57 +++++++++++++++++++++++ distros/alpine/3.20/qemu.sh | 2 + distros/alpine/3.20/virtualbox.sh | 2 + distros/alpine/3.20/vmware.sh | 4 ++ distros/alpine/default.nix | 4 ++ 8 files changed, 151 insertions(+) create mode 100644 distros/alpine/3.20/amd64.pkrvars.hcl create mode 100644 distros/alpine/3.20/finalize.sh create mode 100644 distros/alpine/3.20/http/answers.cfg.sh create mode 100644 distros/alpine/3.20/http/in-chroot.sh create mode 100644 distros/alpine/3.20/qemu.sh create mode 100644 distros/alpine/3.20/virtualbox.sh create mode 100644 distros/alpine/3.20/vmware.sh diff --git a/distros/alpine/3.20/amd64.pkrvars.hcl b/distros/alpine/3.20/amd64.pkrvars.hcl new file mode 100644 index 0000000..42369d8 --- /dev/null +++ b/distros/alpine/3.20/amd64.pkrvars.hcl @@ -0,0 +1,19 @@ +distro = "alpine" +version = "3.20" +iso = { + url = "http://dl-cdn.alpinelinux.org/alpine/v3.20/releases/x86_64/alpine-standard-3.20.1-x86_64.iso" + checksum = "c3043af6421b6e0ab22994b01d10785728888b37d976a754f12f23b42aecd95e" +} +boot_command = [ + "root", + "echo 'iface eth0 inet dhcp' > /etc/network/interfaces", + "ifup eth0", + "wget -O answers.cfg.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers.cfg.sh", + "", + "wget -O in-chroot.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/in-chroot.sh", + "", + "/bin/ash ./answers.cfg.sh 2>&1 | tee install.log", +] +http_directory = "distros/alpine/3.20/http/" +boot_wait = "20s" +shutdown_command = "sudo poweroff" diff --git a/distros/alpine/3.20/finalize.sh b/distros/alpine/3.20/finalize.sh new file mode 100644 index 0000000..5a01809 --- /dev/null +++ b/distros/alpine/3.20/finalize.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +set -ex \ No newline at end of file diff --git a/distros/alpine/3.20/http/answers.cfg.sh b/distros/alpine/3.20/http/answers.cfg.sh new file mode 100644 index 0000000..a430023 --- /dev/null +++ b/distros/alpine/3.20/http/answers.cfg.sh @@ -0,0 +1,61 @@ +#!/bin/ash +# shellcheck shell=dash + +set -ex -o pipefail + +if [ -e /dev/vda ]; then + disk="/dev/vda" +else + disk="/dev/sda" +fi + +cat << EOF > answers.cfg +KEYMAPOPTS="us us" + +HOSTNAMEOPTS="vagrant" + +DEVDOPTS=mdev + +INTERFACESOPTS="auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp +hostname vagrant.local" + +TIMEZONEOPTS="UTC" + +PROXYOPTS="none" + +# Add first CDN mirror +APKREPOSOPTS="-1" + +USEROPTS="-a -u -g audio,video,netdev vagrant" + +SSHDOPTS=openssh + +NTPOPTS=none + +DISKOPTS="-m sys ${disk}" + +LBUOPTS=none + +APKCACHEOPTS=none +EOF + +setup-alpine -e -f answers.cfg -q +yes y | setup-disk -m sys "${disk}" || true +# It isn't setting up disk in initial run, but +# it also can't setup disk before the rest of it +# is setup properly. There might be a better workaround +# but this is what I'm choosing to do +setup-alpine -e -f answers.cfg -q + +mount "${disk}3" /mnt +mount "${disk}1" /mnt/boot + +mv in-chroot.sh /mnt +for fs in proc sys dev sys/firmware/efi/efivars; do mount -o bind /${fs} /mnt/${fs}; done +chroot /mnt /bin/ash /in-chroot.sh +rm /mnt/in-chroot.sh +reboot \ No newline at end of file diff --git a/distros/alpine/3.20/http/in-chroot.sh b/distros/alpine/3.20/http/in-chroot.sh new file mode 100644 index 0000000..4300f7d --- /dev/null +++ b/distros/alpine/3.20/http/in-chroot.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env sh +set -ex + +# Enables packages like "sudo" +sed -i 's/#\(.*\/community\)/\1/' /etc/apk/repositories + +# Install bare minimal packages +apk add curl efibootmgr openssh sudo virt-what + +rc-update add sshd default + +# Configure systems +echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant-nopasswd +echo 'Defaults !requiretty' >> /etc/sudoers +sed -i 's/.*UseDNS.*/UseDNS no/' /etc/ssh/sshd_config +cat > /etc/ssh/sshd_config.d/10-vagrant-insecure-rsa-key.conf < Date: Sun, 30 Jun 2024 23:08:22 -0500 Subject: [PATCH 09/24] New Arch requires new command line --- distros/archlinux/rolling/amd64.pkrvars.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distros/archlinux/rolling/amd64.pkrvars.hcl b/distros/archlinux/rolling/amd64.pkrvars.hcl index 5889869..a2f8d6d 100644 --- a/distros/archlinux/rolling/amd64.pkrvars.hcl +++ b/distros/archlinux/rolling/amd64.pkrvars.hcl @@ -5,7 +5,7 @@ iso = { checksum = "4cc7e1c9f4e97b384f0d8731f317b5995bde256fcc17160d32359cab923c5892" } boot_command = [ - "e net.ifnames=0 biosdevnames=0 console=ttyS0", + "e net.ifnames=0 biosdevnames=0 console=ttyS0", "", # Wait for system to come up? "curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh", "", From caf4f4f5050cd360b9169cc35afcd963f472ead3 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 12 Jul 2024 18:57:21 -0500 Subject: [PATCH 10/24] Init on Windows --- .gitlab-ci-build.yml.in | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci-build.yml.in b/.gitlab-ci-build.yml.in index 74ee9d2..1891062 100644 --- a/.gitlab-ci-build.yml.in +++ b/.gitlab-ci-build.yml.in @@ -71,6 +71,7 @@ hyperv-iso.amd64: parallel: matrix: HYPERV_MATRIX script: + - packer init sources - echo $env:COMMAND > build.ps1 - echo 'if (-not $?) { throw "Error in build"}' >> build.ps1 - pwsh .\build.ps1 From b6461278751218179ba0a32be2680b28e97fdc6d Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 12 Jul 2024 21:15:01 -0500 Subject: [PATCH 11/24] Do better with URL folders --- nix/cache.nix | 5 +++-- sources/hyperv-iso.pkr.hcl | 2 +- sources/inputs.pkr.hcl | 1 + sources/qemu.pkr.hcl | 2 +- sources/virtualbox-iso.pkr.hcl | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nix/cache.nix b/nix/cache.nix index daadc80..4add151 100644 --- a/nix/cache.nix +++ b/nix/cache.nix @@ -29,11 +29,12 @@ in writeShellApplication { map (d: '' url=$(echo var.iso.url | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/) sha=$(echo var.iso.checksum | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/) + distro=$(echo var.distro | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/) # shellcheck disable=SC2143 - if [ -z "$(mc ls storage/isos/cache/ | grep "$sha")" ]; then + if [ -z "$(mc ls "storage/isos/cache/$distro" | grep "$sha")" ]; then curl -L --retry 3 --retry-all-errors -o "cache/$sha.iso" "$url" if [ "$push" == "yes" ]; then - mc put "cache/$sha.iso" "storage/isos/cache/$sha.iso" + mc put "cache/$sha.iso" "storage/isos/cache/$distro/$sha.iso" fi else echo "Skipping ${d.distro} - cache/$sha.iso" diff --git a/sources/hyperv-iso.pkr.hcl b/sources/hyperv-iso.pkr.hcl index 0ce8ff9..c0798ec 100644 --- a/sources/hyperv-iso.pkr.hcl +++ b/sources/hyperv-iso.pkr.hcl @@ -1,5 +1,5 @@ source "hyperv-iso" "amd64" { - iso_urls = [ "s3::${var.storage_url}/isos/cache/${var.iso.checksum}.iso?aws_access_key_id=root&aws_access_key_secret=${var.minio_secret}" ] + iso_urls = [ local.iso_location ] iso_target_path = "cache/${var.iso.checksum}.iso" iso_checksum = var.iso.checksum output_directory = "output/hyperv/${local.name}" diff --git a/sources/inputs.pkr.hcl b/sources/inputs.pkr.hcl index 7234a1d..864c2ac 100644 --- a/sources/inputs.pkr.hcl +++ b/sources/inputs.pkr.hcl @@ -127,6 +127,7 @@ locals { version = var.version build = var.build }) + iso_location = "s3::${var.storage_url}/isos/cache/${var.distro}/${var.iso.checksum}.iso?aws_access_key_id=root&aws_access_key_secret=${var.minio_secret}" cpus = var.cpus memory = var.memory diff --git a/sources/qemu.pkr.hcl b/sources/qemu.pkr.hcl index d1b82ee..e166897 100644 --- a/sources/qemu.pkr.hcl +++ b/sources/qemu.pkr.hcl @@ -4,7 +4,7 @@ variable "qemu_accelerator" { } source "qemu" "amd64" { - iso_urls = [ "s3::${var.storage_url}/isos/cache/${var.iso.checksum}.iso?aws_access_key_id=root&aws_access_key_secret=${var.minio_secret}" ] + iso_urls = [ local.iso_location ] iso_target_path = "cache/${var.iso.checksum}.iso" iso_checksum = var.iso.checksum output_directory = "output/libvirt/${local.name}" diff --git a/sources/virtualbox-iso.pkr.hcl b/sources/virtualbox-iso.pkr.hcl index e2c9a56..11a2b84 100644 --- a/sources/virtualbox-iso.pkr.hcl +++ b/sources/virtualbox-iso.pkr.hcl @@ -1,5 +1,5 @@ source "virtualbox-iso" "amd64" { - iso_urls = [ "s3::${var.storage_url}/isos/cache/${var.iso.checksum}.iso?aws_access_key_id=root&aws_access_key_secret=${var.minio_secret}" ] + iso_urls = [ local.iso_location ] iso_target_path = "cache/${var.iso.checksum}.iso" iso_checksum = var.iso.checksum output_directory = "output/virtualbox/${local.name}" From dc6a77049caedcfee5729da3e2524cbd8a087aac Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 12 Jul 2024 21:15:13 -0500 Subject: [PATCH 12/24] Update Centos 7 URL and Debian to 12.6.0 --- distros/centos/7/amd64.pkrvars.hcl | 2 +- distros/debian/12/amd64.pkrvars.hcl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/distros/centos/7/amd64.pkrvars.hcl b/distros/centos/7/amd64.pkrvars.hcl index 1926391..dea760c 100644 --- a/distros/centos/7/amd64.pkrvars.hcl +++ b/distros/centos/7/amd64.pkrvars.hcl @@ -1,7 +1,7 @@ distro = "centos" version = "7" iso = { - url = "http://mirror.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-NetInstall-2009.iso" + url = "http://vault.centos.org/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-NetInstall-2009.iso" checksum = "b79079ad71cc3c5ceb3561fff348a1b67ee37f71f4cddfec09480d4589c191d6" } boot_command = [ diff --git a/distros/debian/12/amd64.pkrvars.hcl b/distros/debian/12/amd64.pkrvars.hcl index 3278968..5396e4b 100644 --- a/distros/debian/12/amd64.pkrvars.hcl +++ b/distros/debian/12/amd64.pkrvars.hcl @@ -1,8 +1,8 @@ distro = "debian" version = "12" iso = { - url = "http://cdimage.debian.org/cdimage/release/12.5.0/amd64/iso-cd/debian-12.5.0-amd64-netinst.iso" - checksum = "013f5b44670d81280b5b1bc02455842b250df2f0c6763398feb69af1a805a14f" + url = "http://cdimage.debian.org/cdimage/release/12.6.0/amd64/iso-cd/debian-12.6.0-amd64-netinst.iso" + checksum = "ade3a4acc465f59ca2496344aab72455945f3277a52afc5a2cae88cdc370fa12" } boot_command = [ "e", From 6d29120dc594e1c9f04e7275916b97943dd51227 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 00:18:40 -0500 Subject: [PATCH 13/24] Get all the outputs --- distros/almalinux/9/amd64.pkrvars.hcl | 2 +- distros/centos-stream/9/amd64.pkrvars.hcl.sh | 2 +- distros/centos/7/disc/ks.cfg | 5 +++-- distros/centos/7/qemu.sh | 5 +++++ distros/debian/10/amd64.pkrvars.hcl | 2 +- distros/debian/11/amd64.pkrvars.hcl | 2 +- distros/debian/12/amd64.pkrvars.hcl | 2 +- distros/fedora/39/amd64.pkrvars.hcl | 2 +- distros/fedora/40/amd64.pkrvars.hcl | 2 +- distros/fedora/rawhide/amd64.pkrvars.hcl.sh | 2 +- distros/opensuse/15.5/amd64.pkrvars.hcl | 2 +- distros/opensuse/15.6/amd64.pkrvars.hcl | 2 +- distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh | 2 +- distros/rockylinux/9/amd64.pkrvars.hcl | 2 +- distros/ubuntu/20.04/amd64.pkrvars.hcl | 2 +- distros/ubuntu/22.04/amd64.pkrvars.hcl | 2 +- distros/ubuntu/23.10/amd64.pkrvars.hcl | 2 +- distros/ubuntu/24.04/amd64.pkrvars.hcl | 2 +- 18 files changed, 24 insertions(+), 18 deletions(-) diff --git a/distros/almalinux/9/amd64.pkrvars.hcl b/distros/almalinux/9/amd64.pkrvars.hcl index 235dc15..9489bc4 100644 --- a/distros/almalinux/9/amd64.pkrvars.hcl +++ b/distros/almalinux/9/amd64.pkrvars.hcl @@ -8,7 +8,7 @@ boot_command = [ "e", "", " inst.text inst.ks=cdrom:/ks.cfg", - " console=ttyS0 inst.notmux", + " console=tty0 console=ttyS0 inst.notmux", "x" ] cd_files = [ "distros/almalinux/9/disc/*" ] diff --git a/distros/centos-stream/9/amd64.pkrvars.hcl.sh b/distros/centos-stream/9/amd64.pkrvars.hcl.sh index 2e5c192..c157ac0 100755 --- a/distros/centos-stream/9/amd64.pkrvars.hcl.sh +++ b/distros/centos-stream/9/amd64.pkrvars.hcl.sh @@ -24,7 +24,7 @@ boot_command = [ "e", "", " inst.text inst.ks=cdrom:/ks.cfg", - " inst.notmux console=ttyS0", + " inst.notmux console=tty0 console=ttyS0", "x" ] cd_files = [ "distros/centos-stream/9/disc/*" ] diff --git a/distros/centos/7/disc/ks.cfg b/distros/centos/7/disc/ks.cfg index e68c971..c733dc7 100644 --- a/distros/centos/7/disc/ks.cfg +++ b/distros/centos/7/disc/ks.cfg @@ -2,8 +2,9 @@ install text reboot network --bootproto=dhcp --activate -url --url=http://mirror.centos.org/centos/7/os/x86_64/ -repo --name=updates --baseurl=http://mirror.centos.org/centos/7/updates/x86_64/ +url --url=http://vault.centos.org/7.9.2009/os/x86_64/ +repo --name=base --baseurl=http://vault.centos.org/7.9.2009/os/x86_64/ --install +repo --name=updates --baseurl=http://vault.centos.org/7.9.2009/updates/x86_64/ --install lang en_US.UTF-8 keyboard us timezone --utc Etc/UTC diff --git a/distros/centos/7/qemu.sh b/distros/centos/7/qemu.sh index 4082dc8..172ade2 100644 --- a/distros/centos/7/qemu.sh +++ b/distros/centos/7/qemu.sh @@ -1,6 +1,11 @@ #!/usr/bin/env bash set -ex +for f in /etc/yum.repos.d/*; do + echo "$f" + cat "$f" +done +cat /etc/yum.conf || true yum install -y qemu-guest-agent systemctl start qemu-guest-agent systemctl enable qemu-guest-agent diff --git a/distros/debian/10/amd64.pkrvars.hcl b/distros/debian/10/amd64.pkrvars.hcl index 94d2556..815a454 100644 --- a/distros/debian/10/amd64.pkrvars.hcl +++ b/distros/debian/10/amd64.pkrvars.hcl @@ -16,7 +16,7 @@ boot_command = [ "debconf/frontend=noninteractive ", "hostname={{.Name}} ", "domain=vagrant ", - "console=ttyS0 ", + "console=tty0 console=ttyS0 ", "" ] http_directory = "distros/debian/10/http/" diff --git a/distros/debian/11/amd64.pkrvars.hcl b/distros/debian/11/amd64.pkrvars.hcl index e93396e..b7ebe65 100644 --- a/distros/debian/11/amd64.pkrvars.hcl +++ b/distros/debian/11/amd64.pkrvars.hcl @@ -16,7 +16,7 @@ boot_command = [ "debconf/frontend=noninteractive ", "hostname={{.Name}} ", "domain=vagrant ", - "console=ttyS0 ", + "console=tty0 console=ttyS0 ", "" ] http_directory = "distros/debian/11/http/" diff --git a/distros/debian/12/amd64.pkrvars.hcl b/distros/debian/12/amd64.pkrvars.hcl index 5396e4b..1151d42 100644 --- a/distros/debian/12/amd64.pkrvars.hcl +++ b/distros/debian/12/amd64.pkrvars.hcl @@ -16,7 +16,7 @@ boot_command = [ "debconf/frontend=noninteractive ", "hostname={{.Name}} ", "domain=vagrant ", - "console=ttyS0 ", + "console=tty0 console=ttyS0 ", "" ] http_directory = "distros/debian/12/http/" diff --git a/distros/fedora/39/amd64.pkrvars.hcl b/distros/fedora/39/amd64.pkrvars.hcl index 6c3821c..5405397 100644 --- a/distros/fedora/39/amd64.pkrvars.hcl +++ b/distros/fedora/39/amd64.pkrvars.hcl @@ -6,7 +6,7 @@ iso = { } boot_command = [ "e ", - "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux console=ttyS0" + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux console=tty0 console=ttyS0" ] cd_files = [ "distros/fedora/39/*.cfg" diff --git a/distros/fedora/40/amd64.pkrvars.hcl b/distros/fedora/40/amd64.pkrvars.hcl index 76fd884..0397e18 100644 --- a/distros/fedora/40/amd64.pkrvars.hcl +++ b/distros/fedora/40/amd64.pkrvars.hcl @@ -6,7 +6,7 @@ iso = { } boot_command = [ "e ", - "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux console=ttyS0" + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux console=tty0 console=ttyS0" ] cd_files = [ "distros/fedora/40/*.cfg" diff --git a/distros/fedora/rawhide/amd64.pkrvars.hcl.sh b/distros/fedora/rawhide/amd64.pkrvars.hcl.sh index fa06d83..1a1df58 100755 --- a/distros/fedora/rawhide/amd64.pkrvars.hcl.sh +++ b/distros/fedora/rawhide/amd64.pkrvars.hcl.sh @@ -35,7 +35,7 @@ iso = { } boot_command = [ "e", - "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux console=ttyS0" + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux console=tty0 console=ttyS0" ] cd_files = [ "distros/fedora/rawhide/*.cfg" diff --git a/distros/opensuse/15.5/amd64.pkrvars.hcl b/distros/opensuse/15.5/amd64.pkrvars.hcl index 63a8629..a6ec4f0 100644 --- a/distros/opensuse/15.5/amd64.pkrvars.hcl +++ b/distros/opensuse/15.5/amd64.pkrvars.hcl @@ -9,7 +9,7 @@ boot_command = [ "", "", " autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinst.xml textmode=1", - " console=ttyS0", + " console=tty0 console=ttyS0", "x" ] http_directory = "distros/opensuse/15.5/http/" diff --git a/distros/opensuse/15.6/amd64.pkrvars.hcl b/distros/opensuse/15.6/amd64.pkrvars.hcl index f738b6a..f1473bb 100644 --- a/distros/opensuse/15.6/amd64.pkrvars.hcl +++ b/distros/opensuse/15.6/amd64.pkrvars.hcl @@ -9,7 +9,7 @@ boot_command = [ "", "", " autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinst.xml textmode=1", - " console=ttyS0", + " console=tty0 console=ttyS0", "x" ] http_directory = "distros/opensuse/15.6/http/" diff --git a/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh b/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh index 9a6fe9c..5556d39 100755 --- a/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh +++ b/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh @@ -26,7 +26,7 @@ boot_command = [ "e", "", " autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinst.xml textmode=1", - " console=ttyS0", + " console=tty0 console=ttyS0", "x" ] http_directory = "distros/opensuse/tumbleweed/http/" diff --git a/distros/rockylinux/9/amd64.pkrvars.hcl b/distros/rockylinux/9/amd64.pkrvars.hcl index 12da5e9..0a8e9ce 100644 --- a/distros/rockylinux/9/amd64.pkrvars.hcl +++ b/distros/rockylinux/9/amd64.pkrvars.hcl @@ -8,7 +8,7 @@ boot_command = [ "e", "", " inst.text inst.ks=cdrom:/ks.cfg", - " inst.notmux console=ttyS0", + " inst.notmux console=tty0 console=ttyS0", "x" ] cd_files = [ "distros/rockylinux/9/disc/*" ] diff --git a/distros/ubuntu/20.04/amd64.pkrvars.hcl b/distros/ubuntu/20.04/amd64.pkrvars.hcl index a95048e..862528b 100644 --- a/distros/ubuntu/20.04/amd64.pkrvars.hcl +++ b/distros/ubuntu/20.04/amd64.pkrvars.hcl @@ -7,7 +7,7 @@ iso = { boot_wait = "3s" boot_command = [ "e", - "console=ttyS0 ", + "console=tty0 console=ttyS0 ", "fsck.mode=skip ", "locale=en_US ", "auto=true ", diff --git a/distros/ubuntu/22.04/amd64.pkrvars.hcl b/distros/ubuntu/22.04/amd64.pkrvars.hcl index 51baf9b..71baada 100644 --- a/distros/ubuntu/22.04/amd64.pkrvars.hcl +++ b/distros/ubuntu/22.04/amd64.pkrvars.hcl @@ -6,7 +6,7 @@ iso = { } boot_command = [ "e", - "console=ttyS0 ", + "console=tty0 console=ttyS0 ", "fsck.mode=skip ", "locale=en_US ", "auto=true ", diff --git a/distros/ubuntu/23.10/amd64.pkrvars.hcl b/distros/ubuntu/23.10/amd64.pkrvars.hcl index 59d3759..ec5718a 100644 --- a/distros/ubuntu/23.10/amd64.pkrvars.hcl +++ b/distros/ubuntu/23.10/amd64.pkrvars.hcl @@ -6,7 +6,7 @@ iso = { } boot_command = [ "e", - "console=ttyS0 ", + "console=tty0 console=ttyS0 ", "fsck.mode=skip ", "locale=en_US ", "auto=true ", diff --git a/distros/ubuntu/24.04/amd64.pkrvars.hcl b/distros/ubuntu/24.04/amd64.pkrvars.hcl index b1feba3..bbcd42d 100644 --- a/distros/ubuntu/24.04/amd64.pkrvars.hcl +++ b/distros/ubuntu/24.04/amd64.pkrvars.hcl @@ -6,7 +6,7 @@ iso = { } boot_command = [ "e", - "console=ttyS0 ", + "console=tty0 console=ttyS0 ", "fsck.mode=skip ", "locale=en_US ", "auto=true ", From b8029ab985d747770c58d38488312a964e669809 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 01:03:58 -0500 Subject: [PATCH 14/24] Make CentOS 7 build after EOL --- distros/centos/7/disc/ks.cfg | 5 +++++ distros/centos/7/qemu.sh | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/distros/centos/7/disc/ks.cfg b/distros/centos/7/disc/ks.cfg index c733dc7..8da018b 100644 --- a/distros/centos/7/disc/ks.cfg +++ b/distros/centos/7/disc/ks.cfg @@ -43,6 +43,11 @@ nmcli c %end %post --erroronfail + +echo "gpgkey=https://vault.centos.org/7.9.2009/os/x86_64/RPM-GPG-KEY-CentOS-7" >> /etc/yum.repos.d/base.repo +echo "gpgkey=https://vault.centos.org/7.9.2009/os/x86_64/RPM-GPG-KEY-CentOS-7" >> /etc/yum.repos.d/updates.repo +rm -f /etc/yum.repos.d/CentOS* + yum -y update cat < /etc/sudoers.d/vagrant diff --git a/distros/centos/7/qemu.sh b/distros/centos/7/qemu.sh index 172ade2..4082dc8 100644 --- a/distros/centos/7/qemu.sh +++ b/distros/centos/7/qemu.sh @@ -1,11 +1,6 @@ #!/usr/bin/env bash set -ex -for f in /etc/yum.repos.d/*; do - echo "$f" - cat "$f" -done -cat /etc/yum.conf || true yum install -y qemu-guest-agent systemctl start qemu-guest-agent systemctl enable qemu-guest-agent From f74011333b38c1db59e1230b48db0886f0e672be Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 01:33:27 -0500 Subject: [PATCH 15/24] No, do not do serial console --- distros/almalinux/9/amd64.pkrvars.hcl | 2 +- distros/archlinux/rolling/amd64.pkrvars.hcl | 2 +- distros/centos-stream/9/amd64.pkrvars.hcl.sh | 2 +- distros/centos/7/amd64.pkrvars.hcl | 2 +- distros/debian/10/amd64.pkrvars.hcl | 1 - distros/debian/11/amd64.pkrvars.hcl | 1 - distros/debian/12/amd64.pkrvars.hcl | 1 - distros/fedora/39/amd64.pkrvars.hcl | 2 +- distros/fedora/40/amd64.pkrvars.hcl | 2 +- distros/fedora/rawhide/amd64.pkrvars.hcl.sh | 2 +- distros/nixos/24.05/http/ga-oracle.nix | 3 +-- distros/opensuse/15.5/amd64.pkrvars.hcl | 1 - distros/opensuse/15.6/amd64.pkrvars.hcl | 1 - distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh | 1 - distros/rockylinux/9/amd64.pkrvars.hcl | 2 +- distros/ubuntu/20.04/amd64.pkrvars.hcl | 1 - distros/ubuntu/22.04/amd64.pkrvars.hcl | 1 - distros/ubuntu/23.10/amd64.pkrvars.hcl | 1 - distros/ubuntu/24.04/amd64.pkrvars.hcl | 1 - 19 files changed, 9 insertions(+), 20 deletions(-) diff --git a/distros/almalinux/9/amd64.pkrvars.hcl b/distros/almalinux/9/amd64.pkrvars.hcl index 9489bc4..d499e7d 100644 --- a/distros/almalinux/9/amd64.pkrvars.hcl +++ b/distros/almalinux/9/amd64.pkrvars.hcl @@ -8,7 +8,7 @@ boot_command = [ "e", "", " inst.text inst.ks=cdrom:/ks.cfg", - " console=tty0 console=ttyS0 inst.notmux", + " inst.notmux", "x" ] cd_files = [ "distros/almalinux/9/disc/*" ] diff --git a/distros/archlinux/rolling/amd64.pkrvars.hcl b/distros/archlinux/rolling/amd64.pkrvars.hcl index a2f8d6d..f825524 100644 --- a/distros/archlinux/rolling/amd64.pkrvars.hcl +++ b/distros/archlinux/rolling/amd64.pkrvars.hcl @@ -5,7 +5,7 @@ iso = { checksum = "4cc7e1c9f4e97b384f0d8731f317b5995bde256fcc17160d32359cab923c5892" } boot_command = [ - "e net.ifnames=0 biosdevnames=0 console=ttyS0", + "e net.ifnames=0 biosdevnames=0 ", "", # Wait for system to come up? "curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh", "", diff --git a/distros/centos-stream/9/amd64.pkrvars.hcl.sh b/distros/centos-stream/9/amd64.pkrvars.hcl.sh index c157ac0..336417d 100755 --- a/distros/centos-stream/9/amd64.pkrvars.hcl.sh +++ b/distros/centos-stream/9/amd64.pkrvars.hcl.sh @@ -24,7 +24,7 @@ boot_command = [ "e", "", " inst.text inst.ks=cdrom:/ks.cfg", - " inst.notmux console=tty0 console=ttyS0", + " inst.notmux ", "x" ] cd_files = [ "distros/centos-stream/9/disc/*" ] diff --git a/distros/centos/7/amd64.pkrvars.hcl b/distros/centos/7/amd64.pkrvars.hcl index dea760c..c81d3bc 100644 --- a/distros/centos/7/amd64.pkrvars.hcl +++ b/distros/centos/7/amd64.pkrvars.hcl @@ -8,7 +8,7 @@ boot_command = [ "e", "", " inst.ks=cdrom:/ks.cfg", - " inst.notmux console=ttyS0", + " inst.notmux ", "x" ] cd_files = ["distros/centos/7/disc/*"] diff --git a/distros/debian/10/amd64.pkrvars.hcl b/distros/debian/10/amd64.pkrvars.hcl index 815a454..7a1aeb1 100644 --- a/distros/debian/10/amd64.pkrvars.hcl +++ b/distros/debian/10/amd64.pkrvars.hcl @@ -16,7 +16,6 @@ boot_command = [ "debconf/frontend=noninteractive ", "hostname={{.Name}} ", "domain=vagrant ", - "console=tty0 console=ttyS0 ", "" ] http_directory = "distros/debian/10/http/" diff --git a/distros/debian/11/amd64.pkrvars.hcl b/distros/debian/11/amd64.pkrvars.hcl index b7ebe65..795b6cb 100644 --- a/distros/debian/11/amd64.pkrvars.hcl +++ b/distros/debian/11/amd64.pkrvars.hcl @@ -16,7 +16,6 @@ boot_command = [ "debconf/frontend=noninteractive ", "hostname={{.Name}} ", "domain=vagrant ", - "console=tty0 console=ttyS0 ", "" ] http_directory = "distros/debian/11/http/" diff --git a/distros/debian/12/amd64.pkrvars.hcl b/distros/debian/12/amd64.pkrvars.hcl index 1151d42..e77c0b5 100644 --- a/distros/debian/12/amd64.pkrvars.hcl +++ b/distros/debian/12/amd64.pkrvars.hcl @@ -16,7 +16,6 @@ boot_command = [ "debconf/frontend=noninteractive ", "hostname={{.Name}} ", "domain=vagrant ", - "console=tty0 console=ttyS0 ", "" ] http_directory = "distros/debian/12/http/" diff --git a/distros/fedora/39/amd64.pkrvars.hcl b/distros/fedora/39/amd64.pkrvars.hcl index 5405397..b7be6a1 100644 --- a/distros/fedora/39/amd64.pkrvars.hcl +++ b/distros/fedora/39/amd64.pkrvars.hcl @@ -6,7 +6,7 @@ iso = { } boot_command = [ "e ", - "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux console=tty0 console=ttyS0" + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux " ] cd_files = [ "distros/fedora/39/*.cfg" diff --git a/distros/fedora/40/amd64.pkrvars.hcl b/distros/fedora/40/amd64.pkrvars.hcl index 0397e18..a2e322a 100644 --- a/distros/fedora/40/amd64.pkrvars.hcl +++ b/distros/fedora/40/amd64.pkrvars.hcl @@ -6,7 +6,7 @@ iso = { } boot_command = [ "e ", - "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux console=tty0 console=ttyS0" + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux " ] cd_files = [ "distros/fedora/40/*.cfg" diff --git a/distros/fedora/rawhide/amd64.pkrvars.hcl.sh b/distros/fedora/rawhide/amd64.pkrvars.hcl.sh index 1a1df58..a6be8b2 100755 --- a/distros/fedora/rawhide/amd64.pkrvars.hcl.sh +++ b/distros/fedora/rawhide/amd64.pkrvars.hcl.sh @@ -35,7 +35,7 @@ iso = { } boot_command = [ "e", - "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux console=tty0 console=ttyS0" + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg inst.notmux " ] cd_files = [ "distros/fedora/rawhide/*.cfg" diff --git a/distros/nixos/24.05/http/ga-oracle.nix b/distros/nixos/24.05/http/ga-oracle.nix index 06bc077..6f304b0 100644 --- a/distros/nixos/24.05/http/ga-oracle.nix +++ b/distros/nixos/24.05/http/ga-oracle.nix @@ -2,6 +2,5 @@ { virtualisation.virtualbox.guest = { enable = true; - x11 = false; }; -} \ No newline at end of file +} diff --git a/distros/opensuse/15.5/amd64.pkrvars.hcl b/distros/opensuse/15.5/amd64.pkrvars.hcl index a6ec4f0..4132d37 100644 --- a/distros/opensuse/15.5/amd64.pkrvars.hcl +++ b/distros/opensuse/15.5/amd64.pkrvars.hcl @@ -9,7 +9,6 @@ boot_command = [ "", "", " autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinst.xml textmode=1", - " console=tty0 console=ttyS0", "x" ] http_directory = "distros/opensuse/15.5/http/" diff --git a/distros/opensuse/15.6/amd64.pkrvars.hcl b/distros/opensuse/15.6/amd64.pkrvars.hcl index f1473bb..0032d71 100644 --- a/distros/opensuse/15.6/amd64.pkrvars.hcl +++ b/distros/opensuse/15.6/amd64.pkrvars.hcl @@ -9,7 +9,6 @@ boot_command = [ "", "", " autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinst.xml textmode=1", - " console=tty0 console=ttyS0", "x" ] http_directory = "distros/opensuse/15.6/http/" diff --git a/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh b/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh index 5556d39..191c91b 100755 --- a/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh +++ b/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh @@ -26,7 +26,6 @@ boot_command = [ "e", "", " autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinst.xml textmode=1", - " console=tty0 console=ttyS0", "x" ] http_directory = "distros/opensuse/tumbleweed/http/" diff --git a/distros/rockylinux/9/amd64.pkrvars.hcl b/distros/rockylinux/9/amd64.pkrvars.hcl index 0a8e9ce..3d7f316 100644 --- a/distros/rockylinux/9/amd64.pkrvars.hcl +++ b/distros/rockylinux/9/amd64.pkrvars.hcl @@ -8,7 +8,7 @@ boot_command = [ "e", "", " inst.text inst.ks=cdrom:/ks.cfg", - " inst.notmux console=tty0 console=ttyS0", + " inst.notmux ", "x" ] cd_files = [ "distros/rockylinux/9/disc/*" ] diff --git a/distros/ubuntu/20.04/amd64.pkrvars.hcl b/distros/ubuntu/20.04/amd64.pkrvars.hcl index 862528b..406e681 100644 --- a/distros/ubuntu/20.04/amd64.pkrvars.hcl +++ b/distros/ubuntu/20.04/amd64.pkrvars.hcl @@ -7,7 +7,6 @@ iso = { boot_wait = "3s" boot_command = [ "e", - "console=tty0 console=ttyS0 ", "fsck.mode=skip ", "locale=en_US ", "auto=true ", diff --git a/distros/ubuntu/22.04/amd64.pkrvars.hcl b/distros/ubuntu/22.04/amd64.pkrvars.hcl index 71baada..e4f5b04 100644 --- a/distros/ubuntu/22.04/amd64.pkrvars.hcl +++ b/distros/ubuntu/22.04/amd64.pkrvars.hcl @@ -6,7 +6,6 @@ iso = { } boot_command = [ "e", - "console=tty0 console=ttyS0 ", "fsck.mode=skip ", "locale=en_US ", "auto=true ", diff --git a/distros/ubuntu/23.10/amd64.pkrvars.hcl b/distros/ubuntu/23.10/amd64.pkrvars.hcl index ec5718a..00aeb9b 100644 --- a/distros/ubuntu/23.10/amd64.pkrvars.hcl +++ b/distros/ubuntu/23.10/amd64.pkrvars.hcl @@ -6,7 +6,6 @@ iso = { } boot_command = [ "e", - "console=tty0 console=ttyS0 ", "fsck.mode=skip ", "locale=en_US ", "auto=true ", diff --git a/distros/ubuntu/24.04/amd64.pkrvars.hcl b/distros/ubuntu/24.04/amd64.pkrvars.hcl index bbcd42d..e99de25 100644 --- a/distros/ubuntu/24.04/amd64.pkrvars.hcl +++ b/distros/ubuntu/24.04/amd64.pkrvars.hcl @@ -6,7 +6,6 @@ iso = { } boot_command = [ "e", - "console=tty0 console=ttyS0 ", "fsck.mode=skip ", "locale=en_US ", "auto=true ", From 7c956c9d33b514864cb890a6dbd52d665e20ca9b Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 01:39:48 -0500 Subject: [PATCH 16/24] Move validate to a different file --- flake.nix | 14 +------------- nix/validate.nix | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 nix/validate.nix diff --git a/flake.nix b/flake.nix index 0febf82..0e65b30 100644 --- a/flake.nix +++ b/flake.nix @@ -123,6 +123,7 @@ (builtins.readFile ./.gitlab-ci-build.yml.in) ); cache = pkgs.callPackage (import ./nix/cache.nix) { inherit active distroFile; }; + validate = pkgs.callPackage (import ./nix/validate.nix) {}; cache-restore = pkgs.writeShellApplication { name = "cache-restore"; runtimeInputs = with pkgs; [ @@ -161,19 +162,6 @@ shellcheck -e SC2239 "''${scripts[@]}" ''; }; - validate = pkgs.writeShellApplication { - name = "validate"; - runtimeInputs = with pkgs; [ - packer - ]; - text = '' - shopt -s globstar - packer init sources - for vars in distros/**/*.pkrvars.hcl; do - packer validate -except=upload "-var-file=''${vars}" sources/ - done - ''; - }; }; # https://numtide.github.io/treefmt/ diff --git a/nix/validate.nix b/nix/validate.nix new file mode 100644 index 0000000..4159f80 --- /dev/null +++ b/nix/validate.nix @@ -0,0 +1,18 @@ +{ + writeShellApplication, + packer, + ... +}: +writeShellApplication { + name = "validate"; + runtimeInputs = [ + packer + ]; + text = '' + shopt -s globstar + packer init sources + for vars in distros/**/*.pkrvars.hcl; do + packer validate -except=upload "-var-file=''${vars}" sources/ + done + ''; +} From 41e1f3ae03f5a7fd034223258f45841467e79371 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 01:46:48 -0500 Subject: [PATCH 17/24] Why is it failing now? --- nix/validate.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nix/validate.nix b/nix/validate.nix index 4159f80..579a7af 100644 --- a/nix/validate.nix +++ b/nix/validate.nix @@ -10,7 +10,9 @@ writeShellApplication { ]; text = '' shopt -s globstar + export PACKER_LOG=1 packer init sources + unset PACKER_LOG for vars in distros/**/*.pkrvars.hcl; do packer validate -except=upload "-var-file=''${vars}" sources/ done From 6ae06cee50f292a5085c18c1f01359510e5b8959 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 01:56:23 -0500 Subject: [PATCH 18/24] Bump versions for plugins --- nix/validate.nix | 2 -- sources/build.pkr.hcl | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/nix/validate.nix b/nix/validate.nix index 579a7af..4159f80 100644 --- a/nix/validate.nix +++ b/nix/validate.nix @@ -10,9 +10,7 @@ writeShellApplication { ]; text = '' shopt -s globstar - export PACKER_LOG=1 packer init sources - unset PACKER_LOG for vars in distros/**/*.pkrvars.hcl; do packer validate -except=upload "-var-file=''${vars}" sources/ done diff --git a/sources/build.pkr.hcl b/sources/build.pkr.hcl index 653f54f..69dd485 100644 --- a/sources/build.pkr.hcl +++ b/sources/build.pkr.hcl @@ -2,11 +2,11 @@ packer { required_plugins { qemu = { source = "github.com/hashicorp/qemu" - version = "= 1.0.10" + version = "= 1.1.0" } vagrant = { source = "github.com/hashicorp/vagrant" - version = "= 1.1.1" + version = "= 1.1.4" } vmware = { version = "= 1.0.11" From e5b04d9b2124c9a07328c487f61ebe404241f13d Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 02:43:44 -0500 Subject: [PATCH 19/24] Set plugins executable --- .gitlab-ci-build.yml.in | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci-build.yml.in b/.gitlab-ci-build.yml.in index 1891062..4a13b3a 100644 --- a/.gitlab-ci-build.yml.in +++ b/.gitlab-ci-build.yml.in @@ -40,6 +40,7 @@ stages: ${EXCEPT} sources script: + - find "${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" - packer init sources - echo $COMMAND > build.sh - bash build.sh || exit 1 From bfae3e985406f0e33df222a5a5a89dcd00a4d6c0 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 02:45:05 -0500 Subject: [PATCH 20/24] Also do it here --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ce6a85..ce8d844 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,6 +45,8 @@ validate: - sources/build.pkr.hcl paths: - ./packer_config/ + before_script: + - find "${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" script: nix run ".#validate" # Makes sure that all of the ISO files we are looking for are From 4dd414cc099452e954bfb26b2efc310befae506f Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 03:03:14 -0500 Subject: [PATCH 21/24] Use nix to do builds --- .gitlab-ci-build.yml.in | 21 +++++++++------------ .gitlab-ci.yml | 2 -- flake.lock | 6 +++--- flake.nix | 8 ++++++-- nix/validate.nix | 3 +++ 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci-build.yml.in b/.gitlab-ci-build.yml.in index 4a13b3a..32c6f12 100644 --- a/.gitlab-ci-build.yml.in +++ b/.gitlab-ci-build.yml.in @@ -31,19 +31,8 @@ stages: PACKER_CONFIG_DIR: ./packer_config/ PACKER_CACHE_DIR: ./cache/ PACKER_LOG: 1 - COMMAND: > - packer build ${only} - -var-file="${distro}" - -var build=${BUILD} - -var cpus=2 - -var memory=4096 - ${EXCEPT} - sources script: - - find "${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" - - packer init sources - - echo $COMMAND > build.sh - - bash build.sh || exit 1 + - nix run ".#${buildcmd}" || exit 1 qemu.amd64: extends: .build @@ -69,6 +58,14 @@ hyperv-iso.amd64: <<: *variables only: '-only="hyperv-iso.amd64"' tag: hyperv + COMMAND: > + packer build ${only} + -var-file="${distro}" + -var build=${BUILD} + -var cpus=2 + -var memory=4096 + ${EXCEPT} + sources parallel: matrix: HYPERV_MATRIX script: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ce8d844..5ce6a85 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,8 +45,6 @@ validate: - sources/build.pkr.hcl paths: - ./packer_config/ - before_script: - - find "${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" script: nix run ".#validate" # Makes sure that all of the ISO files we are looking for are diff --git a/flake.lock b/flake.lock index 45463b6..4e87450 100644 --- a/flake.lock +++ b/flake.lock @@ -100,11 +100,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1718870667, - "narHash": "sha256-jab3Kpc8O1z3qxwVsCMHL4+18n5Wy/HHKyu1fcsF7gs=", + "lastModified": 1720750130, + "narHash": "sha256-y2wc7CdK0vVSIbx7MdVoZzuMcUoLvZXm+pQf2RIr1OU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9b10b8f00cb5494795e5f51b39210fed4d2b0748", + "rev": "6794d064edc69918bb0fc0e0eda33ece324be17a", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 0e65b30..c06936e 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,9 @@ name = d: "-${d.distro}-${d.arch}-${d.provider}-${d.version}"; distroFile = d: "distros/${d.distro}/${d.version}/${d.arch}.pkrvars.hcl"; cmd = d: '' + # This is a workaround for a goofy behavior in CI + find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" + packer init sources version="''${1:-1}" packer build -var "build=$version" -only=${d.provider}.${d.arch} -var-file=${distroFile d}''; in flake-parts.lib.mkFlake { inherit inputs; } @@ -88,6 +91,7 @@ base = { runtimeInputs = with pkgs; [ packer + findutils qemu_full vagrant ]; @@ -114,8 +118,8 @@ }); builds = lib.lists.foldr (d: acc: acc // { "build${name d}" = (build d); }) {} withProviders; uploads = lib.lists.foldr (d: acc: acc // { "upload${name d}" = (upload d); }) {} withProviders; - qemu_list = builtins.toJSON (builtins.map (d: { distro = distroFile d; }) (builtins.filter (x: x.provider == "qemu") active)); - vbox_list = builtins.toJSON (builtins.map (d: { distro = distroFile d; }) (builtins.filter (x: x.provider == "virtualbox-iso") active)); + qemu_list = builtins.toJSON (builtins.map (d: { buildcmd = "build${name d}"; }) (builtins.filter (x: x.provider == "qemu") active)); + vbox_list = builtins.toJSON (builtins.map (d: { buildcmd = "build${name d}"; }) (builtins.filter (x: x.provider == "virtualbox-iso") active)); hyperv_list = builtins.toJSON (builtins.map (d: { distro = distroFile d; }) (builtins.filter (x: x.provider == "hyperv-iso") active)); in builds // uploads // { continue = pkgs.writeText "continue.yml" diff --git a/nix/validate.nix b/nix/validate.nix index 4159f80..13b9224 100644 --- a/nix/validate.nix +++ b/nix/validate.nix @@ -1,15 +1,18 @@ { writeShellApplication, + findutils, packer, ... }: writeShellApplication { name = "validate"; runtimeInputs = [ + findutils packer ]; text = '' shopt -s globstar + find "${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" packer init sources for vars in distros/**/*.pkrvars.hcl; do packer validate -except=upload "-var-file=''${vars}" sources/ From 23746f066066fdd95d4ddc891bc1be641a6a5cf8 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 03:16:34 -0500 Subject: [PATCH 22/24] Fix variable syntax --- nix/validate.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/validate.nix b/nix/validate.nix index 13b9224..464fd1e 100644 --- a/nix/validate.nix +++ b/nix/validate.nix @@ -12,7 +12,7 @@ writeShellApplication { ]; text = '' shopt -s globstar - find "${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" + find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" packer init sources for vars in distros/**/*.pkrvars.hcl; do packer validate -except=upload "-var-file=''${vars}" sources/ From b716298d3f146fd45a60a6fea6f6737b40793818 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 03:22:30 -0500 Subject: [PATCH 23/24] Escape dots --- .gitlab-ci-build.yml.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci-build.yml.in b/.gitlab-ci-build.yml.in index 32c6f12..2849ac3 100644 --- a/.gitlab-ci-build.yml.in +++ b/.gitlab-ci-build.yml.in @@ -32,7 +32,7 @@ stages: PACKER_CACHE_DIR: ./cache/ PACKER_LOG: 1 script: - - nix run ".#${buildcmd}" || exit 1 + - nix run ".#\"${buildcmd}\"" || exit 1 qemu.amd64: extends: .build From 66814c42820469770ac8701309a0c721d1711a58 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Jul 2024 03:31:10 -0500 Subject: [PATCH 24/24] Add ci build for CI tasks --- .gitignore | 1 + flake.nix | 29 +++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index bbe3246..c51599b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ isolinux.cfg Vagrantfile .direnv result +packer_config/ # Generated distros distros/fedora/rawhide/*.hcl diff --git a/flake.nix b/flake.nix index c06936e..4912db9 100644 --- a/flake.nix +++ b/flake.nix @@ -31,7 +31,9 @@ distroFile = d: "distros/${d.distro}/${d.version}/${d.arch}.pkrvars.hcl"; cmd = d: '' # This is a workaround for a goofy behavior in CI - find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" + if [ -e "''${PACKER_CONFIG_DIR}" ]; then + find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" + fi packer init sources version="''${1:-1}" packer build -var "build=$version" -only=${d.provider}.${d.arch} -var-file=${distroFile d}''; @@ -83,7 +85,10 @@ env = [{ name = "EFI_DIR"; value = "${pkgs.OVMF.fd}/FV/"; - }]; + } { + name = "PACKER_CONFIG_DIR"; + value = "./packer_config"; + } ]; }; # This is not special, this is just flakes @@ -109,19 +114,27 @@ vagrant box add --provider ${vp d} ./output/${vp d}/${d.distro}-${d.version}.box --name test_box --force ''; }); + cibuild = d: pkgs.writeShellApplication (base // { + name = "ci${name d}"; + text = '' + set -x + ${cmd d} -except=upload sources/ + ''; + }); upload = d: pkgs.writeShellApplication (base // { name = "upload${name d}"; text = '' - set -x - ${cmd d} sources/ + set -x + ${cmd d} sources/ ''; - }); + }); builds = lib.lists.foldr (d: acc: acc // { "build${name d}" = (build d); }) {} withProviders; uploads = lib.lists.foldr (d: acc: acc // { "upload${name d}" = (upload d); }) {} withProviders; - qemu_list = builtins.toJSON (builtins.map (d: { buildcmd = "build${name d}"; }) (builtins.filter (x: x.provider == "qemu") active)); - vbox_list = builtins.toJSON (builtins.map (d: { buildcmd = "build${name d}"; }) (builtins.filter (x: x.provider == "virtualbox-iso") active)); + cibuilds = lib.lists.foldr (d: acc: acc // { "ci${name d}" = (cibuild d); }) {} withProviders; + qemu_list = builtins.toJSON (builtins.map (d: { buildcmd = "ci${name d}"; }) (builtins.filter (x: x.provider == "qemu") active)); + vbox_list = builtins.toJSON (builtins.map (d: { buildcmd = "ci${name d}"; }) (builtins.filter (x: x.provider == "virtualbox-iso") active)); hyperv_list = builtins.toJSON (builtins.map (d: { distro = distroFile d; }) (builtins.filter (x: x.provider == "hyperv-iso") active)); - in builds // uploads // { + in builds // uploads // cibuilds // { continue = pkgs.writeText "continue.yml" (builtins.replaceStrings ["QEMU_MATRIX" "VBOX_MATRIX" "HYPERV_MATRIX"] [qemu_list vbox_list hyperv_list] (builtins.readFile ./.gitlab-ci-build.yml.in)