00ca2ebac6
- Implement source-based package management with support for archives and Git - Add multi-system build support (Autotools, CMake, Meson, Rust/Cargo, Custom) - Implement atomic installation logic using transactions and fakeroot - Add dependency resolution for build-time and runtime requirements - Implement package indexing and local repository management - Add comprehensive configuration system with system/package overrides - Include Project guidelines (AGENTS.md) and README.md
27 lines
796 B
Rust
Executable File
27 lines
796 B
Rust
Executable File
//! Fakeroot support for running commands as pseudo-root
|
|
//! Uses the system fakeroot command when not running as root
|
|
|
|
use std::path::Path;
|
|
use std::process::Command;
|
|
|
|
/// Check if we're running as root
|
|
pub fn is_root() -> bool {
|
|
nix::unistd::geteuid().is_root()
|
|
}
|
|
|
|
/// Wrap a command for fakeroot execution
|
|
/// For make install, we use the system fakeroot command
|
|
pub fn wrap_install_command(program: &str, destdir: &Path) -> Command {
|
|
if is_root() {
|
|
Command::new(program)
|
|
} else {
|
|
// Use system fakeroot command which handles LD_PRELOAD internally
|
|
let mut cmd = Command::new("fakeroot");
|
|
cmd.arg("--");
|
|
cmd.arg(program);
|
|
// Fakeroot will ensure file ownership appears as root
|
|
cmd.env("DESTDIR", destdir);
|
|
cmd
|
|
}
|
|
}
|