From owner-freebsd-ports@FreeBSD.ORG Sat Aug 8 18:45:11 2009 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 360881065672; Sat, 8 Aug 2009 18:45:11 +0000 (UTC) (envelope-from lstewart@freebsd.org) Received: from lauren.room52.net (lauren.room52.net [210.50.193.198]) by mx1.freebsd.org (Postfix) with ESMTP id B72C48FC22; Sat, 8 Aug 2009 18:45:10 +0000 (UTC) Received: from lstewart-laptop.caia.swin.edu.au (host86-144-70-159.range86-144.btcentralplus.com [86.144.70.159]) (authenticated bits=0) by lauren.room52.net (8.14.3/8.14.3) with ESMTP id n78Iimxx067616 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 9 Aug 2009 04:44:52 +1000 (EST) (envelope-from lstewart@freebsd.org) Message-ID: <4A7DC792.2080200@freebsd.org> Date: Sat, 08 Aug 2009 19:44:34 +0100 From: Lawrence Stewart User-Agent: Thunderbird 2.0.0.22 (X11/20090808) MIME-Version: 1.0 To: Frederique Rijsdijk References: <4A5C954C.5060507@quip.cz> <4A5C9A98.5020006@isafeelin.org> <4A5CA8CF.2070906@freebsd.org> <4A5D9FD8.3080209@isafeelin.org> <4A5E02DE.1010908@freebsd.org> In-Reply-To: <4A5E02DE.1010908@freebsd.org> Content-Type: multipart/mixed; boundary="------------020707040308010606030506" X-Spam-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_PBL, RCVD_IN_SORBS_DUL, RDNS_DYNAMIC, SPF_SOFTFAIL autolearn=disabled version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on lauren.room52.net Cc: dougb@freebsd.org, Miroslav Lachman <000.fbsd@quip.cz>, freebsd-ports@freebsd.org Subject: Re: portmaster -x not working? X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Aug 2009 18:45:11 -0000 This is a multi-part message in MIME format. --------------020707040308010606030506 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Lawrence Stewart wrote: > Frederique Rijsdijk wrote: >> Lawrence Stewart wrote: >>> Hijacking the thread slightly, but is there a way to exclude multiple >>> ports using the -x switch (or multiple -x switches)? Logically, I want >>> to be able to do something like this: >>> >>> portmaster -a -x '*foo*' -x '*bar*' >>> >> >> portmaster -x '[.*php5.*|.*apache.*]' -n drupal6-6.12 >> >> That seems to work for me.. >> > > Nifty, although regex goo is unfriendly even at the best of times. > > Thanks for the tip (and sorry for the hijack). Today, I again had need of the ability to exclude multiple ports from an update run. It turns out your tip doesn't work with portmaster, though I suspect it would with portupgrade. I finally bit the bullet and created a patch that allows a user to specify -x multiple times, or specify it once with a space-separated list of port globs. Example usage with the patch applied: Update everything, ignoring ports that match *postgres*: portmaster -adx 'postgres' Update everything, ignoring ports that match *postgres* or *imap-uw*: portmaster -adx 'postgres imap-uw' portmaster -adx 'postgres' -x 'imap-uw' Doug, what do you think of the attached patch? Cheers, Lawrence --------------020707040308010606030506 Content-Type: text/plain; name="pm2.9_multiexclude.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pm2.9_multiexclude.diff" --- portmaster.orig 2009-08-08 22:13:01.000000000 +1000 +++ portmaster 2009-08-09 04:24:34.000000000 +1000 @@ -618,17 +618,21 @@ } globstrip () { + local glob + local globs local in - in=$1 + globs="$1" - case "$in" in - *\*) in=`echo $in | sed s/.$//` - esac - - in=${in%\\} + for glob in $globs + do + case "$glob" in + *\*) glob=`echo $glob | sed s/.$//` + esac + in="${glob%\\} $in" + done - echo $in + echo "${in%% }" } #=============== End functions relevant to --features and main =============== @@ -801,7 +805,7 @@ u) echo "===>>> The -u option has been deprecated" ; echo '' ;; v) PM_VERBOSE=vopt; ARGS="-v $ARGS" ;; w) SAVE_SHARED=wopt; ARGS="-w $ARGS" ;; - x) EXCL=`globstrip $OPTARG` ;; + x) EXCL="`globstrip "$OPTARG"` ${EXCL}" ; EXCL="${EXCL%% }" ;; *) echo '' ; echo "===>>> Try ${0##*/} --help"; exit 1 ;; esac done @@ -818,7 +822,7 @@ if [ -n "$EXCL" ]; then case "$EXCL" in -*) fail 'The -x option requires an argument' ;; - *) ARGS="-x $EXCL $ARGS" ;; + *) ARGS="-x '$EXCL' $ARGS" ;; esac fi @@ -1461,16 +1465,21 @@ } check_exclude () { + local glob + [ -n "$EXCL" ] || return 0 - case "$1" in - *${EXCL}*) - if [ -n "$PM_VERBOSE" ]; then - echo "===>>> Skipping $1" - echo " because it matches the pattern: *${EXCL}*" - fi - return 1 ;; - esac + for glob in $EXCL + do + case "$1" in + *$glob*) + if [ -n "$PM_VERBOSE" ]; then + echo "===>>> Skipping $1" + echo " because it matches the pattern: *$glob*" + fi + return 1 ;; + esac + done return 0 } @@ -1509,7 +1518,7 @@ [ -n "$DEPTH" ] && echo " $DEPTH >> ${1#$pd/}" if [ -z "$NO_ACTION" -o -n "$CONFIG_ONLY" ]; then - ($0 $ARGS $1) || fail "Update for $1 failed" + (eval $0 $ARGS $1) || fail "Update for $1 failed" . $IPC_SAVE else [ -n "$PM_VERBOSE" ] && @@ -1701,7 +1710,7 @@ if [ -n "$CONFIG_ONLY" ]; then for port in $worklist; do check_interactive $port || continue - ($0 $ARGS $port) || fail "Update for $port failed" + (eval $0 $ARGS $port) || fail "Update for $port failed" . $IPC_SAVE done check_fetch_only @@ -1721,7 +1730,7 @@ ;; esac check_interactive $port || continue - ($0 $ARGS $port) || fail "Update for $port failed" + (eval $0 $ARGS $port) || fail "Update for $port failed" . $IPC_SAVE done safe_exit @@ -1968,7 +1977,7 @@ [ -d "$pd/$moved_npd" ] || no_valid_port if [ "$$" -eq "$PARENT_PID" ]; then - $0 $ARGS -o $moved_npd $upg_port + eval $0 $ARGS -o $moved_npd $upg_port safe_exit else exec $0 $ARGS -o $moved_npd $upg_port --- portmaster.8.orig 2009-08-09 04:28:51.000000000 +1000 +++ portmaster.8 2009-08-09 04:36:49.000000000 +1000 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD: ports/ports-mgmt/portmaster/files/portmaster.8,v 2.8 2009/07/29 23:26:14 dougb Exp $ .\" -.Dd July 29, 2009 +.Dd August 8, 2009 .Dt PORTMASTER 8 .Os .Sh NAME @@ -296,7 +296,9 @@ any arguments to supply to .Xr make 1 .It Fl x -avoid building or updating ports that match this pattern +avoid building or updating ports that match this pattern. +Can be specified multiple times, or supplied as a space-separated list of port +globs surrounded by ''. .It Fl p Ar port directory in /usr/ports specify the full path to a port directory .It Fl -show-work --------------020707040308010606030506--