Build missing packages and -git packages

Add locking
Fix style
Optionally disable git rebuild
This commit is contained in:
Tobias Manske 2023-03-27 13:59:50 +02:00
parent de9bbb5a5f
commit 1a7016a930
Signed by: tobias
GPG Key ID: 9164B527694A0709
2 changed files with 61 additions and 35 deletions

View File

@ -6,7 +6,6 @@ name: Build ArchLinux packages!
trigger: trigger:
event: event:
include: include:
- push
- custom - custom
- cron - cron
- tag - tag

View File

@ -1,8 +1,9 @@
#!/bin/sh #!/bin/bash
set -u set -eEu
set -e
set -v set -v
PIPELINE_ID=$RANDOM
echo ${PIPELINE_ID}
sudo pacman-key --init sudo pacman-key --init
@ -10,77 +11,103 @@ sudo pacman-key --init
## Needed so pacman doesnt complain. ## Needed so pacman doesnt complain.
repo-add "/repo/${AUR_REPO_NAME}.db.tar.xz" repo-add "/repo/${AUR_REPO_NAME}.db.tar.xz"
sudo pacman -Syu --noconfirm minio-client pacman-contrib sudo pacman -Syu --noconfirm minio-client pacman-contrib &>/dev/null # Setup tooling
mcli alias set s3 https://s3.tobiasmanske.de $REPO_ACCESS_KEY $REPO_SECRET_KEY mcli alias set s3 https://s3.tobiasmanske.de "${REPO_ACCESS_KEY}" "${REPO_SECRET_KEY}"
mcli cp s3/repo/x86_64/rad4day.db.tar.xz /repo/rad4day.db.tar.xz
mcli cp s3/repo/x86_64/rad4day.files.tar.xz /repo/rad4day.files.tar.xz
mcli cp s3/repo/x86_64/rad4day.db.tar.xz.sig /repo/rad4day.db.tar.xz.sig # LOCK
mcli cp s3/repo/x86_64/rad4day.files.tar.xz.sig /repo/rad4day.files.tar.xz.sig LOCK=""
if ! (aur repo > /dev/null 2>&1); then while [[ "${LOCK}" != "${PIPELINE_ID}" ]]; do
printf "Aur repo not initialized, initializing /repo...\n" LOCK=$(mcli cat s3/repo/LOCK)
repo-add "/repo/${AUR_REPO_NAME}.db.tar.xz" if [[ "${LOCK}" == "FREE" ]]; then
echo $PIPELINE_ID | mcli pipe s3/repo/LOCK
fi
echo "Waiting for lock with id $PIPELINE_ID..."
sleep $((RANDOM % 10))
done
unlock() {
if [[ "${LOCK}" == "${PIPELINE_ID}" ]]; then
echo "FREE" | mcli pipe s3/repo/LOCK
fi
}
trap unlock EXIT INT TERM
echo "Pulling Repository"
(
mcli mirror --overwrite s3/repo/x86_64 /repo &>/dev/null
rm "/repo/${AUR_REPO_NAME}.db"
rm "/repo/${AUR_REPO_NAME}.db.sig"
rm "/repo/${AUR_REPO_NAME}.files"
# rm "/repo/${AUR_REPO_NAME}.files.sig"
ln -sf "/repo/${AUR_REPO_NAME}.db.tar.xz" "/repo/${AUR_REPO_NAME}.db"
ln -sf "/repo/${AUR_REPO_NAME}.files.tar.xz" "/repo/${AUR_REPO_NAME}.files"
ln -sf "/repo/${AUR_REPO_NAME}.db.tar.xz.sig" "/repo/${AUR_REPO_NAME}.db.sig"
ln -sf "/repo/${AUR_REPO_NAME}.files.tar.xz.sig" "/repo/${AUR_REPO_NAME}.files.sig"
) &>/dev/null
if ! (aur repo >/dev/null 2>&1); then
printf "Aur repo not initialized, initializing /repo...\n"
repo-add "/repo/${AUR_REPO_NAME}.db.tar.xz"
fi fi
# Keyring Signing Key # Keyring Signing Key
sudo pacman-key --add trustroot.asc sudo pacman-key --add trustroot.asc
gpg --import --batch trustroot.asc gpg --import --batch trustroot.asc
sudo pacman-key --lsign 10BE06BC275CE0E17373B368F67996C486D1B56B sudo pacman-key --lsign 10BE06BC275CE0E17373B368F67996C486D1B56B
# repoctl conf new "$(readlink -f \"/repo/${AUR_REPO_NAME}.db.tar.xz\")"
# Setup signing # Setup signing
echo "$BUILD_GPG_KEY" | base64 -d | gpg --import --batch echo "${BUILD_GPG_KEY:-}" | base64 -d | gpg --import --batch
echo "C3FE87CFB8F8D503AE03EC1C033E7F3DC71FE89E:6:" | gpg --import-ownertrust --batch echo "C3FE87CFB8F8D503AE03EC1C033E7F3DC71FE89E:6:" | gpg --import-ownertrust --batch
sudo pacman --noconfirm -Sy archlinux-keyring
sudo pacman --noconfirm -Syu
sudo pacman --noconfirm -Syu archlinux-keyring &>/dev/null
git clone --recursive https://git.tobiasmanske.de/archlinux-repo/package_sources.git packages git clone --recursive https://git.tobiasmanske.de/archlinux-repo/package_sources.git packages &>/dev/null
cd packages cd packages
touch buildqueue touch buildqueue
## OBTAIN PACKAGES TO BUILD ## OBTAIN PACKAGES TO BUILD
git submodule update --remote --merge # Make sure we are up to date if something is linked as a submodule git submodule update --remote --merge &>/dev/null # Make sure we are up to date if something is linked as a submodule
# #
find . -name PKGBUILD -execdir sh -c 'makepkg --printsrcinfo > .SRCINFO' \; find . -name PKGBUILD -execdir sh -c 'makepkg --printsrcinfo > .SRCINFO' \;
# Obtain version of downloaded packages # Obtain version of downloaded packages
find . -iname PKGBUILD -exec dirname {} \; | aur srcver --no-prepare - > vcs find . -iname PKGBUILD -exec dirname {} \; | aur srcver --no-prepare - >vcs
# Rebuild all git packages # Rebuild all git packages
find . -iname "*-git$" -type d | tee -a buildqueue if [ ! -z "$NO_GIT_REBUILD" ]; then
cut -f1 vcs | grep -e "-git$" | tee -a buildqueue
fi
# add all outdated packages to the build queue # add all outdated packages to the build queue
aur repo --list | aur vercmp -q -p vcs | tee -a buildqueue aur repo --list | aur vercmp -q -p vcs | tee -a buildqueue
# Build missing packages
comm -23 <(cut -f1 vcs | sort) <(pacman -Slq "${AUR_REPO_NAME}" | sort) | tee -a buildqueue
# Build all packages defined in buildqueue # Build all packages defined in buildqueue
while read -r i; do while read -r i; do
cat "$i"/.SRCINFO cat "$i"/.SRCINFO
done < buildqueue | aur graph | tsort | tac > queue done <buildqueue | aur graph | tsort | tac >queue
echo echo
echo QUEUE echo QUEUE
echo echo
cat queue cat queue
if wc -l queue | grep -q "^0 "; then
echo "Nothing to build, exiting."
exit 0
fi
## BUILD ## BUILD
aur build -S --noconfirm -a queue --no-sync --margs -s aur build -S --noconfirm -a queue --no-sync --margs -s
# build all packages defined in our repo
#paclist custom | awk '{print $1}' | xargs -r aur sync --noconfirm
aur sync -u -S --noview --noconfirm
## Upload to repo ## Upload to repo
mcli mirror --overwrite /repo s3/repo/x86_64 mcli mirror --overwrite /repo s3/repo/x86_64
exec "$@"