paccache: Add size filter
While my general policy is to keep packages two versions back, some packages (eg cuda, texlive) are large enough that I want to keep fewer versions.
However, while paccache
does allow inspecting {a,c,m}time for its rules, it doesn't allow inspecting size.
Currently, I work around this via
#!/bin/bash
if test "$1" == '-s'; then maxsize="$2"; shift 2; fi
if test "$1" == '--maxsize'; then maxsize="$2"; shift 2; fi
if test -n "$maxsize"; then
pkgs() {
CACHEDIR=/var/cache/pacman/pkg/
find "$CACHEDIR" -type f -size +"$1" -exec tar xOf {} .PKGINFO \; \
| awk -F' = ' '$1 == "pkgbase" { print $2; }' \
| tee /dev/stderr
}
else
pkgs() { :; }
fi
exec paccache "$@" $(pkgs "$maxsize")
but I'd rather this be built-in.