[pacman-dev] [PATCH] contrib/paccache: misc cleanup and bugfix
* add paccache to .gitignore * change error verbiage when run as root * delete sigs along with packages * fix bug in diskspace calculations Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- This should cover Allan and Dan's concerns, as well as addressing a silly bug I found in counting diskspace saved. contrib/paccache.in | 28 ++++++++++++++++++++-------- 1 files changed, 20 insertions(+), 8 deletions(-) diff --git a/contrib/paccache.in b/contrib/paccache.in index 0bd0cf7..34ca06b 100755 --- a/contrib/paccache.in +++ b/contrib/paccache.in @@ -110,10 +110,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 +143,7 @@ runcmd() { } summarize() { - local -i filecount=$# + local -i filecount=$1; shift local seenarch= seen= arch= name= local -r pkg_re='(.+)-[^-]+-[0-9]+-([^.]+)\.pkg.*' @@ -204,7 +205,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 +278,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 +300,4 @@ elif (( move )); then runcmd mv "${cmdopts[@]}" "${candidates[@]}" "$movedir" fi -summarize "${candidates[@]}" +summarize "$pkgcount" "${candidates[@]}" -- 1.7.6
On 03/08/11 14:52, Dave Reisner wrote:
* add paccache to .gitignore
Hmmm.... where?
* change error verbiage when run as root * delete sigs along with packages * fix bug in diskspace calculations
Signed-off-by: Dave Reisner<dreisner@archlinux.org> --- This should cover Allan and Dan's concerns, as well as addressing a silly bug I found in counting diskspace saved.
contrib/paccache.in | 28 ++++++++++++++++++++-------- 1 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/contrib/paccache.in b/contrib/paccache.in index 0bd0cf7..34ca06b 100755 --- a/contrib/paccache.in +++ b/contrib/paccache.in @@ -110,10 +110,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 +143,7 @@ runcmd() { }
summarize() { - local -i filecount=$# + local -i filecount=$1; shift local seenarch= seen= arch= name= local -r pkg_re='(.+)-[^-]+-[0-9]+-([^.]+)\.pkg.*'
@@ -204,7 +205,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 +278,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 +300,4 @@ elif (( move )); then runcmd mv "${cmdopts[@]}" "${candidates[@]}" "$movedir" fi
-summarize "${candidates[@]}" +summarize "$pkgcount" "${candidates[@]}"
On Wed, Aug 03, 2011 at 01:02:49AM -0400, Dave Reisner wrote:
On Wed, Aug 03, 2011 at 03:00:40PM +1000, Allan McRae wrote:
On 03/08/11 14:52, Dave Reisner wrote:
* add paccache to .gitignore
Hmmm.... where?
Nowhere. It's in my tree but amended to my previous crap since Dan already merged the earlier patch. Le sigh, rebasing...
Disregard... Dan added it for me when he merged aforementioned crap. He can munch up the commit message on the patch too. d
participants (2)
-
Allan McRae
-
Dave Reisner