diff options
Diffstat (limited to 'ports-mgmt')
-rw-r--r-- | ports-mgmt/pkg-rmleaf/Makefile | 2 | ||||
-rw-r--r-- | ports-mgmt/pkg-rmleaf/files/pkg-rmleaf | 43 |
2 files changed, 29 insertions, 16 deletions
diff --git a/ports-mgmt/pkg-rmleaf/Makefile b/ports-mgmt/pkg-rmleaf/Makefile index aeb9675722ee..7bda8a05e764 100644 --- a/ports-mgmt/pkg-rmleaf/Makefile +++ b/ports-mgmt/pkg-rmleaf/Makefile @@ -2,7 +2,7 @@ # $FreeBSD$ PORTNAME= pkg-rmleaf -PORTVERSION= 0.2 +PORTVERSION= 0.3 CATEGORIES= ports-mgmt MASTER_SITES= # none DISTFILES= # none diff --git a/ports-mgmt/pkg-rmleaf/files/pkg-rmleaf b/ports-mgmt/pkg-rmleaf/files/pkg-rmleaf index 381827d89cf9..c1bd18b94e8b 100644 --- a/ports-mgmt/pkg-rmleaf/files/pkg-rmleaf +++ b/ports-mgmt/pkg-rmleaf/files/pkg-rmleaf @@ -1,6 +1,8 @@ #!/bin/sh -# Copyright (c) 2013 Yanhui Shen, shen.elf@gmail.c0m +# version 0.3 + +# Copyright (c) 2014 Yanhui Shen, shen.elf@gmail.c0m # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -24,28 +26,39 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -#Twiddle="echo '|/-\\' | cut -c" -PkgQuery="pkg query -e \"%#r=0\" \"%o#%c\" | sort" +cols=$((`stty size | cut -w -f2` - 6)) +rows=$((`stty size | cut -w -f1` - 4)) +height=$(($rows - 7)) +sep="#" +PkgQuery="pkg query -e \"%#r=0\" \"%o$sep%c\" | sort" PkgDelete="pkg delete -y" -DialogList="dialog --stdout --checklist \"leaf packages (%s)\" 30 90 30" +FmtDialog="dialog --checklist \"Leaf Packages: %s\" $rows $cols $height %s" KeptLeaves="" while true; do #==== refresh leaves ==== - echo "Calculating..." + echo "Querying..." AllLeaves=`eval $PkgQuery` NewLeaves="" nNewLeaves="0" - #n="0" - IFS=$'\n' + + #IFS=$'\n' + # see http://svnweb.freebsd.org/base?view=revision&revision=221513 + # for compatibility, use the following trick instead + IFS=" +" for line in $AllLeaves; do - # print twiddle will be a little slower - #n=$(($n % 4 + 1)) - #ch=`eval "$Twiddle $n"` - #printf "Calculating...%s\r" "$ch" + case $line in + (*"$sep"*) + port=${line%%"$sep"*} + desc=${line#*"$sep"} + ;; + (*) + echo "Bad line: " $line + exit + ;; + esac - port=`echo "$line" | cut -d'#' -f1` - desc=`echo "$line" | cut -d'#' -f2 | sed -e 's/\"/\\\"/g'` ret=`echo "$KeptLeaves" | grep "$port"` if [ -z "$ret" ]; then NewLeaves="$NewLeaves $port \"$desc\" off" @@ -58,8 +71,8 @@ while true; do echo "Nothing to do!" exit fi - cmd=`printf $DialogList "$nNewLeaves"` - selections=`eval "$cmd $NewLeaves"` + cmd=`printf $FmtDialog "$nNewLeaves" "$NewLeaves"` + selections=`eval "$cmd 3>&2 2>&1 1>&3"` if [ $? -ne 0 ]; then echo "Canceled." exit |