Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/scripts/libmakepkg
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2019-05-22 10:44:27 -0400
committerAllan McRae <allan@archlinux.org>2019-05-28 12:46:44 +1000
commit27e80ca7f61d0eb9861d36c24520a3e081bcb2ec (patch)
treebf5f5ebe3a4c84ff5ef13e165b44737b3e6558b5 /scripts/libmakepkg
parenta00615bfdad628299352b94e0f44d211a758fd17 (diff)
makepkg: also move restore_envvars handling into libmakepkg
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'scripts/libmakepkg')
-rw-r--r--scripts/libmakepkg/util/config.sh.in20
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/libmakepkg/util/config.sh.in b/scripts/libmakepkg/util/config.sh.in
index 9201bc01..5e3a9b6a 100644
--- a/scripts/libmakepkg/util/config.sh.in
+++ b/scripts/libmakepkg/util/config.sh.in
@@ -54,3 +54,23 @@ source_makepkg_config() {
fi
fi
}
+
+# load makepkg.conf by sourcing the configuration files, and preserving
+# existing environment settings
+load_makepkg_config() {
+ # $1: override system config file
+
+ local MAKEPKG_CONF=${1:-${MAKEPKG_CONF:-@sysconfdir@/makepkg.conf}}
+
+ # preserve environment variables to override makepkg.conf
+ local restore_envvars=$(
+ for var in PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR PKGEXT SRCEXT GPGKEY PACKAGER CARCH; do
+ # the output of 'declare -p' results in locally scoped values when used within a function
+ [[ -v $var ]] && printf '%s=%s\n' "$var" "${!var@Q}"
+ done
+ )
+
+ source_makepkg_config "$MAKEPKG_CONF"
+
+ eval "$restore_envvars"
+}