makepkg: also move restore_envvars handling into libmakepkg
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
a00615bfda
commit
27e80ca7f6
2 changed files with 21 additions and 6 deletions
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -1100,12 +1100,7 @@ done
|
|||
trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT
|
||||
trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
||||
|
||||
# preserve environment variables to override makepkg.conf
|
||||
restore_envvars=$(declare -p PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR PKGEXT SRCEXT GPGKEY PACKAGER CARCH 2>/dev/null || true)
|
||||
|
||||
source_makepkg_config
|
||||
|
||||
eval "$restore_envvars"
|
||||
load_makepkg_config
|
||||
|
||||
# override settings from extra variables on commandline, if any
|
||||
if (( ${#extra_environment[*]} )); then
|
||||
|
|
Loading…
Add table
Reference in a new issue