d-dont-download-stage0
authorRust Maintainers <pkg-rust-maintainers@lists.alioth.debian.org>
Sun, 12 Mar 2017 03:15:33 +0000 (03:15 +0000)
committerXimin Luo <infinity0@debian.org>
Sun, 12 Mar 2017 03:15:33 +0000 (03:15 +0000)
Gbp-Pq: Name d-dont-download-stage0.patch

src/bootstrap/bootstrap.py
src/etc/get-stage0.py

index 69f2355a3623a1c0528483da7c79690e46487010..79e81e0970efc9f2da736ac17eb186e0153bb92f 100644 (file)
@@ -22,15 +22,17 @@ import tempfile
 from time import time
 
 
-def get(url, path, verbose=False):
+def get(url, path, verbose=False, use_local_hash_if_present=False):
     sha_url = url + ".sha256"
     with tempfile.NamedTemporaryFile(delete=False) as temp_file:
         temp_path = temp_file.name
-    with tempfile.NamedTemporaryFile(suffix=".sha256", delete=False) as sha_file:
-        sha_path = sha_file.name
+    sha_path = path + ".sha256"
 
     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:
@@ -47,7 +49,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)
 
 
index 127251cc802c9ccec20dc19c01901cbad412f43e..4b89c59b5df15dc15377f645fa5c78064f9826f1 100644 (file)
@@ -31,7 +31,7 @@ def main(triple):
     filename = 'rustc-{}-{}.tar.gz'.format(channel, triple)
     url = 'https://static.rust-lang.org/dist/{}/{}'.format(date, filename)
     dst = dl_dir + '/' + filename
-    bootstrap.get(url, dst)
+    bootstrap.get(url, dst, use_local_hash_if_present=True)
 
     stage0_dst = triple + '/stage0'
     if os.path.exists(stage0_dst):