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/pacman.rs | |
parent | d396881816cd256cb12d03deebea445cba99ea85 (diff) | |
download | arbs-553bbac36bdc483135a7053ca64507e01397e5e1.tar arbs-553bbac36bdc483135a7053ca64507e01397e5e1.tar.gz arbs-553bbac36bdc483135a7053ca64507e01397e5e1.zip |
add package manager recognition
Diffstat (limited to 'src/packages/pacman.rs')
-rw-r--r-- | src/packages/pacman.rs | 13 |
1 files changed, 8 insertions, 5 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()? |