On 4/16/19 12:59 PM, Dave Reisner wrote: > On Tue, Apr 16, 2019 at 12:22:38PM -0400, Eli Schwartz wrote: >> Signed-off-by: Eli Schwartz <[email protected]> >> --- >> scripts/libmakepkg/util/config.sh.in | 20 ++++++++++++++++++++ >> scripts/makepkg.sh.in | 6 +----- >> 2 files changed, 21 insertions(+), 5 deletions(-) >> >> diff --git a/scripts/libmakepkg/util/config.sh.in >> b/scripts/libmakepkg/util/config.sh.in >> index fdfeef89..2a6a0ae3 100644 >> --- a/scripts/libmakepkg/util/config.sh.in >> +++ b/scripts/libmakepkg/util/config.sh.in >> @@ -53,3 +53,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:-@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 >> + # declare -p does not work inside a function due to >> being marked as local >> + [[ -v $var ]] && printf '%s=%s\n' "$var" "${var@Q}" > > Shouldn't this be "${!var@Q}"?
Oops, will fix.
>> + done
>> + )
>> +
>> + source_makepkg_config "$MAKEPKG_CONF"
>> +
>> + eval "$restore_envvars"
>> +}
>> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
>> index 08ec2a15..7a65d0f2 100644
>> --- a/scripts/makepkg.sh.in
>> +++ b/scripts/makepkg.sh.in
>> @@ -1098,15 +1098,11 @@ 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)
>>
>> # default config is makepkg.conf
>> MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg.conf}
>>
>> -source_makepkg_config "$MAKEPKG_CONF"
>> -
>> -eval "$restore_envvars"
>> +load_makepkg_config "$MAKEPKG_CONF"
>>
>> # override settings from extra variables on commandline, if any
>> if (( ${#extra_environment[*]} )); then
>> --
>> 2.21.0
--
Eli Schwartz
Bug Wrangler and Trusted User
signature.asc
Description: OpenPGP digital signature
