portmaster -x not working?
Lawrence Stewart
lstewart at freebsd.org
Sat Aug 8 18:45:11 UTC 2009
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
-------------- next part --------------
--- 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
More information about the freebsd-ports
mailing list