Merge pull request #22545 from mhei/gensio-update-to-2.7.6
[feed/packages.git] / lang / rust / patches / 0002-rustc-bootstrap-cache.patch
1 --- a/src/bootstrap/bootstrap.py
2 +++ b/src/bootstrap/bootstrap.py
3 @@ -546,7 +546,7 @@ class RustBuild(object):
4 shutil.rmtree(bin_root)
5
6 key = self.stage0_compiler.date
7 - cache_dst = os.path.join(self.build_dir, "cache")
8 + cache_dst = os.getenv('OPENWRT_RUSTC_BOOTSTRAP_CACHE', os.path.join(self.build_dir, "cache"))
9 rustc_cache = os.path.join(cache_dst, key)
10 if not os.path.exists(rustc_cache):
11 os.makedirs(rustc_cache)
12 --- a/src/bootstrap/download.rs
13 +++ b/src/bootstrap/download.rs
14 @@ -202,7 +202,13 @@ impl Config {
15 Some(other) => panic!("unsupported protocol {other} in {url}"),
16 None => panic!("no protocol in {url}"),
17 }
18 - t!(std::fs::rename(&tempfile, dest_path));
19 + match std::fs::rename(&tempfile, dest_path) {
20 + Ok(v) => v,
21 + Err(_) => {
22 + t!(std::fs::copy(&tempfile, dest_path));
23 + t!(std::fs::remove_file(&tempfile));
24 + }
25 + }
26 }
27
28 fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) {
29 @@ -520,7 +526,10 @@ impl Config {
30 key: &str,
31 destination: &str,
32 ) {
33 - let cache_dst = self.out.join("cache");
34 + let cache_dst = match env::var_os("OPENWRT_RUSTC_BOOTSTRAP_CACHE") {
35 + Some(v) => PathBuf::from(v),
36 + None => self.out.join("cache"),
37 + };
38 let cache_dir = cache_dst.join(key);
39 if !cache_dir.exists() {
40 t!(fs::create_dir_all(&cache_dir));
41 @@ -647,7 +656,10 @@ download-rustc = false
42 let llvm_assertions = self.llvm_assertions;
43
44 let cache_prefix = format!("llvm-{llvm_sha}-{llvm_assertions}");
45 - let cache_dst = self.out.join("cache");
46 + let cache_dst = match env::var_os("OPENWRT_RUSTC_BOOTSTRAP_CACHE") {
47 + Some(v) => PathBuf::from(v),
48 + None => self.out.join("cache"),
49 + };
50 let rustc_cache = cache_dst.join(cache_prefix);
51 if !rustc_cache.exists() {
52 t!(fs::create_dir_all(&rustc_cache));