mirror of
https://github.com/openwrt/packages.git
synced 2025-12-20 17:41:20 +00:00
The rust bootstrap downloads files into a "tmp" directory then moves the files into the "cache" directory using std::fs::rename. There are no issues in the original/unpatched case as "tmp" and "cache" are subdirectories in the build directory ($(HOST_BUILD_DIR)/build) and so are nearly guaranteed to be on the same filesystem.35768bf31echanged where files are saved/cached (in $(DL_DIR)/rustc). If HOST_BUILD_DIR and DL_DIR are on separate filesystems, then using std::fs::rename to move the files will fail.[1] This updates 0002-rustc-bootstrap-cache.patch to account for this case, i.e. if std::fs::rename fails, fall back to copying the file then removing the original. [1]: https://github.com/openwrt/packages/pull/22457 Fixes:35768bf31e("rust: Cache bootstrap downloads to $(DL_DIR)/rustc") Signed-off-by: Jeffery To <jeffery.to@gmail.com>
53 lines
2.1 KiB
Diff
53 lines
2.1 KiB
Diff
--- a/src/bootstrap/bootstrap.py
|
|
+++ b/src/bootstrap/bootstrap.py
|
|
@@ -546,7 +546,7 @@ class RustBuild(object):
|
|
shutil.rmtree(bin_root)
|
|
|
|
key = self.stage0_compiler.date
|
|
- cache_dst = os.path.join(self.build_dir, "cache")
|
|
+ cache_dst = os.getenv('OPENWRT_RUSTC_BOOTSTRAP_CACHE', os.path.join(self.build_dir, "cache"))
|
|
rustc_cache = os.path.join(cache_dst, key)
|
|
if not os.path.exists(rustc_cache):
|
|
os.makedirs(rustc_cache)
|
|
--- a/src/bootstrap/download.rs
|
|
+++ b/src/bootstrap/download.rs
|
|
@@ -202,7 +202,13 @@ impl Config {
|
|
Some(other) => panic!("unsupported protocol {other} in {url}"),
|
|
None => panic!("no protocol in {url}"),
|
|
}
|
|
- t!(std::fs::rename(&tempfile, dest_path));
|
|
+ match std::fs::rename(&tempfile, dest_path) {
|
|
+ Ok(v) => v,
|
|
+ Err(_) => {
|
|
+ t!(std::fs::copy(&tempfile, dest_path));
|
|
+ t!(std::fs::remove_file(&tempfile));
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) {
|
|
@@ -520,7 +526,10 @@ impl Config {
|
|
key: &str,
|
|
destination: &str,
|
|
) {
|
|
- let cache_dst = self.out.join("cache");
|
|
+ let cache_dst = match env::var_os("OPENWRT_RUSTC_BOOTSTRAP_CACHE") {
|
|
+ Some(v) => PathBuf::from(v),
|
|
+ None => self.out.join("cache"),
|
|
+ };
|
|
let cache_dir = cache_dst.join(key);
|
|
if !cache_dir.exists() {
|
|
t!(fs::create_dir_all(&cache_dir));
|
|
@@ -647,7 +656,10 @@ download-rustc = false
|
|
let llvm_assertions = self.llvm_assertions;
|
|
|
|
let cache_prefix = format!("llvm-{llvm_sha}-{llvm_assertions}");
|
|
- let cache_dst = self.out.join("cache");
|
|
+ let cache_dst = match env::var_os("OPENWRT_RUSTC_BOOTSTRAP_CACHE") {
|
|
+ Some(v) => PathBuf::from(v),
|
|
+ None => self.out.join("cache"),
|
|
+ };
|
|
let rustc_cache = cache_dst.join(cache_prefix);
|
|
if !rustc_cache.exists() {
|
|
t!(fs::create_dir_all(&rustc_cache));
|