2025-08-08 00:00:14 +03:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
use crate::utils::hardcopy::hardcopy_handler;
|
|
|
|
|
use crate::utils::shell::*;
|
|
|
|
|
|
2025-09-02 20:01:30 +03:00
|
|
|
pub fn link(repo: &String, pkgname: &String) -> Result<(), String> {
|
2025-08-08 00:00:14 +03:00
|
|
|
let source = PathBuf::from("/pkg").join(repo).join(pkgname);
|
|
|
|
|
if source.join("disabled").exists() { return Ok(()) }
|
|
|
|
|
|
|
|
|
|
let destination = source.parent()
|
|
|
|
|
.ok_or("Failed to get parent directory for path")?
|
|
|
|
|
.to_path_buf();
|
|
|
|
|
|
|
|
|
|
let dirs_to_copy = vec![
|
|
|
|
|
("bin"),
|
|
|
|
|
("lib"),
|
|
|
|
|
("libexec"),
|
|
|
|
|
("include"),
|
|
|
|
|
("share")
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
for base_system_folder_dir in dirs_to_copy {
|
|
|
|
|
let src = source.join(base_system_folder_dir);
|
|
|
|
|
let dest = destination.join(base_system_folder_dir);
|
|
|
|
|
|
|
|
|
|
if src.exists() {
|
|
|
|
|
hardcopy_handler(&src, &dest)
|
|
|
|
|
.map_err(|e| format!("Failed to copy {} to {}: {}", src.display(), dest.display(), e))?;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mount_overlay(&destination)?;
|
|
|
|
|
shell_update()?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|