Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-08-05 18:04:37 -0400
committerAllan McRae <allan@archlinux.org>2013-08-21 11:13:12 +1000
commit3d3c7ebb0dfef248c53f7cfc3730ed3fd89756a9 (patch)
treeadcc1dc75af76ff3c4a600b0427944405c219fc7
parent9085aa43224474bc2c943f4d268d8dd4b735a665 (diff)
makepkg: allow make-style environment var overrides
This allows for VAR=value and VAR+=value variable declarations. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--doc/makepkg.8.txt2
-rw-r--r--scripts/makepkg.sh.in15
2 files changed, 16 insertions, 1 deletions
diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
index 899858e4..0b548bc9 100644
--- a/doc/makepkg.8.txt
+++ b/doc/makepkg.8.txt
@@ -11,7 +11,7 @@ makepkg - package build utility
Synopsis
--------
-'makepkg' [options]
+'makepkg' [options] [ENVVAR=value[ENVVAR+=value] ...
Description
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 580f16ce..025f7564 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -2624,6 +2624,16 @@ while true; do
shift
done
+# attempt to consume any extra argv as environment variables. this supports
+# overriding (e.g. CC=clang) as well as overriding (e.g. CFLAGS+=' -g').
+extra_environment=()
+while [[ $1 ]]; do
+ if [[ $1 = [_[:alpha:]]*([[:alnum:]_])?(+)=* ]]; then
+ extra_environment+=("$1")
+ fi
+ shift
+done
+
# setup signal traps
trap 'clean_up' 0
for signal in TERM HUP QUIT; do
@@ -2706,6 +2716,11 @@ if [[ ! -w $BUILDDIR ]]; then
exit 1
fi
+# override settings from extra variables on commandline, if any
+if (( ${#extra_environment[*]} )); then
+ export "${extra_environment[@]}"
+fi
+
PKGDEST=${_PKGDEST:-$PKGDEST}
PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
if (( ! (NOBUILD || GENINTEG) )) && [[ ! -w $PKGDEST ]]; then