From owner-svn-src-user@FreeBSD.ORG Sun Aug 15 06:10:09 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 198E810656F2; Sun, 15 Aug 2010 06:10:09 +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 E3B6F8FC08; Sun, 15 Aug 2010 06:10:08 +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 o7F6A8Fg049806; Sun, 15 Aug 2010 06:10:08 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7F6A8KN049804; Sun, 15 Aug 2010 06:10:08 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008150610.o7F6A8KN049804@svn.freebsd.org> From: Doug Barton Date: Sun, 15 Aug 2010 06:10:08 +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: r211322 - 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: Sun, 15 Aug 2010 06:10:09 -0000 Author: dougb Date: Sun Aug 15 06:10:08 2010 New Revision: 211322 URL: http://svn.freebsd.org/changeset/base/211322 Log: Improve the regexp for parse_index() by specifying the PORTSDIR path, and not using globals. In the initialization code when using --index* set the path for the ports tree in the INDEX file with a special version of $pd, PM_IPD. We only need to set this to something other than /usr/ports if $pd is not already set, and/or it's set to something other than /usr/ports. In addition to improving the efficiency of parse_index() this has the pleasant side effect of (slightly) improving support for non-standard PORTSDIR. For -F, at the end of the run break out of the loop if the number of extant fetches is 0. This doesn't happen often, but there is a race that can cause it. Printing the message that we're waiting for zero fetches is silly; but the real problem is sleep'ing for no reason. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sat Aug 14 22:49:07 2010 (r211321) +++ user/dougb/portmaster/portmaster Sun Aug 15 06:10:08 2010 (r211322) @@ -570,16 +570,20 @@ if [ "$$" -eq "$PM_PARENT_PID" ]; then PM_INDEX_PORTS=`pkg_version -Ivl\< $PM_INDEX | cut -f1 -d\<` export PM_INDEX_PORTS - fi - if [ -z "$pd" ]; then - if [ -n "$PM_INDEX_ONLY" ]; then - pd=`head -1 $PM_INDEX | cut -f 2 -d\|` - pd=${pd%/*} - pd=${pd%/*} + if [ -z "$pd" -o "$pd" != /usr/ports ]; then + PM_IPD=`head -1 $PM_INDEX | cut -f 2 -d\|` + PM_IPD=${PM_IPD%/*} + PM_IPD=${PM_IPD%/*} + + [ -n "$PM_INDEX_ONLY" ] && pd=$PM_IPD + else + PM_IPD=$pd fi - [ -z "$pd" ] && fail 'The value of PORTSDIR cannot be empty' + export PM_IPD fi + + [ -z "$pd" ] && fail 'The value of PORTSDIR cannot be empty' if [ -z "$pdb" ]; then if [ -z "$PKG_DBDIR" ]; then [ -d /var/db/pkg ] && pdb=/var/db/pkg @@ -1006,7 +1010,7 @@ init_packages_var () { parse_index () { local line - line=`grep -m1 .*\|.*/${1}\|.* $PM_INDEX` || return 1 + line=`grep -m1 "|${PM_IPD}/${1}|" $PM_INDEX` || return 1 case "$2" in name) echo ${line%%|*} ;; @@ -2046,6 +2050,7 @@ check_fetch_only () { while `ls ${TMPDIR}/f-${PM_PARENT_PID}-fetchlog-* >/dev/null 2>&1`; do nf=`ps -ax | grep [f]etch | wc -l` nf=${nf##* } + [ "$nf" -eq 0 ] && break # Not often, but it happens fetches=fetches ; [ "$nf" -eq 1 ] && fetches=fetch echo "===>>> Waiting for ${nf##* } distfile $fetches to finish" sleep $sleep