supercow/aux/build.sh

58 lines
1.8 KiB
Bash
Raw Permalink Normal View History

2024-08-12 12:20:28 +00:00
#!/bin/bash -ex
# Check if cleanup happened before
if [ -d "/staging" ]; then
echo "/staging exists! Please check the logs to see why the cleanup process didn't run" 1>&2
# ... however, we can fix that ...
echo -n "Running cleanup now... "
rm -rf /staging && echo "OK, proceeding." || exit 1
fi
# Create temporary folder structure
mkdir -p /staging
cd /staging
mkdir -p pool/main dists/stable/main/binary-amd64
2024-08-13 14:08:36 +00:00
# Populate with packages
2024-08-12 12:20:28 +00:00
cp /private/pkgs/*.deb pool/main/.
2024-08-13 14:08:36 +00:00
chmod 644 pool/main/*.deb
chown root:root pool/main/*.deb
2024-08-12 12:20:28 +00:00
# Create Package indexes
dpkg-scanpackages --arch amd64 pool/ > dists/stable/main/binary-amd64/Packages
cat dists/stable/main/binary-amd64/Packages | gzip -9 > dists/stable/main/binary-amd64/Packages.gz
# Create Release file
# taken from https://earthly.dev/blog/creating-and-hosting-your-own-deb-packages-and-apt-repo/
do_hash() {
HASH_NAME=$1
HASH_CMD=$2
echo "${HASH_NAME}:"
for f in $(find -type f); do
f=$(echo $f | cut -c3-) # remove ./ prefix
if [ "$f" = "Release" ]; then
continue
fi
echo " $(${HASH_CMD} ${f} | cut -d" " -f1) $(wc -c $f)"
done
}
pushd dists/stable
/aux/generate-release.sh "$REPO_DOMAIN" "$REPO_DESCRIPTION" > Release
do_hash "MD5Sum" "md5sum" >> Release
do_hash "SHA1" "sha1sum" >> Release
do_hash "SHA256" "sha256sum" >> Release
popd
2024-08-12 12:20:28 +00:00
# Sign Release file
cat dists/stable/Release | gpg --default-key $(gpg --list-keys | head -n 4 | tail -n 1) --armor --detach-sign --sign --output dists/stable/Release.gpg
cat dists/stable/Release | gpg --default-key $(gpg --list-keys | head -n 4 | tail -n 1) --armor --clearsign --sign --output dists/stable/InRelease
# Make pubkey accessible
gpg --armor --export > signing.pub
# Move files and clean up staging directory
rm -rf /usr/share/nginx/html/*
mv /staging/* /usr/share/nginx/html/.
rm -rf /staging