]> wolfpit.net Git - tool/Arch-pacman/.git/commitdiff
makepkg: allow make-style environment var overrides
authorDave Reisner <dreisner@archlinux.org>
Mon, 5 Aug 2013 22:04:37 +0000 (18:04 -0400)
committerAllan McRae <allan@archlinux.org>
Wed, 21 Aug 2013 01:13:12 +0000 (11:13 +1000)
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>
doc/makepkg.8.txt
scripts/makepkg.sh.in

index 899858e436226908f5d5b4c46afbeb8638bd5e26..0b548bc95b993f66876be6b7563bc2ab18f3af78 100644 (file)
@@ -11,7 +11,7 @@ makepkg - package build utility
 
 Synopsis
 --------
-'makepkg' [options]
+'makepkg' [options] [ENVVAR=value[ENVVAR+=value] ...
 
 
 Description
index 580f16ced2639c89080ccacf2560a667a3f7ffa5..025f756438d24b793eea39a85d291edc9958556d 100644 (file)
@@ -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