From owner-freebsd-bugs@FreeBSD.ORG Mon Jul 12 19:40:01 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE3B6106564A for ; Mon, 12 Jul 2010 19:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 911FF8FC1D for ; Mon, 12 Jul 2010 19:40:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o6CJe1X1042827 for ; Mon, 12 Jul 2010 19:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o6CJe1FV042826; Mon, 12 Jul 2010 19:40:01 GMT (envelope-from gnats) Resent-Date: Mon, 12 Jul 2010 19:40:01 GMT Resent-Message-Id: <201007121940.o6CJe1FV042826@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Galimov Albert Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4409B1065670 for ; 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 ; 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 ; 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 To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/148528: [patch] portsnap(8): add new command mode X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2010 19:40:01 -0000 >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: