From owner-svn-src-user@FreeBSD.ORG Mon May 10 06:59:08 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3F7B81065676; Mon, 10 May 2010 06:59:08 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 2E9338FC1E; Mon, 10 May 2010 06:59: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 o4A6x8EA076538; Mon, 10 May 2010 06:59:08 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o4A6x7ji076537; Mon, 10 May 2010 06:59:07 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201005100659.o4A6x7ji076537@svn.freebsd.org> From: Doug Barton Date: Mon, 10 May 2010 06:59:07 +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: r207841 - 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: Mon, 10 May 2010 06:59:08 -0000 Author: dougb Date: Mon May 10 06:59:07 2010 New Revision: 207841 URL: http://svn.freebsd.org/changeset/base/207841 Log: Allow setting of DISTDIR directly in .portmasterrc like the other widely used vars. This entails the following: 1. Capitalize distdir every place that it's used. 2. Add to the list of --options to check which mean we don't even have to try to set it. This saves us a call to make(1). 3. Don't set it to / if DISTDIR is empty, which makes error checking later on easier. 4. Mark DISTDIR (and related vars) global in a few more functions to make it consistent. While I'm here, move the test for version > 6.4 first in the list, no point in processing a bunch of stuff only to bail out later. Unset the test_command_line function when we're done using it Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Mon May 10 03:13:23 2010 (r207840) +++ user/dougb/portmaster/portmaster Mon May 10 06:59:07 2010 (r207841) @@ -496,6 +496,11 @@ unset var # Do this here so it can use the fancy functions above, and default values # can be overridden in the rc files if [ "$$" -eq "$PM_PARENT_PID" ]; then + if [ -n "$PM_PACKAGES" -o -n "$PM_PACKAGES_BUILD" ]; then + [ `/sbin/sysctl -n kern.osreldate 2>/dev/null` -lt 600400 ] && + fail Package installation support requires FreeBSD 6.4 or newer + fi + if [ -z "$pd" ]; then if [ -z "$PORTSDIR" ]; then [ -d /usr/ports ] && pd=/usr/ports @@ -570,12 +575,13 @@ if [ "$$" -eq "$PM_PARENT_PID" ]; then fi fi fi - if [ -z "$distdir" -a "$PM_PACKAGES" != only ]; then - distdir=`pm_make_b -f/usr/share/mk/bsd.port.mk -V DISTDIR 2>/dev/null` - # In case it is a symlink - distdir="${distdir%/}/" + export pd pdb + + if [ -z "$DISTDIR" -a "$PM_PACKAGES" != only -a -z "$CHECK_DEPENDS" -a \ + -z "$CHECK_PORT_DBDIR" -a -z "$LIST_ORIGINS" ]; then + DISTDIR=`pm_make_b -f/usr/share/mk/bsd.port.mk -V DISTDIR 2>/dev/null` fi - export pd pdb distdir + [ -n "$DISTDIR" ] && { DISTDIR="${DISTDIR%/}/"; export DISTDIR; } [ -z "$port_dbdir" -a -d /var/db/ports ] && port_dbdir=/var/db/ports [ -z "$port_dbdir" ] && @@ -586,10 +592,6 @@ if [ "$$" -eq "$PM_PARENT_PID" ]; then PM_BUILD_ONLY_LIST=pm_bol export PM_BUILD_ONLY_LIST fi - if [ -n "$PM_PACKAGES" -o -n "$PM_PACKAGES_BUILD" ]; then - [ `/sbin/sysctl -n kern.osreldate 2>/dev/null` -lt 600400 ] && - fail Package installation support requires FreeBSD 6.4 or newer - fi fi set -- $newopts @@ -901,8 +903,8 @@ ports_by_category () { delete_empty_dist_subdirs () { # Get back to somewhere safe so we do not # delete our CWD out from under ourselves - pm_cd $distdir || fail "Cannot cd into $distdir" - find -d $distdir -type d \( -empty -and ! -path \*\.zfs/\* \) -delete + pm_cd $DISTDIR || fail "Cannot cd into $DISTDIR" + find -d $DISTDIR -type d \( -empty -and ! -path \*\.zfs/\* \) -delete } # Takes a pattern as input @@ -933,15 +935,15 @@ find_glob_dirs () { #=============== Begin code relevant only to --features =============== if [ -n "$CLEAN_DISTFILES" ]; then - [ "$distdir" != '/' ] || fail 'There is no DISTDIR to clean' + [ -n "$DISTDIR" ] || fail 'There is no DISTDIR to clean' # Set the file name here since we are usually called in a subshell DI_FILES=`pm_mktemp DI-FILES` read_distinfos echo "===>>> Checking for stale distfiles" - for df in `find $distdir -type f | sort`; do - f=${df#$distdir} + for df in `find $DISTDIR -type f | sort`; do + f=${df#$DISTDIR} if ! grep -ql $f $DI_FILES; then if [ -n "$ALL" ]; then echo "===>>> Deleting $f" @@ -1181,6 +1183,7 @@ if [ -n "$LIST" -o -n "$LIST_PLUS" ]; th [ $# -gt 0 ] && fail 'The -[lL] options are not compatible with updates or installs' fi unset my_environment +unset -f test_command_line #=============== Begin functions for getopts features and main =============== @@ -1484,10 +1487,10 @@ delete_dist_list () { } find_and_delete_distfiles () { - # Global: distfiles distfiles_checked delete_all + # Global: port_subdir DISTDIR distfiles distfiles_checked delete_all local ps pattern file answer - ps=${port_subdir#$distdir} + ps=${port_subdir#$DISTDIR} pattern=${1%[_-]*} for file in ${pattern}*; do @@ -1532,7 +1535,7 @@ find_and_delete_distfiles () { } set_distfiles_and_subdir () { - # Global: dist_list_files distfiles port_subdir distdir + # Global: dist_list_files distfiles port_subdir DISTDIR [ -z "$dist_list_files" ] && find_dl_distfiles $1 @@ -1552,9 +1555,9 @@ set_distfiles_and_subdir () { if [ -z "$port_subdir" ]; then port_subdir=`pm_make -V DIST_SUBDIR` if [ -n "$port_subdir" ]; then - port_subdir="${distdir}${port_subdir}/" + port_subdir="${DISTDIR}${port_subdir}/" else - port_subdir=$distdir + port_subdir=$DISTDIR fi fi if [ -d "$port_subdir" ]; then @@ -1621,7 +1624,7 @@ delete_stale_distfiles () { } delete_all_distfiles () { - # Global: delete_all distdir + # Global: delete_all DISTDIR local origin rc delete_current # In case we are called more than once @@ -1640,9 +1643,9 @@ delete_all_distfiles () { local answer f ; read answer case "$answer" in [yY]) for f in $dist_list_files; do - if [ -f "${distdir}${f}" ]; then - echo " Deleting ${distdir}${f}" - pm_unlink ${distdir}${f} + if [ -f "${DISTDIR}${f}" ]; then + echo " Deleting ${DISTDIR}${f}" + pm_unlink ${DISTDIR}${f} fi done ;; esac @@ -1822,7 +1825,8 @@ fi #=============== End code relevant only to getopts features =============== -[ "$distdir" = '/' -a "$PM_PACKAGES" != only ] && fail 'The value of DISTDIR cannot be empty' +[ -z "$DISTDIR" -a "$PM_PACKAGES" != only -a -z "$DONT_SCRUB_DISTFILES" ] && + fail 'The value of DISTDIR cannot be empty' #=============== Begin functions for main =============== @@ -3371,7 +3375,7 @@ if [ -n "$distfiles" ]; then ds=`pm_make -V DIST_SUBDIR` [ -n "$ds" ] && ds="${ds}/" - port_subdir="${distdir}${ds}" # Also for *delete*distfiles() + port_subdir="${DISTDIR}${ds}" # Also for *delete*distfiles() if [ -s distinfo ]; then distinfo=distinfo