From b6461278751218179ba0a32be2680b28e97fdc6d Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 12 Jul 2024 21:15:01 -0500 Subject: [PATCH] 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}"