Don't download SHA256 if it's already available locally
authorXimin Luo <infinity0@debian.org>
Thu, 6 Aug 2020 20:11:39 +0000 (21:11 +0100)
committerXimin Luo <infinity0@debian.org>
Thu, 6 Aug 2020 20:11:39 +0000 (21:11 +0100)
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

src/bootstrap/bootstrap.py

index ea507ee35c7ea1bf9b53d9aacc91dcee5aabf2d0..22868f7299a4a1a2042c4e3a6e121477dbb73989 100644 (file)
@@ -15,16 +15,18 @@ import tempfile
 from time import time
 
 
-def get(url, path, verbose=False):
+def get(url, path, verbose=False, 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:
-        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:
@@ -42,7 +44,6 @@ def get(url, path, verbose=False):
             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)
 
 
@@ -430,7 +431,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)