add config (WIP)
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use std::os::unix::process::CommandExt;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
use alpm::Alpm;
|
use alpm::Alpm;
|
||||||
use alpm::PackageReason::Explicit;
|
use alpm::PackageReason::Explicit;
|
||||||
@@ -12,7 +14,7 @@ pub(crate) struct Pacman {
|
|||||||
pub(crate) packages: HashSet<Package>,
|
pub(crate) packages: HashSet<Package>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const BINARY: Text = "paru";
|
const BINARY: Text = "yay";
|
||||||
const SECTION: Text = "pacman";
|
const SECTION: Text = "pacman";
|
||||||
const SWITCHES_INSTALL: Switches = &["-S"];
|
const SWITCHES_INSTALL: Switches = &["-S"];
|
||||||
const SWITCHES_REMOVE: Switches = &["-Rsn"];
|
const SWITCHES_REMOVE: Switches = &["-Rsn"];
|
||||||
@@ -34,6 +36,30 @@ impl Backend for Pacman {
|
|||||||
let result = convert_to_pacdef_packages(alpm_packages);
|
let result = convert_to_pacdef_packages(alpm_packages);
|
||||||
Ok(result)
|
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>> {
|
fn get_all_installed_packages_from_alpm() -> Result<HashSet<String>> {
|
||||||
|
|||||||
+10
-1
@@ -60,7 +60,16 @@ impl Pacdef {
|
|||||||
fn get_missing_packages(&self) -> ToDoPerBackend {
|
fn get_missing_packages(&self) -> ToDoPerBackend {
|
||||||
let mut to_install = ToDoPerBackend::new();
|
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);
|
backend.load(&self.groups);
|
||||||
|
|
||||||
match backend.get_missing_packages_sorted() {
|
match backend.get_missing_packages_sorted() {
|
||||||
|
|||||||
Reference in New Issue
Block a user