File: d-dont-download-stage0.patch

package info (click to toggle)
rustc 1.48.0%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, bullseye-backports, sid
  • size: 275,960 kB
  • sloc: xml: 147,652; ansic: 16,929; sh: 16,839; javascript: 6,817; python: 6,021; cpp: 4,663; makefile: 3,284; asm: 1,437; ruby: 68; awk: 12
file content (50 lines) | stat: -rw-r--r-- 1,956 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Description: Don't download SHA256 if it's already available locally
 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.
Author: Ximin Luo <infinity0@debian.org>
Forwarded: not-needed
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -24,17 +24,19 @@
     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 @@
             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)
 
 
@@ -459,7 +460,7 @@
 
         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)