git-pbuilder: export GBP_{DIST,ARCH,BUILDER} to the environment
authorGuido Günther <agx@sigxcpu.org>
Wed, 3 Aug 2022 17:31:10 +0000 (19:31 +0200)
committerGuido Günther <agx@sigxcpu.org>
Wed, 3 Aug 2022 17:36:43 +0000 (19:36 +0200)
This makes sure we don't export very generic vars while still being able
to make decisions based on what was passed to gbp.

bin/git-pbuilder

index 9161b4f2c6c9243f3c89d07d0ae8f9458d162ea2..545ed8d380420c1a53f9afa60b2dbac135679461 100755 (executable)
@@ -39,7 +39,12 @@ shell_quote () {
 
 # unset variables we inherited from the environment ourselfes
 # Names like DIST are very generic and can trip up other build systems
-unset_env() {
+# so unset these and set some prefixed ones instead so they can e.g.
+# be used in .pbuilderrc.
+update_env() {
+     [ -z "$DIST" -o -n "$GBP_DIST" ] || export GBP_DIST=$DIST
+     [ -z "$BUILDER" -o -n "$GBP_BUILDER" ] || export GBP_BUILDER=$BUILDER
+     [ -z "$ARCH" -o -n "$GBP_ARCH" ] || export GBP_ARCH=$ARCH
     export -n DIST BUILDER ARCH
 }
 
@@ -351,7 +356,7 @@ done
 
 # Now we can finally run pdebuild.  The quoting here is tricky, but this
 # seems to pass everything through properly.
-unset_env
+update_env
 if [ no = "$GIT_PBUILDER_AUTOCONF" ] ; then
     set -e
     [ ! "$GIT_PBUILDER_DEBUG" ] || set -x