nixpkgs/pkgs/tools/filesystems/stratisd/paths.patch
2022-08-24 23:42:13 +08:00

43 lines
1.8 KiB
Diff

diff --git a/src/engine/strat_engine/cmd.rs b/src/engine/strat_engine/cmd.rs
index daaff70f..ed528f7f 100644
--- a/src/engine/strat_engine/cmd.rs
+++ b/src/engine/strat_engine/cmd.rs
@@ -39,8 +39,6 @@ use crate::{
// The maximum allowable size of the thinpool metadata device
const MAX_META_SIZE: MetaBlocks = MetaBlocks(255 * ((1 << 14) - 64));
-const BINARIES_PATHS: [&str; 4] = ["/usr/sbin", "/sbin", "/usr/bin", "/bin"];
-
/// Find the binary with the given name by looking in likely locations.
/// Return None if no binary was found.
/// Search an explicit list of directories rather than the user's PATH
@@ -49,7 +47,7 @@ const BINARIES_PATHS: [&str; 4] = ["/usr/sbin", "/sbin", "/usr/bin", "/bin"];
fn find_binary(name: &str) -> Option<PathBuf> {
BINARIES_PATHS
.iter()
- .map(|pre| [pre, name].iter().collect::<PathBuf>())
+ .map(|pre| [pre, &name.into()].iter().collect::<PathBuf>())
.find(|path| path.exists())
}
@@ -147,6 +145,10 @@ lazy_static! {
.and_then(|mut hm| hm
.remove(CLEVIS)
.and_then(|c| hm.remove(JOSE).map(|j| (c, j))));
+ static ref BINARIES_PATHS: Vec<PathBuf> = match std::option_env!("BINARIES_PATHS") {
+ Some(paths) => std::env::split_paths(paths).collect(),
+ None => ["/usr/sbin", "/sbin", "/usr/bin", "/bin"].iter().map(|p| p.into()).collect(),
+ };
}
/// Verify that all binaries that the engine might invoke are available at some
@@ -160,7 +162,7 @@ pub fn verify_binaries() -> StratisResult<()> {
name,
BINARIES_PATHS
.iter()
- .map(|p| format!("\"{}\"", p))
+ .map(|p| format!("\"{}\"", p.display()))
.collect::<Vec<_>>()
.join(", "),
))),