diff options
author | fxqnlr <[email protected]> | 2024-09-09 23:03:49 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2024-09-09 23:03:49 +0200 |
commit | 553bbac36bdc483135a7053ca64507e01397e5e1 (patch) | |
tree | 494dad0623628df4f1b86b93da51edf60795a901 /src/packages | |
parent | d396881816cd256cb12d03deebea445cba99ea85 (diff) | |
download | arbs-553bbac36bdc483135a7053ca64507e01397e5e1.tar arbs-553bbac36bdc483135a7053ca64507e01397e5e1.tar.gz arbs-553bbac36bdc483135a7053ca64507e01397e5e1.zip |
add package manager recognition
Diffstat (limited to 'src/packages')
-rw-r--r-- | src/packages/pacman.rs | 13 | ||||
-rw-r--r-- | src/packages/portage.rs | 4 |
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 @@ | |||
1 | use std::process::{Command, Stdio}; | 1 | use std::process::{Command, Stdio}; |
2 | 2 | ||
3 | use super::{Package, PackageManager}; | 3 | use super::{Package, PackageList, PackageManager}; |
4 | 4 | ||
5 | use crate::error::{Error, Result}; | 5 | use crate::error::{Error, Result}; |
6 | 6 | ||
7 | pub struct Pacman; | 7 | pub struct Pacman; |
8 | 8 | ||
9 | impl PackageManager for Pacman { | 9 | impl 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 @@ | |||
1 | use tracing::error; | 1 | use tracing::error; |
2 | 2 | ||
3 | use super::PackageManager; | 3 | use super::{PackageList, PackageManager}; |
4 | 4 | ||
5 | pub struct Portage; | 5 | pub struct Portage; |
6 | 6 | ||
7 | impl PackageManager for Portage { | 7 | impl 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 | ||