summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-02-13 14:04:32 +0100
committerErich Eckner <git@eckner.net>2020-02-13 14:04:32 +0100
commit5a63f896f4fd5cb1c15facaea31da822594b8cd2 (patch)
tree47b39ff03f3f7392bf92ecb6bc33dfd5a559fd8a /bin
parent2d3fd458553d694721de509bcbb6738ee99205ed (diff)
downloadbuilder-5a63f896f4fd5cb1c15facaea31da822594b8cd2.tar.xz
bin/clean-cache: remove hard-coded package suffixes
Diffstat (limited to 'bin')
-rwxr-xr-xbin/clean-cache36
1 files changed, 25 insertions, 11 deletions
diff --git a/bin/clean-cache b/bin/clean-cache
index 2ed8c58..eda926f 100755
--- a/bin/clean-cache
+++ b/bin/clean-cache
@@ -5,8 +5,6 @@
# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"
-# TODO: remove hard-coded package suffixes
-
if [ $# -eq 0 ]; then
dummynator='sudo'
elif [ $# -eq 1 ] && [ "x$1" = 'x-n' ]; then
@@ -53,13 +51,29 @@ find "${tmp_dir}" -type f -name desc \
' | \
sort -k2,2 | \
uniq -uf1 | \
- while read -r s; do
- printf '%s%s\n' \
- "${s}" '-i686.pkg.tar.xz' \
- "${s}" '-any.pkg.tar.xz' \
- "${s}" '-i686.pkg.tar.zst' \
- "${s}" '-any.pkg.tar.zst'
- done | \
+ sed -n '
+ h
+ '"$(
+ # shellcheck disable=SC2016
+ {
+ printf 'SELECT'
+ printf ' CONCAT('
+ printf '"g;s@$@-",'
+ printf '`architectures`.`name`,'
+ printf '".pkg.",'
+ printf '`compressions`.`suffix`,'
+ printf '"@;p"'
+ printf ')'
+ printf ' FROM `compressions`'
+ printf ' JOIN `architectures`;\n'
+ } \
+ | mysql_run_query
+ )" \
sha256sum -c --ignore-missing --quiet 2> /dev/null | \
- sed 's|: FAILED$||' | \
- xargs -r ${dummynator} rm
+ sed -n '
+ s|: FAILED$||
+ T
+ p
+ s/$/.sig/
+ ' | \
+ xargs -r ${dummynator} rm -f