From b8f608772ccffaf514f29edb09fdc758a4c8207f Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sun, 1 Dec 2024 13:39:18 -0500 Subject: [PATCH] forgejo-ci: add clear-repo binary --- .forgejo/bin/clear-repo.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 .forgejo/bin/clear-repo.sh diff --git a/.forgejo/bin/clear-repo.sh b/.forgejo/bin/clear-repo.sh new file mode 100755 index 0000000..14110ea --- /dev/null +++ b/.forgejo/bin/clear-repo.sh @@ -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