[devtools,7/7] mkarchroot: Don't let the environment affect pacstrap (sans proxy settings).

Message ID 20170405193603.22277-8-lukeshu@lukeshu.com
State Accepted
Headers show
Series [devtools,1/7] Handle makepkg.conf more consistently | expand

Commit Message

Luke Shumaker April 5, 2017, 7:36 p.m. UTC
From: Luke Shumaker <lukeshu@parabola.nu>

A previous iteration of this change (libretools commit d7dcce53396d)
simply inserted `env -i` to clear the environment.

However, that lead to it ignoring proxy settings, which some users had
problems with:

    > To fix other bugs, the pacstrap environment is blank, which also
    > means that the proxy settings are blank.

So (in libretools commit d17d1d82349f), I changed it to use `declare
-x` to inspect the environment, and create a version of it only
consisting of variables ending with "_proxy" (case-insensitive).

I honestly don't remember what "other bugs" prompted me to clear the
environment in the first place.
 mkarchroot.in | 5 +++++
 1 file changed, 5 insertions(+)


diff --git a/mkarchroot.in b/mkarchroot.in
index 9f365e8..3aff357 100644
--- a/mkarchroot.in
+++ b/mkarchroot.in
@@ -78,6 +78,11 @@  for file in "${files[@]}"; do
 	cp "$file" "$working_dir$file"
+while read -r varname; do
+	_env+=("$varname=${!varname}")
+done < <(declare -x | sed -r 's/^declare -x ([^=]*)=.*/\1/' | grep -i '_proxy$')
+env -i "${_env[@]}" \
 pacstrap -GMcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \
   "${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'