2025-08-08 00:00:14 +03:00
|
|
|
use std::fs;
|
2025-11-18 19:46:36 +03:00
|
|
|
use crate::utils::fs::deletecopy::deletecopy;
|
2025-08-08 00:00:14 +03:00
|
|
|
use crate::utils::shell::*;
|
|
|
|
|
|
|
|
|
|
pub fn disable(repo: &String, pkgname: &String) -> Result<(), String> {
|
2025-11-18 19:46:36 +03:00
|
|
|
let source = crate::commands::get_aeropkg_base().join(repo).join(pkgname);
|
|
|
|
|
|
|
|
|
|
if source.join("disabled").exists() { return Ok(()) };
|
|
|
|
|
|
2025-08-08 00:00:14 +03:00
|
|
|
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() {
|
|
|
|
|
deletecopy(&src, &dest)
|
|
|
|
|
.map_err(|e| format!("Failed to delete copy {} to {}: {}", src.display(), dest.display(), e))?;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mount_overlay(&destination)?;
|
|
|
|
|
shell_update()?;
|
|
|
|
|
|
2025-11-18 19:46:36 +03:00
|
|
|
fs::File::create(&source.join("disabled")).ok();
|
2025-08-08 00:00:14 +03:00
|
|
|
Ok(())
|
|
|
|
|
}
|