summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2022-03-16 21:09:49 -0400
committerDave Wallace <dwallacelf@gmail.com>2022-03-16 21:09:49 -0400
commit980983f3e41b74b64e2c7c2c66653513272e6fcd (patch)
tree6e2130f8fb10078e30a130a97f3ffd18ca1bbccf /extras
parent1f723ed0fca3a5d33896d28e5e19576f730c0782 (diff)
extras/bash: script to clean up https://packagecloud.io/fdio/attic
Signed-off-by: Dave Wallace <dwallacelf@gmail.com> Change-Id: Iec595af163e201689a1e07e81daf5ed9519888b8
Diffstat (limited to 'extras')
-rwxr-xr-xextras/bash/packagecloud_attic_cleanup.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/extras/bash/packagecloud_attic_cleanup.sh b/extras/bash/packagecloud_attic_cleanup.sh
new file mode 100755
index 000000000..6312510af
--- /dev/null
+++ b/extras/bash/packagecloud_attic_cleanup.sh
@@ -0,0 +1,29 @@
+#! /bin/bash
+
+set -euo pipefail
+
+attic_repo='fdio/attic'
+packages_json='/tmp/pkgs.json'
+packagecloud_user="$HOME/.ssh/.packagecloud.user"
+# shellcheck disable=SC2064
+trap "rm -f $packages_json" SIGHUP SIGINT SIGQUIT EXIT
+
+get_more_packages() {
+ rm -f $packages_json
+ echo "Retrieving packages from packagecloud.io/$attic_repo"
+ # shellcheck disable=SC2086
+ curl -s https://"$(cat $packagecloud_user)"/api/v1/repos/$attic_repo/packages.json | jq . > $packages_json
+}
+
+get_more_packages
+while [ -n "$(cat $packages_json)" ] ; do
+ for pkg in $(cat $packages_json | jq '.[].destroy_url' | xargs) ; do
+ # shellcheck disable=SC2086
+ echo "Deleting $(basename $pkg)"
+ # shellcheck disable=SC2086
+ curl -sX DELETE "https://$(cat $packagecloud_user)$pkg" >& /dev/null
+ done
+ echo
+ get_more_packages
+done
+echo "No more packages in '$attic_repo'!"