Better cache file naming

This commit is contained in:
Greg Hellings
2024-06-26 20:57:47 -05:00
parent 31f14a5e8f
commit bc1f23a47b
6 changed files with 48 additions and 47 deletions
+41
View File
@@ -0,0 +1,41 @@
{
writeShellApplication,
active,
distroFile,
curl,
minio-client,
packer,
...
}:
let
inherit (builtins) concatStringsSep map;
in writeShellApplication {
name = "cache-isos";
runtimeInputs = [
curl
minio-client
packer
];
text = (concatStringsSep "\n" (
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/)
if [ ! -e "cache/$sha.iso" ]; then
curl --retry 3 --retry-all-errors -o "cache/$sha.iso" "$url"
else
echo "Skipping ${d.distro} - cache/$sha.iso"
fi
'') active
)) + ''
ls -lh cache/
mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET"
for f in cache/*; do
mc put "$f" "storage/isos/$f"
done
'';
}