+16
-16
@@ -22,26 +22,26 @@ writeShellApplication {
|
||||
];
|
||||
text =
|
||||
''
|
||||
push="''${1:-yes}"
|
||||
if [ "$push" == "yes" ]; then
|
||||
mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET"
|
||||
fi
|
||||
mkdir -p cache
|
||||
push="''${1:-yes}"
|
||||
if [ "$push" == "yes" ]; then
|
||||
mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET"
|
||||
fi
|
||||
mkdir -p cache
|
||||
''
|
||||
+ (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/)
|
||||
distro=$(echo var.distro | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
|
||||
# shellcheck disable=SC2143
|
||||
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/$distro/$sha.iso"
|
||||
fi
|
||||
else
|
||||
echo "Skipping ${d.distro} - cache/$sha.iso"
|
||||
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/$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/$distro/$sha.iso"
|
||||
fi
|
||||
else
|
||||
echo "Skipping ${d.distro} - cache/$sha.iso"
|
||||
fi
|
||||
'') active
|
||||
));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
{
|
||||
pkgs,
|
||||
qemu_list,
|
||||
vbox_list,
|
||||
hyperv_list,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
general = {
|
||||
stage = "build";
|
||||
cache = [
|
||||
{
|
||||
key = {
|
||||
files = [ "sources/build.pkr.hcl" ];
|
||||
};
|
||||
paths = [ "./packer_config/" ];
|
||||
}
|
||||
];
|
||||
rules = [
|
||||
{
|
||||
"if" = "$CI_COMMIT_TAG";
|
||||
variables = {
|
||||
EXCEPT = "";
|
||||
JOB_PREFIX = "upload";
|
||||
};
|
||||
}
|
||||
{
|
||||
"if" = "$CI_COMMIT_TAG =~ \"/^$/\"";
|
||||
variables = {
|
||||
EXCEPT = "-except=upload";
|
||||
JOB_PREIX = "ci";
|
||||
};
|
||||
}
|
||||
];
|
||||
needs = [
|
||||
{
|
||||
pipeline = "$PARENT_PIPELINE_ID";
|
||||
job = "generate";
|
||||
artifacts = true;
|
||||
}
|
||||
];
|
||||
script = [
|
||||
"nix run \".#\\\"\${JOB_PREIX}\${buildcmd}\\\"\" || exit 1"
|
||||
];
|
||||
};
|
||||
|
||||
variables = {
|
||||
PACKER_CONFIG_DIR = "./packer_config/";
|
||||
PACKER_CACHE_DIR = "./cache/";
|
||||
PACKER_LOG = "1";
|
||||
};
|
||||
|
||||
continue = {
|
||||
stages = [
|
||||
"build"
|
||||
"release"
|
||||
];
|
||||
"qemu.amd64" = general // {
|
||||
variables = variables // {
|
||||
only = "-only=qemu.amd64";
|
||||
};
|
||||
tag = [ "qemu" ];
|
||||
parallel = {
|
||||
matrix = qemu_list;
|
||||
};
|
||||
before_script = [
|
||||
"echo $BUILD"
|
||||
"env"
|
||||
];
|
||||
};
|
||||
"virtualbox-iso.amd64" = general // {
|
||||
variables = variables // {
|
||||
only = "-only=\"virtualbox-iso.amd64\"";
|
||||
};
|
||||
tags = [ "vbox" ];
|
||||
parallel = {
|
||||
matrix = vbox_list;
|
||||
};
|
||||
};
|
||||
"hyperv-iso.amd64" = general // {
|
||||
variables = variables // {
|
||||
only = "-only=\"hyperv-iso.amd64\"";
|
||||
};
|
||||
tags = [ "hyperv" ];
|
||||
parallel = {
|
||||
matrix = hyperv_list;
|
||||
};
|
||||
script = [
|
||||
"packer init sources"
|
||||
"packer build -only=\"hyperv-iso.amd64\" -var-file=\"\${distro}\" -var build=\${BUILD} -var cpus=2 -var memory=4096 \${EXCEPT} sources"
|
||||
"if (-not $?) { throw \"Error in build\")"
|
||||
];
|
||||
};
|
||||
};
|
||||
in
|
||||
pkgs.writeText "continue.yml" (builtins.toJSON continue)
|
||||
+8
-8
@@ -11,13 +11,13 @@ writeShellApplication {
|
||||
packer
|
||||
];
|
||||
text = ''
|
||||
shopt -s globstar
|
||||
if [ -e "''${PACKER_CONFIG_DIR}" ]; then
|
||||
find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
|
||||
fi
|
||||
packer init sources
|
||||
for vars in distros/**/*.pkrvars.hcl; do
|
||||
packer validate -except=upload "-var-file=''${vars}" sources/
|
||||
done
|
||||
shopt -s globstar
|
||||
if [ -e "''${PACKER_CONFIG_DIR}" ]; then
|
||||
find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
|
||||
fi
|
||||
packer init sources
|
||||
for vars in distros/**/*.pkrvars.hcl; do
|
||||
packer validate -except=upload "-var-file=''${vars}" sources/
|
||||
done
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user