1
0
Fork 0

patch cargo-xbuild to ensure copied Cargo.lock is writable

https://github.com/rust-osdev/cargo-xbuild/issues/96
This commit is contained in:
Sebastien Bourdeauducq 2020-10-13 18:27:52 +08:00
parent 34a63d7732
commit 56c94b0855
3 changed files with 31 additions and 2 deletions

View File

@ -8,7 +8,9 @@ let
src = ./.; src = ./.;
cargoSha256 = "1f2psa1g41pl2j8n60hhik2s2pqdfjhr5capimvajf81kxrnn2ck"; cargoSha256 = "1f2psa1g41pl2j8n60hhik2s2pqdfjhr5capimvajf81kxrnn2ck";
nativeBuildInputs = [ pkgs.cargo-xbuild ]; nativeBuildInputs = [
(pkgs.cargo-xbuild.overrideAttrs(oa: { patches = oa.patches ++ [ ./xbuild_writable_lockfile.diff ]; } ))
];
buildPhase = '' buildPhase = ''
export XARGO_RUST_SRC="${rustPlatform.rust.rustc.src}/library" export XARGO_RUST_SRC="${rustPlatform.rust.rustc.src}/library"
export CARGO_HOME=$(mktemp -d cargo-home.XXX) export CARGO_HOME=$(mktemp -d cargo-home.XXX)

View File

@ -8,7 +8,7 @@ in
rustPlatform.rust.rustc rustPlatform.rust.rustc
rustPlatform.rust.cargo rustPlatform.rust.cargo
pkgs.cacert pkgs.cacert
pkgs.cargo-xbuild (pkgs.cargo-xbuild.overrideAttrs(oa: { patches = oa.patches ++ [ ./xbuild_writable_lockfile.diff ]; } ))
pkgs.openocd pkgs.gdb pkgs.openocd pkgs.gdb
pkgs.openssh pkgs.rsync pkgs.openssh pkgs.rsync

View File

@ -0,0 +1,27 @@
diff --git a/src/sysroot.rs b/src/sysroot.rs
index 1f3c8d1..422d3d0 100644
--- a/src/sysroot.rs
+++ b/src/sysroot.rs
@@ -85,10 +85,20 @@ fn build_crate(
}
util::write(&td.join("Cargo.toml"), &stoml)?;
- fs::copy(lockfile, &td.join("Cargo.lock")).chain_err(||
+ let dst_file = td.join("Cargo.lock");
+ fs::copy(lockfile, &dst_file).chain_err(||
format!("failed to copy Cargo.lock from `{}` to `{}`",
- lockfile.display(), &td.join("Cargo.lock").display())
+ lockfile.display(), &dst_file.display())
)?;
+ let mut perms = fs::metadata(&dst_file).chain_err(||
+ format!("failed to retrieve permissions for `{}`",
+ dst_file.display())
+ )?.permissions();
+ perms.set_readonly(false);
+ fs::set_permissions(&dst_file, perms).chain_err(||
+ format!("failed to update permissions for `{}`",
+ dst_file.display())
+ );
util::mkdir(&td.join("src"))?;
util::write(&td.join("src/lib.rs"), "")?;