summaryrefslogtreecommitdiff
path: root/src/packages
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2024-09-09 23:03:49 +0200
committerfxqnlr <[email protected]>2024-09-09 23:03:49 +0200
commit553bbac36bdc483135a7053ca64507e01397e5e1 (patch)
tree494dad0623628df4f1b86b93da51edf60795a901 /src/packages
parentd396881816cd256cb12d03deebea445cba99ea85 (diff)
downloadarbs-553bbac36bdc483135a7053ca64507e01397e5e1.tar
arbs-553bbac36bdc483135a7053ca64507e01397e5e1.tar.gz
arbs-553bbac36bdc483135a7053ca64507e01397e5e1.zip
add package manager recognition
Diffstat (limited to 'src/packages')
-rw-r--r--src/packages/pacman.rs13
-rw-r--r--src/packages/portage.rs4
2 files changed, 10 insertions, 7 deletions
diff --git a/src/packages/pacman.rs b/src/packages/pacman.rs
index e10c6fb..0ad463b 100644
--- a/src/packages/pacman.rs
+++ b/src/packages/pacman.rs
@@ -1,13 +1,13 @@
1use std::process::{Command, Stdio}; 1use std::process::{Command, Stdio};
2 2
3use super::{Package, PackageManager}; 3use super::{Package, PackageList, PackageManager};
4 4
5use crate::error::{Error, Result}; 5use crate::error::{Error, Result};
6 6
7pub struct Pacman; 7pub struct Pacman;
8 8
9impl PackageManager for Pacman { 9impl PackageManager for Pacman {
10 fn get_installed(&self) -> Result<Vec<super::Package>> { 10 fn get_installed(&self) -> Result<PackageList> {
11 let pm_pkgs = Command::new("pacman").args(["-Q"]).output().unwrap(); 11 let pm_pkgs = Command::new("pacman").args(["-Q"]).output().unwrap();
12 let pm_e_pkgs = Command::new("pacman") 12 let pm_e_pkgs = Command::new("pacman")
13 .args(["-Q", "--explicit"]) 13 .args(["-Q", "--explicit"])
@@ -37,16 +37,19 @@ impl PackageManager for Pacman {
37 }); 37 });
38 } 38 }
39 39
40 Ok(pkgs) 40 Ok(PackageList {
41 packages: pkgs,
42 manager: super::Manager::Pacman,
43 })
41 } 44 }
42 45
43 fn install(&self, pkgs: Vec<super::Package>) -> Result<()> { 46 fn install(&self, pkgs: Vec<super::Package>) -> Result<()> {
44 let mut args = vec!["--noconfirm".to_string(), "-S".to_string()]; 47 let mut args = vec!["pacman".to_string(), "--noconfirm".to_string(), "-S".to_string()];
45 48
46 for pkg in pkgs { 49 for pkg in pkgs {
47 args.push(pkg.id); 50 args.push(pkg.id);
48 } 51 }
49 Command::new("pacman") 52 Command::new("doas")
50 .stdout(Stdio::inherit()) 53 .stdout(Stdio::inherit())
51 .args(args) 54 .args(args)
52 .spawn()? 55 .spawn()?
diff --git a/src/packages/portage.rs b/src/packages/portage.rs
index f9a760b..7fa09a8 100644
--- a/src/packages/portage.rs
+++ b/src/packages/portage.rs
@@ -1,11 +1,11 @@
1use tracing::error; 1use tracing::error;
2 2
3use super::PackageManager; 3use super::{PackageList, PackageManager};
4 4
5pub struct Portage; 5pub struct Portage;
6 6
7impl PackageManager for Portage { 7impl PackageManager for Portage {
8 fn get_installed(&self) -> crate::error::Result<Vec<super::Package>> { 8 fn get_installed(&self) -> crate::error::Result<PackageList> {
9 todo!() 9 todo!()
10 } 10 }
11 11