1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-21 00:25:50 +00:00

Update to 0.3.

PR:		191577
Submitted by:	shen.elf@gmail.com (maintainer)
This commit is contained in:
Raphael Kubo da Costa 2014-07-09 18:02:58 +00:00
parent ae33ac8e60
commit 5823055b72
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=361398
2 changed files with 30 additions and 17 deletions

View File

@ -2,7 +2,7 @@
# $FreeBSD$
PORTNAME= pkg-rmleaf
PORTVERSION= 0.2
PORTVERSION= 0.3
CATEGORIES= ports-mgmt
MASTER_SITES= # none
DISTFILES= # none

View File

@ -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'
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"
port=`echo "$line" | cut -d'#' -f1`
desc=`echo "$line" | cut -d'#' -f2 | sed -e 's/\"/\\\"/g'`
#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
case $line in
(*"$sep"*)
port=${line%%"$sep"*}
desc=${line#*"$sep"}
;;
(*)
echo "Bad line: " $line
exit
;;
esac
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