Skip to content

Commit

Permalink
Don't preserve libffi mode and ownership on build
Browse files Browse the repository at this point in the history
By default, copying a file will preserve its mode and ownership
attributes. This is an issue when copying `libffi` from a read-only
filesystem since the configuration log file also becomes read-only,
causing a build failure.
  • Loading branch information
fracek authored and yorickpeterse committed Jul 22, 2023
1 parent 7cab761 commit ef98286
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion libffi-sys-rs/build/not_msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,21 @@ pub fn build_and_link() {
e
);
}

// On Linux, don't preserve the attributes of the source directory.
// Not all cp versions support --no-preserve=mode,ownership, so we
// first check if it's available.
let mut command = Command::new("cp");
let has_no_preserve_flag = {
let output = Command::new("cp").arg("--help").output().unwrap().stdout;
String::from_utf8(output).unwrap().contains("--no-preserve")
};
if has_no_preserve_flag {
command.arg("--no-preserve=mode,ownership");
};
run_command(
"Copying libffi into the build directory",
Command::new("cp").arg("-R").arg("libffi").arg(&build_dir),
command.arg("-R").arg("libffi").arg(&build_dir),
);

// Generate configure, run configure, make, make install
Expand Down

0 comments on commit ef98286

Please sign in to comment.