From 553bbac36bdc483135a7053ca64507e01397e5e1 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Mon, 9 Sep 2024 23:03:49 +0200 Subject: add package manager recognition --- src/packages/pacman.rs | 13 ++++++++----- src/packages/portage.rs | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/packages') 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 @@ use std::process::{Command, Stdio}; -use super::{Package, PackageManager}; +use super::{Package, PackageList, PackageManager}; use crate::error::{Error, Result}; pub struct Pacman; impl PackageManager for Pacman { - fn get_installed(&self) -> Result> { + fn get_installed(&self) -> Result { let pm_pkgs = Command::new("pacman").args(["-Q"]).output().unwrap(); let pm_e_pkgs = Command::new("pacman") .args(["-Q", "--explicit"]) @@ -37,16 +37,19 @@ impl PackageManager for Pacman { }); } - Ok(pkgs) + Ok(PackageList { + packages: pkgs, + manager: super::Manager::Pacman, + }) } fn install(&self, pkgs: Vec) -> Result<()> { - let mut args = vec!["--noconfirm".to_string(), "-S".to_string()]; + let mut args = vec!["pacman".to_string(), "--noconfirm".to_string(), "-S".to_string()]; for pkg in pkgs { args.push(pkg.id); } - Command::new("pacman") + Command::new("doas") .stdout(Stdio::inherit()) .args(args) .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 @@ use tracing::error; -use super::PackageManager; +use super::{PackageList, PackageManager}; pub struct Portage; impl PackageManager for Portage { - fn get_installed(&self) -> crate::error::Result> { + fn get_installed(&self) -> crate::error::Result { todo!() } -- cgit v1.2.3