From owner-svn-src-user@FreeBSD.ORG Fri Jul 23 23:58:57 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 918961065679; Fri, 23 Jul 2010 23:58:57 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 757D68FC16; Fri, 23 Jul 2010 23:58:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o6NNwvJZ056480; Fri, 23 Jul 2010 23:58:57 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o6NNwvZI056478; Fri, 23 Jul 2010 23:58:57 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201007232358.o6NNwvZI056478@svn.freebsd.org> From: Doug Barton Date: Fri, 23 Jul 2010 23:58:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r210440 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jul 2010 23:58:57 -0000 Author: dougb Date: Fri Jul 23 23:58:57 2010 New Revision: 210440 URL: http://svn.freebsd.org/changeset/base/210440 Log: By popular demand, add an option to --clean-distfiles[-all] to allow a distfile to be valid if it matches ANY port in the tree, not just those installed. This requires building a distinfo list from all ports, so duplicate the relevant bits of read_distinfos() into read_distinfos_all(). The common elements are split into during the loop and after the loop, so making 4 functions total doesn't seem worth it. Add logic to --clean-distfiles to handle the -t option and call the right read_distinfos* function accordingly. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Fri Jul 23 22:49:25 2010 (r210439) +++ user/dougb/portmaster/portmaster Fri Jul 23 23:58:57 2010 (r210440) @@ -291,8 +291,8 @@ usage () { echo '' echo "${0##*/} [--force-config|-G] [-aftv] -F" echo '' - echo "${0##*/} --clean-distfiles" - echo "${0##*/} --clean-distfiles-all" + echo "${0##*/} [-t] --clean-distfiles" + echo "${0##*/} [-t] --clean-distfiles-all" echo '' echo "${0##*/} [--index] --clean-packages" echo "${0##*/} [--index] --clean-packages-all" @@ -365,8 +365,9 @@ usage () { echo '' echo '[--force-config|-G] [-aftv] -F fetch distfiles only' echo '' - echo '--clean-distfiles offer to delete stale distfiles' - echo '--clean-distfiles-all delete stale distfiles without prompting' + echo '[-t] --clean-distfiles offer to delete stale distfiles' + echo '[-t] --clean-distfiles-all delete stale distfiles without prompting' + echo ' with -t distfile is valid from any port, not just those installed' echo '' echo '[--index] --clean-packages offer to delete stale packages' echo '[--index] --clean-packages-all delete stale packages without prompting' @@ -897,6 +898,40 @@ read_distinfos () { [ -e "${DI_FILES}-e" ] && unlink ${DI_FILES}-e } +read_distinfos_all () { + local origin distinfo disc1 f disc2 + + echo '############' > $DI_FILES # Make the file > 0 bytes + echo "===>>> Gathering distinfo list for all ports" + echo ' (This will take several minutes)' + echo '' + for origin in ${pd}/*/*; do + case "${origin#$pd/}" in + Mk/*|T*|distfiles/*|packages/*|*/[Mm]akefile) continue ;; esac + + [ -d "$origin" ] || continue + pm_cd $origin || continue + + if [ -s distinfo ]; then + distinfo=distinfo + else + distinfo=`pm_make -V MD5_FILE` + fi + + if [ -s "$distinfo" ]; then + grep '^MD5' $distinfo | while read disc1 f disc2; do + f=${f#(} ; f=${f%)} + echo $f >> $DI_FILES + done + fi + done + + # Tell safe_exit that we are done + [ -e "${DI_FILES}-e" ] && unlink ${DI_FILES}-e + sed -i -e 1s/############/%%%%%%%%%%%%/ $DI_FILES + [ -e "${DI_FILES}-e" ] && unlink ${DI_FILES}-e +} + globstrip () { local in @@ -1007,7 +1042,12 @@ if [ -n "$CLEAN_DISTFILES" ]; then # Set the file name here since we are usually called in a subshell DI_FILES=`pm_mktemp DI-FILES` - read_distinfos + + if [ "$1" != '-t' ]; then + read_distinfos + else + read_distinfos_all + fi echo "===>>> Checking for stale distfiles" for df in `find $DISTDIR -type f | sort`; do