mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
scripts: Allow configuring a custom CA bundle for build process.
For building Zulip in an environment where a custom CA certificate is required to access the public Internet, one needs to be able to specify that CA certificate for all network access done by the Zulip installer/build process. This change allows configuring that via the environment.
This commit is contained in:
@@ -252,6 +252,13 @@ def setup_virtualenv(target_venv_path, requirements_file, virtualenv_args=None,
|
||||
exec(open(activate_this).read(), {}, dict(__file__=activate_this))
|
||||
return cached_venv_path
|
||||
|
||||
def add_cert_to_pipconf():
|
||||
# type: () -> None
|
||||
conffile = os.path.expanduser("~/.pip/pip.conf")
|
||||
confdir = os.path.expanduser("~/.pip/")
|
||||
os.makedirs(confdir, exist_ok=True)
|
||||
run(["crudini", "--set", conffile, "global", "cert", os.environ["CUSTOM_CA_CERTIFICATES"]])
|
||||
|
||||
def do_setup_virtualenv(venv_path, requirements_file, virtualenv_args):
|
||||
# type: (str, str, List[str]) -> None
|
||||
|
||||
@@ -272,6 +279,11 @@ def do_setup_virtualenv(venv_path, requirements_file, virtualenv_args):
|
||||
activate_this = os.path.join(venv_path, "bin", "activate_this.py")
|
||||
exec(open(activate_this).read(), {}, dict(__file__=activate_this))
|
||||
|
||||
# use custom certificate if needed
|
||||
if os.environ.get('CUSTOM_CA_CERTIFICATES'):
|
||||
print("Configuring pip to use custom CA certificates...")
|
||||
add_cert_to_pipconf()
|
||||
|
||||
try:
|
||||
install_venv_deps(requirements_file)
|
||||
except subprocess.CalledProcessError:
|
||||
|
||||
Reference in New Issue
Block a user