59 lines
No EOL
1.6 KiB
Bash
59 lines
No EOL
1.6 KiB
Bash
#!/usr/bin/env bash
|
|
# e - script stops on error (return != 0)
|
|
# u - error if undefined variable
|
|
# o pipefail - script fails if one of piped commands fails
|
|
# x - output each line (debug)
|
|
set -euo pipefail
|
|
|
|
if [ "$1" = "all" ]; then
|
|
BUILT=()
|
|
for file in kitteh-node-*/*; do
|
|
FILE_NO_EXTENSION="${file/".nix"/""}"
|
|
|
|
# checksum modification checking
|
|
if [ ! -d "meta/$(dirname "$file")" ]; then
|
|
mkdir -p "meta/$(dirname "$file")"
|
|
fi
|
|
sha512sum "$file" > /tmp/kt-clusterbuild_sha512sum
|
|
|
|
if [ ! -f "meta/$file.sha" ] || ! diff -q "/tmp/kt-clusterbuild_sha512sum" "meta/$file.sha" > /dev/null; then
|
|
./"${0}" "$FILE_NO_EXTENSION"
|
|
|
|
# shellcheck disable=SC2181
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to build, skipping..."
|
|
continue
|
|
fi
|
|
|
|
if ! grep -q "out/$FILE_NO_EXTENSION.vma.zst" meta/tagged_for_upload; then
|
|
echo "out/$FILE_NO_EXTENSION.vma.zst" >> meta/tagged_for_upload
|
|
fi
|
|
else
|
|
echo "Not building '$FILE_NO_EXTENSION'."
|
|
continue
|
|
fi
|
|
|
|
BUILT+=("$FILE_NO_EXTENSION")
|
|
|
|
mv "/tmp/kt-clusterbuild_sha512sum" "meta/$file.sha"
|
|
done
|
|
|
|
echo "Done building:"
|
|
declare -p BUILT
|
|
fi
|
|
|
|
if [ "$1" != "all" ]; then
|
|
echo "Building '$1'..."
|
|
nix --extra-experimental-features nix-command run github:nix-community/nixos-generators -- --format proxmox --configuration "$1.nix" | tee build.log
|
|
|
|
if [ ! -d "out/" ]; then
|
|
mkdir out/
|
|
fi
|
|
|
|
echo "Copying file to the output directory..."
|
|
|
|
mkdir -p "out/$(dirname "$1")"
|
|
rm -rf out/"$1".vma.zst
|
|
OUT_FILE="$(sed -n '$p' build.log)"
|
|
cp -r "$OUT_FILE" out/"$1".vma.zst
|
|
fi |