From 27e80ca7f61d0eb9861d36c24520a3e081bcb2ec Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 22 May 2019 10:44:27 -0400 Subject: makepkg: also move restore_envvars handling into libmakepkg Signed-off-by: Eli Schwartz Signed-off-by: Allan McRae --- scripts/libmakepkg/util/config.sh.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'scripts/libmakepkg') 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" +} -- cgit v1.2.3-54-g00ecf