From f80df0ca47d75e99d0340782a26a735542e02f17 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Mon, 6 Nov 2023 11:46:00 -0800 Subject: [PATCH] select the system certificates more reliably The rust build requires cargo to connect to its servers, it needs system certificates to connect through MITM proxies or other various issues in corporate systems. This searches for more common locations to find those certificates and the name used by RHEL in addition to the usual debian convention. Fixes rust build on TOSS4. --- var/spack/repos/builtin/packages/rust/package.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/var/spack/repos/builtin/packages/rust/package.py b/var/spack/repos/builtin/packages/rust/package.py index b660697df36..bf3609c9779 100644 --- a/var/spack/repos/builtin/packages/rust/package.py +++ b/var/spack/repos/builtin/packages/rust/package.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import re +import os from spack.package import * @@ -92,8 +93,16 @@ def setup_build_environment(self, env): env.set("AR", ar.path) # Manually inject the path of openssl's certs for build. - certs = join_path(self.spec["openssl"].prefix, "etc/openssl/cert.pem") - env.set("CARGO_HTTP_CAINFO", certs) + certs = None + for p in ("etc/openssl/cert.pem", "../etc/openssl/cert.pem", + "etc/ssl/certs/ca-bundle.crt", "../etc/ssl/certs/ca-bundle.crt"): + certs = join_path(self.spec["openssl"].prefix, p) + if os.path.exists(certs): + break + else: + certs = None + if certs is not None: + env.set("CARGO_HTTP_CAINFO", certs) def configure(self, spec, prefix): opts = []