diff options
Diffstat (limited to 'clean-cache')
-rwxr-xr-x | clean-cache | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/clean-cache b/clean-cache index d2c9b3c..d580d4c 100755 --- a/clean-cache +++ b/clean-cache @@ -7,4 +7,33 @@ find "${mirror_dir}" -type f -printf '%h\n' \ | sort -u \ | while read -r repo_dir; do paccache -v -r -k 2 -c "${repo_dir}" + if [ -z "${repo_dir##*/os/*}" ]; then + repo="${repo_dir%%/os/*}" + repo="${repo##*/}" + else + repo="${repo_dir##*/}" + fi + curl \ + --resolve 'arch-mirror.home.eckner.net:80:127.0.0.1' \ + -Ss 'http://arch-mirror.home.eckner.net/'"${repo_dir#${mirror_dir}/}/${repo}"'.db' \ + | tar -Oxz \ + | sed -n ' + /^%\(FILENAME\|CSIZE\|SHA256SUM\)%$/,/^$/p + ' \ + | grep -v '^%.*%$' \ + | grep -vxF '' \ + | sed ' + N;N + s@\n@ @g + ' \ + | while read -r file size sum; do + [ -f "${repo_dir}/${file}" ] || continue + if stat -c'%s' "${repo_dir}/${file}" \ + | grep -qxF "${size}" \ + && printf '%s %s/%s\n' "${sum}" "${repo_dir}" "${file}" \ + | sha256sum -c --quiet; then + continue + fi + rm "${file}" + done done |