1
0
Fork 0

Fix reflink sometimes removing executable bit

Or, well, work around it.
This commit is contained in:
Robbert van der Helm 2022-06-15 00:06:07 +02:00
parent 0b6be4de1c
commit 199305c413

View file

@ -5,6 +5,9 @@ use std::fs;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::Command; use std::process::Command;
#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;
mod symbols; mod symbols;
/// Re-export for the main function. /// Re-export for the main function.
@ -232,6 +235,22 @@ fn bundle_binary(
reflink::reflink_or_copy(&bin_path, &standalone_binary_path) reflink::reflink_or_copy(&bin_path, &standalone_binary_path)
.context("Could not copy binary to standalone bundle")?; .context("Could not copy binary to standalone bundle")?;
// FIXME: The reflink crate seems to sometime strip away the executable bit, so we need to help
// it a little here
#[cfg(unix)]
if let Ok(metadata) = fs::metadata(&standalone_binary_path) {
// These are the executable bits
let mut permissions = metadata.permissions();
permissions.set_mode(permissions.mode() | 0b0001001001);
fs::set_permissions(&standalone_binary_path, permissions).with_context(|| {
format!(
"Could not make '{}' executable",
standalone_binary_path.display()
)
})?;
}
let standalone_bundle_home = Path::new(BUNDLE_HOME).join( let standalone_bundle_home = Path::new(BUNDLE_HOME).join(
Path::new(&standalone_bundle_binary_name) Path::new(&standalone_bundle_binary_name)
.components() .components()