From nobody@FreeBSD.org  Mon Jul 12 19:33:12 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4409B1065670
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 12 Jul 2010 19:33:12 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 3454D8FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 12 Jul 2010 19:33:12 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o6CJXBPk092572
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 12 Jul 2010 19:33:11 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o6CJXBAV092571;
	Mon, 12 Jul 2010 19:33:11 GMT
	(envelope-from nobody)
Message-Id: <201007121933.o6CJXBAV092571@www.freebsd.org>
Date: Mon, 12 Jul 2010 19:33:11 GMT
From: Galimov Albert <wtfcrap@mail.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] portsnap(8): add new command mode
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         148528
>Category:       bin
>Synopsis:       [patch] portsnap(8): add new command mode
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    cperciva
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 12 19:40:00 UTC 2010
>Closed-Date:    
>Last-Modified:  Mon Jul 12 20:28:51 UTC 2010
>Originator:     Galimov Albert
>Release:        HEAD
>Organization:
>Environment:
>Description:
Add new "list" command to portsnap(8). It displays origins ready to be added/updated and origins to be deleted on next "update" invocation.
This is useful for users who wait some port updates, and for users who do not want specific updates.
>How-To-Repeat:

>Fix:
Patch included 

Patch attached with submission follows:

Index: portsnap.sh
===================================================================
--- portsnap.sh	(revision 209954)
+++ portsnap.sh	(working copy)
@@ -58,6 +58,7 @@
                   files and directories.
   update       -- Update ports tree to match current snapshot, replacing
                   files and directories which have changed.
+  list         -- List origins prepared to update
 EOF
 	exit 0
 }
@@ -140,7 +141,7 @@
 			if [ ! -z "${SERVERNAME}" ]; then usage; fi
 			shift; SERVERNAME="$1"
 			;;
-		cron | extract | fetch | update | alfred)
+		cron | extract | fetch | update | alfred | list)
 			COMMANDS="${COMMANDS} $1"
 			;;
 		*)
@@ -982,6 +983,53 @@
 	extract_indices
 }
 
+# Do the actual work involved in "list"
+list_run() {
+	if sort ${WORKDIR}/INDEX |
+	    cmp -s ${PORTSDIR}/.portsnap.INDEX -; then
+		echo "Ports tree is already up to date."
+		return 0
+	fi
+
+	TMPFILE=`mktemp /tmp/portsnap.XXXXXX` || exit 1
+	echo "Files and directories to be updated/added: "
+	if !
+		if ! [ -z "${REFUSE}" ]; then
+			grep -vE "${REFUSE}" ${WORKDIR}/INDEX | sort
+		else
+			sort ${WORKDIR}/INDEX
+		fi |
+	    comm -13 ${PORTSDIR}/.portsnap.INDEX - |
+	    while read LINE; do
+		FILE=`echo ${LINE} | cut -f 1 -d '|'`
+		HASH=`echo ${LINE} | cut -f 2 -d '|'`
+		if ! [ -r "${WORKDIR}/files/${HASH}.gz" ]; then
+			echo "files/${HASH}.gz not found -- snapshot corrupt."
+			return 1
+		fi
+		echo "$FILE"
+		echo "$FILE" >> $TMPFILE
+	done; then
+		return 1
+	fi
+
+	echo ""
+	echo "Files and directories to be deleted: "
+
+# If we are REFUSEing to touch certain directories, don't remove files
+# from those directories (even if they are out of date)
+	if ! [ -z "${REFUSE}" ]; then 
+		sort ${WORKDIR}/INDEX |
+		    comm -23 ${PORTSDIR}/.portsnap.INDEX - | cut -f 1 -d '|' |
+		    grep -vE "${REFUSE}" |  comm -13 $TMPFILE - | xargs -n 1 echo
+	else
+		sort ${WORKDIR}/INDEX |
+		    comm -23 ${PORTSDIR}/.portsnap.INDEX - | cut -f 1 -d '|' |
+		    comm -13 $TMPFILE - | xargs -n 1 echo
+	fi
+	rm $TMPFILE
+}
+
 #### Main functions -- call parameter-handling and core functions
 
 # Using the command line, configuration file, and defaults,
@@ -1056,6 +1104,11 @@
 	fi
 }
 
+# List command. Show origins fetched and ready to update
+cmd_list() {
+	list_run || exit 1
+}
+
 #### Entry point
 
 # Make sure we find utilities from the base system
Index: portsnap.8
===================================================================
--- portsnap.8	(revision 209954)
+++ portsnap.8	(working copy)
@@ -160,6 +160,12 @@
 commands.
 Again, note that in the parts of the ports tree which are being
 updated, any local changes or additions will be removed.
+.It list
+List origins prepared to 
+.Cm update
+via 
+.Cm fetch
+command.
 .El
 .Sh TIPS
 .Bl -bullet


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->cperciva 
Responsible-Changed-By: remko 
Responsible-Changed-When: Mon Jul 12 20:28:31 UTC 2010 
Responsible-Changed-Why:  
Colin, this is your application, can you have a look at this please? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=148528 
>Unformatted:
