From 16afcda8ed3f6baaa7d6ab8193373d2a78670c8a Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 26 Jan 2025 06:32:32 -0600 Subject: [PATCH 1/6] Add Linux Mint --- distros/default.nix | 1 + distros/mint/22/amd64.pkrvars.hcl | 18 ++++++ distros/mint/22/finalize.sh | 22 ++++++++ distros/mint/22/http/preseed.cfg | 92 +++++++++++++++++++++++++++++++ distros/mint/22/qemu.sh | 6 ++ distros/mint/22/virtualbox.sh | 10 ++++ distros/mint/22/vmware.sh | 4 ++ distros/mint/default.nix | 8 +++ 8 files changed, 161 insertions(+) create mode 100644 distros/mint/22/amd64.pkrvars.hcl create mode 100644 distros/mint/22/finalize.sh create mode 100644 distros/mint/22/http/preseed.cfg create mode 100644 distros/mint/22/qemu.sh create mode 100644 distros/mint/22/virtualbox.sh create mode 100644 distros/mint/22/vmware.sh create mode 100644 distros/mint/default.nix diff --git a/distros/default.nix b/distros/default.nix index 0b6dbcf..2dce527 100644 --- a/distros/default.nix +++ b/distros/default.nix @@ -6,6 +6,7 @@ centos-stream = import ./centos-stream; debian = import ./debian; fedora = import ./fedora; + mint = import ./mint; nixos = import ./nixos; opensuse = import ./opensuse; rockylinux = import ./rockylinux; diff --git a/distros/mint/22/amd64.pkrvars.hcl b/distros/mint/22/amd64.pkrvars.hcl new file mode 100644 index 0000000..065d09c --- /dev/null +++ b/distros/mint/22/amd64.pkrvars.hcl @@ -0,0 +1,18 @@ +distro = "mint" +version = "22" +iso = { + url = "https://mirrors.kernel.org/linuxmint/stable/22.1/linuxmint-22.1-cinnamon-64bit.iso" + checksum = "ccf482436df954c0ad6d41123a49fde79352ca71f7a684a97d5e0a0c39d7f39f" +} +boot_command = [ + "e", + "auto ", + "noprompt ", + "automatic-ubiquity ", + #"only-ubiquity ", + "url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ", + "", +] +http_directory = "distros/mint/22/http/" +vbox_os_type = "Debian12_64" +disk_size = "30" diff --git a/distros/mint/22/finalize.sh b/distros/mint/22/finalize.sh new file mode 100644 index 0000000..9da84aa --- /dev/null +++ b/distros/mint/22/finalize.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -ex + +# 5 minute timeout for the package lock to arrive +apt-get -o DPkg::Lock::Timeout=600 autoremove -y + +# Configure sshd to be 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 + +virt="$(systemd-detect-virt)" +if [ "${virt}" == "microsoft" ]; then + apt-get install -y hyperv-daemons + systemctl enable hv-fcopy-daemon + systemctl enable hv-kvp-daemon + systemctl enable hv-vss-daemon +fi diff --git a/distros/mint/22/http/preseed.cfg b/distros/mint/22/http/preseed.cfg new file mode 100644 index 0000000..d6a3b2a --- /dev/null +++ b/distros/mint/22/http/preseed.cfg @@ -0,0 +1,92 @@ +d-i debconf/frontend select Noninteractive +d-i debconf/priority select critical + +d-i debian-installer/locale string en_US.UTF-8 +# If you don't set locale separately, you will still get asked +d-i debian-installer/language string en +d-i debian-installer/country string US +d-i debconf/language string en +d-i console-setup/ask_detect boolean false + +# Setup the keyboard +d-i keyboard-configuration/layout select English (US) +d-i keyboard-configuration/variant select English (US) +d-i keyboard-configuration/keyboardcode select English (US) +d-i keyboard-configuration/xkb-keymap select us +d-i keyboard-configuration/toggle select No toggling +d-i keyboard-configuration/layoutcode string us + +# Choose whatever network seems good at the time +d-i netconfig/choose_interface select auto +d-i netcfg/get_hostname string vagrant +d-i netcfg/get_domain string vagrant + +# Setup vagrant user with vagrant passwords and such +d-i passwd/root-password-again password vagrant +d-i passwd/root-password password vagrant +d-i passwd/user-fullname string vagrant +d-i passwd/username string vagrant +d-i passwd/user-password password vagrant +d-i passwd/user-password-again password vagrant + +# Assume UTC time, to let user change if wanted +d-i clock-setup/utc boolean true +d-i time/zone string UTC + +# Just use plain partitions +ubiquity partman-auto/method string regular +# Don't prompt removing LVM +ubiquity partman-lvm/device_remove_lvm boolean true +# Don't prompt removing software RAID +ubiquity partman-md/device_remove_md boolean true + +# Put everything on one partition, then confirm +d-i partman-auto/choose_recipe select atomic +d-i partman-partitioning/confirm_write_new_label boolean true +d-i partman/choose_partition select finish +d-i partman/confirm boolean true +d-i partman/confirm_nooverwrite boolean true +ubiquity partman/confirm boolean true +ubiquity partman-partitioning/confirm_write_new_label boolean true +ubiquity partman/choose_partition select finish +ubiquity partman/confirm boolean true +ubiquity partman/confirm_nooverwrite boolean true + +# Install to MBR, regardless of disk contents +d-i grub-installer/only_debian boolean true +d-i grub-installer/with_other_os boolean true +d-i grub-installer/bootdev string default +#d-i grub-installer/force-efi-extra-removable boolean true + +# Settings for package manager +d-i apt-setup/non-free boolean true +d-i apt-setup/contrib boolean true +d-i apt-setup/cdrom/set-first boolean false +d-i apt-setup/cdrom/set-next boolean false +d-i apt-setup/cdrom/set-failed boolean false +d-i mirror/country string manual +d-i mirror/http/proxy string +ubiquity ubiquity/use_nonfree boolean false + +# Package selection +tasksel tasksel/first multiselect +#d-i pkgsel/include string curl openssh-server sudo python3 network-manager +popularity-contest popularity-contest/participate boolean false + + +# Skip final message about completed install +d-i finish-install/reboot_in_progress note +d-i ubiquity/summary note +ubiquity ubiquity/reboot boolean true + +ubiquity ubiquity/success_command string \ + 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; \ + sed -i -e 's/ens3/ens5/g' /target/etc/network/interfaces; \ + IF=$(ip -br a|grep DOWN|head -1|awk '{print $1}'); \ + ip link set up dev $IF; \ + dhclient $IF; \ + in-target apt-get update; \ + in-target apt-get upgrade -y; \ + in-target apt-get install -y openssh-server diff --git a/distros/mint/22/qemu.sh b/distros/mint/22/qemu.sh new file mode 100644 index 0000000..4ef2dee --- /dev/null +++ b/distros/mint/22/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/mint/22/virtualbox.sh b/distros/mint/22/virtualbox.sh new file mode 100644 index 0000000..998449c --- /dev/null +++ b/distros/mint/22/virtualbox.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -ex + +packages=(bzip2 dkms build-essential "linux-headers-$(uname -r)") +apt install -y "${packages[@]}" +mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt +/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log +apt remove -y "${packages[@]}" +umount /mnt +rm /home/vagrant/VBoxGuestAdditions.iso diff --git a/distros/mint/22/vmware.sh b/distros/mint/22/vmware.sh new file mode 100644 index 0000000..9560300 --- /dev/null +++ b/distros/mint/22/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +apt install -y open-vm-tools diff --git a/distros/mint/default.nix b/distros/mint/default.nix new file mode 100644 index 0000000..f721563 --- /dev/null +++ b/distros/mint/default.nix @@ -0,0 +1,8 @@ +[ + + { + version = "22"; + arch = "amd64"; + eol = false; + } +] From 58a41f3d3b9da774c62e5b147aabc2b8f24533db Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 26 Jan 2025 06:32:44 -0600 Subject: [PATCH 2/6] Increase base disk size for Linux Mint reqs --- sources/inputs.pkr.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/inputs.pkr.hcl b/sources/inputs.pkr.hcl index 2fcc09d..c6726be 100644 --- a/sources/inputs.pkr.hcl +++ b/sources/inputs.pkr.hcl @@ -131,7 +131,7 @@ locals { cpus = var.cpus memory = var.memory - disk_size = 10 + disk_size = 20 ssh = { username = "vagrant" password = "vagrant" From a6fec9eded9c2638fa06ae63101343e8a4d6eb0f Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 26 Jan 2025 13:55:17 -0600 Subject: [PATCH 3/6] Update to a faster openSuse mirror --- distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh b/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh index b8eca9e..56fed07 100755 --- a/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh +++ b/distros/opensuse/tumbleweed/amd64.pkrvars.hcl.sh @@ -4,7 +4,7 @@ set -x name="${0%.sh}" -base="https://download.opensuse.org/tumbleweed/iso/openSUSE-Tumbleweed-DVD-x86_64-Current.iso" +base="https://mirror.fcix.net/opensuse/tumbleweed/iso/openSUSE-Tumbleweed-DVD-x86_64-Current.iso" # Working directory tmp="$(mktemp -d)" From 8f5e127b45b7d707cf45dcf973f34f1fbbcef6c6 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 26 Jan 2025 13:55:46 -0600 Subject: [PATCH 4/6] Support parallel downloads with Go --- nix/cache/cache.go | 49 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/nix/cache/cache.go b/nix/cache/cache.go index bd3f03d..082b18e 100644 --- a/nix/cache/cache.go +++ b/nix/cache/cache.go @@ -61,47 +61,59 @@ func processStdin() []IsoInfo { return isos } -func downloadAndUploadIso(minioClient *minio.Client, iso IsoInfo) error { +func downloadAndUploadIso(minioClient *minio.Client, iso IsoInfo, ch chan int) { // Create the destination file path destPath := "cache/" + iso.Hash + ".iso" // Create cache directory if it doesn't exist err := os.MkdirAll("cache", 0755) if err != nil { - return err + log.Fatalln(err) + ch <- 1 + return } log.Println("Downloading " + iso.Url) // Download the ISO file resp, err := http.Get(iso.Url) if err != nil { - return err + log.Fatalln(err) + ch <- 1 + return } defer resp.Body.Close() // Create the destination file destFile, err := os.Create(destPath) if err != nil { - return err + log.Fatalln(err) + ch <- 1 + return } defer destFile.Close() // Copy the downloaded content to the file _, err = io.Copy(destFile, resp.Body) if err != nil { - return err + log.Fatalln(err) + ch <- 1 + return } // Reopen file for uploading uploadFile, err := os.Open(destPath) if err != nil { - return err + log.Fatalln(err) + ch <- 1 + return } defer uploadFile.Close() // Get file info for content-length fileInfo, err := uploadFile.Stat() if err != nil { - return err + log.Fatalln(err) + ch <- 1 + return } log.Println("Uploading " + destPath) @@ -111,10 +123,13 @@ func downloadAndUploadIso(minioClient *minio.Client, iso IsoInfo) error { ContentType: "application/x-iso9660-image", }) if err != nil { - return err + log.Fatalln(err) + ch <- 1 + return } - return nil + log.Println("Done with " + iso.Url) + ch <- 1 } func main() { @@ -144,6 +159,8 @@ func main() { isos := processStdin() + downloads := 0 + dl_counter := make(chan int) for _, iso := range isos { // Check if ISO exists in Minio isoPath := "cache/" + iso.Distro + "/" + iso.Hash + ".iso" @@ -157,10 +174,16 @@ func main() { } if !exists { - if err := downloadAndUploadIso(minioClient, iso); err != nil { - log.Println("Error downloading/uploading ISO:", err) - os.Exit(1) - } + downloads += 1 + go downloadAndUploadIso(minioClient, iso, dl_counter) + } + } + + for downloads > 0 { + if k := <-dl_counter; k == 1 { + downloads -= 1 + } else { + log.Println("Received unknown message on channel: ", k) } } } From c0cd44a8e35da4a6bc94dcd820991a23dac001ea Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 27 Jan 2025 11:19:49 -0600 Subject: [PATCH 5/6] Update VirtualBox OS types --- distros/centos-stream/10/amd64.pkrvars.hcl.sh | 2 +- distros/ubuntu/24.04/amd64.pkrvars.hcl | 2 +- distros/ubuntu/24.10/amd64.pkrvars.hcl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/distros/centos-stream/10/amd64.pkrvars.hcl.sh b/distros/centos-stream/10/amd64.pkrvars.hcl.sh index acf0c61..a830de8 100755 --- a/distros/centos-stream/10/amd64.pkrvars.hcl.sh +++ b/distros/centos-stream/10/amd64.pkrvars.hcl.sh @@ -28,7 +28,7 @@ boot_command = [ "x" ] cd_files = [ "distros/centos-stream/10/disc/*" ] -vbox_os_type = "RedHat10_64" +vbox_os_type = "RedHat_64" HERPDERP rm -f cache/CentOS-Stream-10-latest-x86_64-boot.iso diff --git a/distros/ubuntu/24.04/amd64.pkrvars.hcl b/distros/ubuntu/24.04/amd64.pkrvars.hcl index e6d2b3f..ae1de5e 100644 --- a/distros/ubuntu/24.04/amd64.pkrvars.hcl +++ b/distros/ubuntu/24.04/amd64.pkrvars.hcl @@ -16,4 +16,4 @@ boot_command = [ cd_files = [ "distros/ubuntu/24.04/disc/*" ] -vbox_os_type = "Ubuntu24_64" +vbox_os_type = "Ubuntu24_LTS_64" diff --git a/distros/ubuntu/24.10/amd64.pkrvars.hcl b/distros/ubuntu/24.10/amd64.pkrvars.hcl index 40100e1..1e42070 100644 --- a/distros/ubuntu/24.10/amd64.pkrvars.hcl +++ b/distros/ubuntu/24.10/amd64.pkrvars.hcl @@ -16,4 +16,4 @@ boot_command = [ cd_files = [ "distros/ubuntu/24.10/disc/*" ] -vbox_os_type = "Ubuntu24_64" +vbox_os_type = "Ubuntu_64" From efa7a944672eabd6e88ea8655b15cc2f943dcb71 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 27 Jan 2025 13:20:26 -0600 Subject: [PATCH 6/6] Eliminate warning --- distros/mint/22/amd64.pkrvars.hcl | 1 - 1 file changed, 1 deletion(-) diff --git a/distros/mint/22/amd64.pkrvars.hcl b/distros/mint/22/amd64.pkrvars.hcl index 065d09c..3a5e1a5 100644 --- a/distros/mint/22/amd64.pkrvars.hcl +++ b/distros/mint/22/amd64.pkrvars.hcl @@ -15,4 +15,3 @@ boot_command = [ ] http_directory = "distros/mint/22/http/" vbox_os_type = "Debian12_64" -disk_size = "30"