Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-08-02 09:02:57 -0400
committerDan McGee <dan@archlinux.org>2011-08-08 13:29:45 -0500
commit1e16b94a85678bc6d055e19f0efbd5bb680c5032 (patch)
tree45ad40dfe69120b8e4f0a25a013163d3b1054c6f
parent07a1292721c62f44d89a9fe6a0b093b5e6865b8a (diff)
contrib/paccache: misc cleanup and bugfix
* change error verbiage when run as root * delete sigs along with packages * fix bug in diskspace calculations * merge END block in pkgfilter Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
-rwxr-xr-xcontrib/paccache.in35
1 files changed, 22 insertions, 13 deletions
diff --git a/contrib/paccache.in b/contrib/paccache.in
index 0bd0cf79..909cbbee 100755
--- a/contrib/paccache.in
+++ b/contrib/paccache.in
@@ -87,9 +87,7 @@ pkgfilter() {
while (getline < "/dev/stdin") {
parse_filename($0)
}
- }
- END {
for (pkglist in packages) {
# idx[1,2] = idx[pkgname,arch]
split(pkglist, idx, SUBSEP)
@@ -110,10 +108,11 @@ pkgfilter() {
size_to_human() {
awk -v size="$1" '
BEGIN {
- suffix[1] = "KiB"
- suffix[2] = "MiB"
- suffix[3] = "GiB"
- suffix[4] = "TiB"
+ suffix[1] = "B"
+ suffix[2] = "KiB"
+ suffix[3] = "MiB"
+ suffix[4] = "GiB"
+ suffix[5] = "TiB"
count = 1
while (size > 1024) {
@@ -142,7 +141,7 @@ runcmd() {
}
summarize() {
- local -i filecount=$#
+ local -i filecount=$1; shift
local seenarch= seen= arch= name=
local -r pkg_re='(.+)-[^-]+-[0-9]+-([^.]+)\.pkg.*'
@@ -166,13 +165,12 @@ summarize() {
printf "%s$delim" "$pkg"
fi
done < <(printf '%s\n' "$@" | sort -V)
- printf '\n' >&2
fi
-
printf -v output 'finished dry run: %d candidates' "$filecount"
fi
- msg "$output (diskspace saved: %s)" "$(size_to_human "$totalsaved")"
+ printf '\n' >&2
+ msg "$output (diskspace saved: %s)" "$(size_to_human "$totalsaved")"
}
usage() {
@@ -204,7 +202,7 @@ EOF
}
if (( ! UID )); then
- error "Bad dog, no biscuit. You will be prompted for privilege escalation."
+ error "Do not run this script as root. You will be prompted for privilege escalation."
exit 42
fi
@@ -277,8 +275,19 @@ if (( ! ${#candidates[*]} )); then
exit 1
fi
+# grab this prior to signature scavenging
+pkgcount=${#candidates[*]}
+
+# copy the list, merging in any found sigs
+for cand in "${candidates[@]}"; do
+ candtemp+=("$cand")
+ [[ -f $cand.sig ]] && candtemp+=("$cand.sig")
+done
+candidates=("${candtemp[@]}")
+unset candtemp
+
# do this before we destroy anything
-totalsaved=$(@SIZECMD@ "${candidates[@]}" | awk '{ sum = $1 } END { print sum }')
+totalsaved=$(@SIZECMD@ "${candidates[@]}" | awk '{ sum += $1 } END { print sum }')
# crush. kill. destroy.
(( verbose )) && cmdopts+=(-v)
@@ -288,4 +297,4 @@ elif (( move )); then
runcmd mv "${cmdopts[@]}" "${candidates[@]}" "$movedir"
fi
-summarize "${candidates[@]}"
+summarize "$pkgcount" "${candidates[@]}"