|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
|
|
use crate::crash;
|
|
|
|
|
use crate::info;
|
|
|
|
|
use crate::internal::commands::ShellCommand;
|
|
|
|
@ -16,6 +18,9 @@ pub fn clean(options: Options) {
|
|
|
|
|
.wait_with_output()
|
|
|
|
|
.silent_unwrap(AppExitCode::PacmanError);
|
|
|
|
|
|
|
|
|
|
if orphaned_packages.stdout.as_str() == "" {
|
|
|
|
|
info("No orphaned packages found".to_string());
|
|
|
|
|
} else {
|
|
|
|
|
info(format!(
|
|
|
|
|
"Removing orphans would uninstall the following packages: \n{}",
|
|
|
|
|
&orphaned_packages.stdout
|
|
|
|
@ -33,7 +38,7 @@ pub fn clean(options: Options) {
|
|
|
|
|
|
|
|
|
|
let orphaned_packages_vec = orphaned_packages.stdout.split('\n').collect::<Vec<&str>>();
|
|
|
|
|
for package in &orphaned_packages_vec {
|
|
|
|
|
if package.len() > 0 {
|
|
|
|
|
if !package.is_empty() {
|
|
|
|
|
pacman_args.push(package);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -56,16 +61,39 @@ pub fn clean(options: Options) {
|
|
|
|
|
AppExitCode::PacmanError,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let clear_cache = prompt("Also clear pacman's package cache?".to_string(), false);
|
|
|
|
|
if clear_cache {
|
|
|
|
|
let mut pacman_args = vec!["-Scc"];
|
|
|
|
|
let mut pacman_args = vec!["-Sc"];
|
|
|
|
|
if noconfirm {
|
|
|
|
|
pacman_args.push("--noconfirm");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let mut paccache_args = vec!["-r"];
|
|
|
|
|
if noconfirm {
|
|
|
|
|
paccache_args.push("--noconfirm");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if verbosity >= 1 {
|
|
|
|
|
log("Clearing using `paccache -r`".to_string());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Command::new("sudo")
|
|
|
|
|
.arg("paccache")
|
|
|
|
|
.args(paccache_args)
|
|
|
|
|
.spawn()
|
|
|
|
|
.unwrap_or_else(|e| {
|
|
|
|
|
crash(
|
|
|
|
|
format!("Couldn't clear cache using `paccache -r`, {}", e),
|
|
|
|
|
AppExitCode::PacmanError,
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
.wait()
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
if verbosity >= 1 {
|
|
|
|
|
log("Clearing package cache".to_string());
|
|
|
|
|
log("Clearing using `pacman -Sc`".to_string());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let pacman_result = ShellCommand::pacman()
|
|
|
|
|