pmb.helpers.run_core: always configure proxy vars if set in environment

By configuring proxy vars in run_core.core, we can ensure that the
environment is always aware of any configured proxy, whether it's
running natively or in a chroot.

fixes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2249

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230713021822.15223-2-clayton@craftyguy.net%3E
This commit is contained in:
Clayton Craft 2023-07-12 19:18:21 -07:00 committed by Oliver Smith
parent caf4d779e3
commit 1a00c04f74
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
2 changed files with 7 additions and 6 deletions

View File

@ -65,12 +65,6 @@ def root(args, cmd, suffix="native", working_dir="/", output="log",
for key, value in env.items():
env_all[key] = value
# Preserve proxy environment variables
for var in ["FTP_PROXY", "ftp_proxy", "HTTP_PROXY", "http_proxy",
"HTTPS_PROXY", "https_proxy", "HTTP_PROXY_AUTH"]:
if var in os.environ:
env_all[var] = os.environ[var]
# Build the command in steps and run it, e.g.:
# cmd: ["echo", "test"]
# cmd_chroot: ["/sbin/chroot", "/..._native", "/bin/sh", "-c", "echo test"]

View File

@ -310,6 +310,13 @@ def core(args, log_message, cmd, working_dir=None, output="log",
"""
sanity_checks(output, output_return, check)
# Preserve proxy environment variables
for var in ["FTP_PROXY", "ftp_proxy", "HTTP_PROXY", "http_proxy",
"HTTPS_PROXY", "https_proxy", "HTTP_PROXY_AUTH"]:
if var in os.environ:
# Prepend setting var to cmd string
cmd = f"{var}={os.environ[var]} {cmd}"
if args.sudo_timer and sudo:
sudo_timer_start()