Refactor and enhance source management and installation processes
- Improved error handling and context messages in `checkout` function in `git.rs`. - Updated license field in package specification to use a vector in `hooks.rs`. - Enhanced `copy_manual_sources` function in `mod.rs` to support both local file and remote URL sources, including checksum verification. - Added new utility functions for path normalization and skipping installation of specific files in `staging/mod.rs`. - Implemented logic to handle existing files during installation, allowing for `.depotnew` suffix for kept files. - Added tests for manual source copying, installation behavior, and path validation. - Introduced a new LICENSE file with MIT License terms.
This commit is contained in:
+7
-12
@@ -203,12 +203,16 @@ endian = 'little'
|
||||
}
|
||||
}
|
||||
|
||||
/// Find a cross-compilation tool in PATH
|
||||
/// Find a cross-compilation tool in PATH and return its absolute path
|
||||
fn find_tool(prefix: &str, suffixes: &[&str], required: bool) -> Result<String> {
|
||||
for suffix in suffixes {
|
||||
let tool_name = format!("{}-{}", prefix, suffix);
|
||||
if tool_exists(&tool_name) {
|
||||
return Ok(tool_name);
|
||||
// Use `which` to resolve to an absolute path (so callers get a usable path)
|
||||
if let Ok(output) = Command::new("which").arg(&tool_name).output() {
|
||||
if output.status.success() {
|
||||
let path = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
return Ok(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,12 +226,3 @@ fn find_tool(prefix: &str, suffixes: &[&str], required: bool) -> Result<String>
|
||||
|
||||
Err(anyhow::anyhow!("Tool not found"))
|
||||
}
|
||||
|
||||
/// Check if a tool exists in PATH
|
||||
fn tool_exists(name: &str) -> bool {
|
||||
Command::new("which")
|
||||
.arg(name)
|
||||
.output()
|
||||
.map(|o| o.status.success())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user