From c0c66a0fed8795cbcbf11ed851da1a1550ea169f Mon Sep 17 00:00:00 2001 From: Alec Scott Date: Mon, 20 Nov 2023 13:35:26 -0700 Subject: [PATCH] rust: add v1.73.0 and add support for external openssl certs (#41161) Co-authored-by: Tom Scogland --- .../packages/rust-bootstrap/package.py | 11 +++ .../repos/builtin/packages/rust/package.py | 73 +++++++++++++------ 2 files changed, 61 insertions(+), 23 deletions(-) diff --git a/var/spack/repos/builtin/packages/rust-bootstrap/package.py b/var/spack/repos/builtin/packages/rust-bootstrap/package.py index 337618e20e..a8e9f7baae 100644 --- a/var/spack/repos/builtin/packages/rust-bootstrap/package.py +++ b/var/spack/repos/builtin/packages/rust-bootstrap/package.py @@ -21,6 +21,17 @@ class RustBootstrap(Package): # should update these binary releases as bootstrapping requirements are # modified by new releases of Rust. rust_releases = { + "1.73.0": { + "darwin": { + "x86_64": "ece9646bb153d4bc0f7f1443989de0cbcd8989a7d0bf3b7fb9956e1223954f0c", + "aarch64": "9c96e4c57328fb438ee2d87aa75970ce89b4426b49780ccb3c16af0d7c617cc6", + }, + "linux": { + "x86_64": "aa4cf0b7e66a9f5b7c623d4b340bb1ac2864a5f2c2b981f39f796245dc84f2cb", + "aarch64": "e54d7d886ba413ae573151f668e76ea537f9a44406d3d29598269a4a536d12f6", + "powerpc64le": "8fa215ee3e274fb64364e7084613bc570369488fa22cf5bc8e0fe6dc810fe2b9", + }, + }, "1.70.0": { "darwin": { "x86_64": "e5819fdbfc7f1a4d5d82cb4c3b7662250748450b45a585433bfb75648bc45547", diff --git a/var/spack/repos/builtin/packages/rust/package.py b/var/spack/repos/builtin/packages/rust/package.py index b660697df3..8d0784d95a 100644 --- a/var/spack/repos/builtin/packages/rust/package.py +++ b/var/spack/repos/builtin/packages/rust/package.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import os import re from spack.package import * @@ -17,6 +18,27 @@ class Rust(Package): maintainers("alecbcs") + # When adding a version of Rust you may need to add an additional version + # to rust-bootstrap as the minimum bootstrapping requirements increase. + # As a general rule of thumb Rust can be built with either the previous major + # version or the current version of the compiler as shown above. + + # Pre-release versions. + # Note: If you plan to use these versions remember to install with + # `-n` to prevent Spack from failing due to failed checksums. + # + # $ spack install -n rust@pre-release-version + # + version("beta") + version("master", branch="master", submodules=True) + version("nightly") + + # Stable versions. + version("1.73.0", sha256="96d62e6d1f2d21df7ac8acb3b9882411f9e7c7036173f7f2ede9e1f1f6b1bb3a") + version("1.70.0", sha256="b2bfae000b7a5040e4ec4bbc50a09f21548190cb7570b0ed77358368413bd27c") + version("1.65.0", sha256="5828bb67f677eabf8c384020582b0ce7af884e1c84389484f7f8d00dd82c0038") + version("1.60.0", sha256="20ca826d1cf674daf8e22c4f8c4b9743af07973211c839b85839742314c838b7") + # Core dependencies depends_on("cmake@3.13.4:", type="build") depends_on("curl+nghttp2") @@ -40,26 +62,7 @@ class Rust(Package): depends_on("rust-bootstrap@1.59:1.60", type="build", when="@1.60") depends_on("rust-bootstrap@1.64:1.65", type="build", when="@1.65") depends_on("rust-bootstrap@1.69:1.70", type="build", when="@1.70") - - # When adding a version of Rust you may need to add an additional version - # to rust-bootstrap as the minimum bootstrapping requirements increase. - # As a general rule of thumb Rust can be built with either the previous major - # version or the current version of the compiler as shown above. - - # Pre-release versions. - # Note: If you plan to use these versions remember to install with - # `-n` to prevent Spack from failing due to failed checksums. - # - # $ spack install -n rust@pre-release-version - # - version("beta") - version("master", branch="master", submodules=True) - version("nightly") - - # Stable versions. - version("1.70.0", sha256="b2bfae000b7a5040e4ec4bbc50a09f21548190cb7570b0ed77358368413bd27c") - version("1.65.0", sha256="5828bb67f677eabf8c384020582b0ce7af884e1c84389484f7f8d00dd82c0038") - version("1.60.0", sha256="20ca826d1cf674daf8e22c4f8c4b9743af07973211c839b85839742314c838b7") + depends_on("rust-bootstrap@1.72:1.73", type="build", when="@1.73") variant( "analysis", @@ -91,9 +94,33 @@ def setup_build_environment(self, env): ar = which("ar", required=True) 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) + # Manually inject the path of openssl's certs for build + # if certs are present on system via Spack or via external + # openssl. + def get_test_path(p): + certs = join_path(p, "cert.pem") + if os.path.exists(certs): + return certs + return None + + # find certs, don't set if no file is found in case + # ca-certificates isn't installed + certs = None + openssl = self.spec["openssl"] + if openssl.external: + try: + output = which("openssl", required=True)("version", "-d", output=str, error=str) + openssl_dir = re.match('OPENSSLDIR: "([^"]+)"', output) + if openssl_dir: + certs = get_test_path(openssl_dir.group(1)) + except ProcessError: + pass + + if certs is None: + certs = get_test_path(join_path(openssl.prefix, "etc/openssl")) + + if certs is not None: + env.set("CARGO_HTTP_CAINFO", certs) def configure(self, spec, prefix): opts = []