Better cache file naming
This commit is contained in:
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -eo pipefail
|
|
||||||
|
|
||||||
files=()
|
|
||||||
|
|
||||||
# These files are always out of date
|
|
||||||
rm -f cache/*latest* cache/*Rawhide* cache/openSUSE*Current*
|
|
||||||
|
|
||||||
# shellcheck disable=SC2044
|
|
||||||
for vars in $(find distros/ -name '*.pkrvars.hcl'); do
|
|
||||||
file=$(echo var.iso.url | packer console -var-file="${vars}" -config-type=hcl2 sources/)
|
|
||||||
base="$(basename "${file}")"
|
|
||||||
if [ -e "cache/${base}" ]; then
|
|
||||||
echo "Found cache/${base} already"
|
|
||||||
else
|
|
||||||
files+=("--retry" "3" "--retry-all-errors" "-O" "${file}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
mkdir -p cache
|
|
||||||
pushd cache
|
|
||||||
echo "Downloading ${files[*]}"
|
|
||||||
curl --parallel -L "${files[@]}"
|
|
||||||
popd
|
|
||||||
|
|
||||||
ls -lh cache/
|
|
||||||
|
|
||||||
mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET"
|
|
||||||
|
|
||||||
for f in cache/*; do
|
|
||||||
mc put "$f" "storage/isos/$f"
|
|
||||||
done
|
|
||||||
@@ -108,15 +108,7 @@
|
|||||||
(builtins.replaceStrings ["QEMU_MATRIX" "VBOX_MATRIX" "HYPERV_MATRIX"] [qemu_list vbox_list hyperv_list]
|
(builtins.replaceStrings ["QEMU_MATRIX" "VBOX_MATRIX" "HYPERV_MATRIX"] [qemu_list vbox_list hyperv_list]
|
||||||
(builtins.readFile ./.gitlab-ci-build.yml.in)
|
(builtins.readFile ./.gitlab-ci-build.yml.in)
|
||||||
);
|
);
|
||||||
cache = pkgs.writeShellApplication {
|
cache = pkgs.callPackage (import ./nix/cache.nix) { inherit active distroFile; };
|
||||||
name = "cache-isos";
|
|
||||||
runtimeInputs = with pkgs; [
|
|
||||||
curl
|
|
||||||
minio-client
|
|
||||||
packer
|
|
||||||
];
|
|
||||||
text = builtins.readFile ./cache.sh;
|
|
||||||
};
|
|
||||||
cache-restore = pkgs.writeShellApplication {
|
cache-restore = pkgs.writeShellApplication {
|
||||||
name = "cache-restore";
|
name = "cache-restore";
|
||||||
runtimeInputs = with pkgs; [
|
runtimeInputs = with pkgs; [
|
||||||
|
|||||||
@@ -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
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
source "hyperv-iso" "amd64" {
|
source "hyperv-iso" "amd64" {
|
||||||
iso_urls = [ "s3::${var.storage_url}/isos/cache/${basename(var.iso.url)}?aws_access_key_id=root&aws_access_key_secret=${var.minio_secret}" ]
|
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_target_path = "cache/${basename(var.iso.url)}"
|
iso_target_path = "cache/${var.iso.checksum}.iso"
|
||||||
iso_checksum = var.iso.checksum
|
iso_checksum = var.iso.checksum
|
||||||
output_directory = "output/hyperv/${local.name}"
|
output_directory = "output/hyperv/${local.name}"
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ variable "qemu_accelerator" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
source "qemu" "amd64" {
|
source "qemu" "amd64" {
|
||||||
iso_urls = [ "s3::${var.storage_url}/isos/cache/${basename(var.iso.url)}?aws_access_key_id=root&aws_access_key_secret=${var.minio_secret}" ]
|
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_target_path = "cache/${basename(var.iso.url)}"
|
iso_target_path = "cache/${var.iso.checksum}.iso"
|
||||||
iso_checksum = var.iso.checksum
|
iso_checksum = var.iso.checksum
|
||||||
output_directory = "output/libvirt/${local.name}"
|
output_directory = "output/libvirt/${local.name}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
source "virtualbox-iso" "amd64" {
|
source "virtualbox-iso" "amd64" {
|
||||||
iso_urls = [ "s3::${var.storage_url}/isos/cache/${basename(var.iso.url)}?aws_access_key_id=root&aws_access_key_secret=${var.minio_secret}" ]
|
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_target_path = "cache/${basename(var.iso.url)}"
|
iso_target_path = "cache/${var.iso.checksum}.iso"
|
||||||
iso_checksum = var.iso.checksum
|
iso_checksum = var.iso.checksum
|
||||||
output_directory = "output/virtualbox/${local.name}"
|
output_directory = "output/virtualbox/${local.name}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user