supercow/aux/build.sh

55 lines
1.8 KiB
Bash
Executable File

#!/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
cp /private/pkgs/*.deb pool/main/.
# 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
# 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