From: Ximin Luo Date: Sun, 19 Sep 2021 18:48:33 +0000 (+0100) Subject: Don't download SHA256 if it's already available locally X-Git-Tag: archive/raspbian/1.59.0+dfsg1-1_deb11u3+rpi1~2^2^2~7 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5f0850c960c683f360055e1efccd616506dc7881;p=rustc-mozilla.git Don't download SHA256 if it's already available locally Forwarded: not-needed In Debian we provide the stage0 tarballs as a separate component so that the buildds don't need to access the network during the build. Forwarded: not-needed Gbp-Pq: Name d-dont-download-stage0.patch --- diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 5b283229b..5f777bb4e 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -24,17 +24,19 @@ def support_xz(): except tarfile.CompressionError: return False -def get(url, path, verbose=False, do_verify=True): +def get(url, path, verbose=False, do_verify=True, use_local_hash_if_present=True): suffix = '.sha256' sha_url = url + suffix with tempfile.NamedTemporaryFile(delete=False) as temp_file: temp_path = temp_file.name - with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as sha_file: - sha_path = sha_file.name + sha_path = path + suffix try: if do_verify: - download(sha_path, sha_url, False, verbose) + if use_local_hash_if_present and os.path.exists(sha_path): + print("using already-download file " + sha_path) + else: + download(sha_path, sha_url, False, verbose) if os.path.exists(path): if verify(path, sha_path, False): if verbose: @@ -52,7 +54,6 @@ def get(url, path, verbose=False, do_verify=True): print("moving {} to {}".format(temp_path, path)) shutil.move(temp_path, path) finally: - delete_if_present(sha_path, verbose) delete_if_present(temp_path, verbose) @@ -492,7 +493,7 @@ class RustBuild(object): url = "{}/dist/{}".format(self._download_url, date) tarball = os.path.join(rustc_cache, filename) - if not os.path.exists(tarball): + if True: get("{}/{}".format(url, filename), tarball, verbose=self.verbose) unpack(tarball, tarball_suffix, self.bin_root(), match=pattern, verbose=self.verbose)