>Number:         148528
>Category:       bin
>Synopsis:       [patch] portsnap(8): add new command mode
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>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:
>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:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to