diff --git a/src/backend/actual/pacman.rs b/src/backend/actual/pacman.rs index e726a41..05c825b 100644 --- a/src/backend/actual/pacman.rs +++ b/src/backend/actual/pacman.rs @@ -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, } -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) { + 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> { diff --git a/src/core.rs b/src/core.rs index 3523959..1709912 100644 --- a/src/core.rs +++ b/src/core.rs @@ -60,7 +60,16 @@ impl Pacdef { fn get_missing_packages(&self) -> ToDoPerBackend { let mut to_install = ToDoPerBackend::new(); - for mut backend in Backends::iter() { + for backend in Backends::iter() { + let mut backend = if backend.get_section() == "pacman" { + Box::new(crate::backend::Pacman { + binary: self.config.aur_helper.clone(), + packages: HashSet::new(), + }) + } else { + backend + }; + backend.load(&self.groups); match backend.get_missing_packages_sorted() {