forgejo-ci: add clear-repo binary

This commit is contained in:
Antoine Martin 2024-12-01 13:39:18 -05:00
parent 89c8805846
commit b8f608772c
Signed by: forge
GPG key ID: D62A472A4AA7D541

17
.forgejo/bin/clear-repo.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
TARGET_REPO=$1
ARCH=$2
curl --silent $TARGET_REPO/$ARCH/APKINDEX.tar.gz | tar -O -zx APKINDEX > APKINDEX
pkgs=$(awk -F ':' '{if($1=="o"){print $2}}' APKINDEX | sort | uniq)
for pkg in $pkgs; do
pkgvers=$(sed -n "/^P:$pkg$/,/^$/p" APKINDEX | awk -F ':' '{if($1=="V"){print $2}}')
for pkgver in $pkgvers; do
echo "Deleting $pkg-$pkgver of arch $ARCH from $TARGET_REPO"
curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN -X DELETE $TARGET_REPO/$ARCH/$pkg-$pkgver.apk
done
done