Add new Package examples to main
Print debug line with module arguments when run starts Make apt package manager non-interactive Move PackageList to dedicated module and make more impls utils::Cmd now can take environment variables
This commit is contained in:
parent
f26f1c1bf2
commit
1245db813b
7 changed files with 115 additions and 147 deletions
|
|
@ -2,6 +2,10 @@ use crate::utils::cmd::Cmd;
|
|||
|
||||
use super::{PackageError, PackageList, SpecificPackageManager};
|
||||
|
||||
pub fn apt() -> Cmd {
|
||||
Cmd::new("apt").env("DEBIAN_FRONTEND", "noninteractive")
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DebianPackageManager;
|
||||
|
||||
|
|
@ -11,7 +15,7 @@ impl SpecificPackageManager for DebianPackageManager {
|
|||
}
|
||||
|
||||
fn update(&self) -> Result<(), PackageError> {
|
||||
let res = Cmd::new("apt").arg("update").run()?;
|
||||
let res = apt().arg("update").run()?;
|
||||
|
||||
if ! res.success {
|
||||
return Err(PackageError::CmdFail(res));
|
||||
|
|
@ -20,7 +24,7 @@ impl SpecificPackageManager for DebianPackageManager {
|
|||
}
|
||||
|
||||
fn install(&self, list: PackageList) -> Result<(), PackageError> {
|
||||
let res = Cmd::new("apt").arg("install").args(list.list()).run()?;
|
||||
let res = apt().arg("install").args(list.list()).run()?;
|
||||
|
||||
if ! res.success {
|
||||
return Err(PackageError::CmdFail(res));
|
||||
|
|
@ -29,7 +33,7 @@ impl SpecificPackageManager for DebianPackageManager {
|
|||
}
|
||||
|
||||
fn remove(&self, list: PackageList) -> Result<(), PackageError> {
|
||||
let res = Cmd::new("apt").arg("remove").args(list.list()).run()?;
|
||||
let res = apt().arg("remove").args(list.list()).run()?;
|
||||
|
||||
if ! res.success {
|
||||
return Err(PackageError::CmdFail(res));
|
||||
|
|
|
|||
Loading…
Reference in a new issue