add config (WIP)

This commit is contained in:
timeshifter
2023-01-14 17:08:59 +01:00
parent 1a9226384a
commit a5419d02ec
2 changed files with 37 additions and 2 deletions
+27 -1
View File
@@ -1,4 +1,6 @@
use std::collections::HashSet;
use std::os::unix::process::CommandExt;
use std::process::Command;
use alpm::Alpm;
use alpm::PackageReason::Explicit;
@@ -12,7 +14,7 @@ pub(crate) struct Pacman {
pub(crate) packages: HashSet<Package>,
}
const BINARY: Text = "paru";
const BINARY: Text = "yay";
const SECTION: Text = "pacman";
const SWITCHES_INSTALL: Switches = &["-S"];
const SWITCHES_REMOVE: Switches = &["-Rsn"];
@@ -34,6 +36,30 @@ impl Backend for Pacman {
let result = convert_to_pacdef_packages(alpm_packages);
Ok(result)
}
/// Install the specified packages.
fn install_packages(&self, packages: &[Package]) {
if packages.is_empty() {
return;
}
let mut cmd = Command::new(&self.binary);
cmd.args(self.get_switches_install());
for p in packages {
cmd.arg(format!("{p}"));
}
cmd.exec();
}
/// Remove the specified packages.
fn remove_packages(&self, packages: Vec<Package>) {
let mut cmd = Command::new(&self.binary);
cmd.args(self.get_switches_remove());
for p in packages {
cmd.arg(format!("{p}"));
}
cmd.exec();
}
}
fn get_all_installed_packages_from_alpm() -> Result<HashSet<String>> {