Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Aug 2010 06:10:08 +0000 (UTC)
From:      Doug Barton <dougb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r211322 - user/dougb/portmaster
Message-ID:  <201008150610.o7F6A8KN049804@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008150610.o7F6A8KN049804>