#linux-distro #linux #bindings #package-manager #api-bindings

pacmanager_wrapper

A utility to interact with any package manager on any Linux distro

4 releases

0.2.0 Mar 17, 2024
0.1.2 Mar 16, 2024
0.1.1 Mar 16, 2024
0.1.0 Mar 16, 2024

#544 in Unix APIs

Download history 2/week @ 2024-07-29 2/week @ 2024-09-16 9/week @ 2024-09-23 3/week @ 2024-09-30

85 downloads per month
Used in pacmanager

MIT license

25KB
577 lines

pacmanager_wrapper - A universal library for managing packages

A utility to interact with any package manager on any Linux distro

Package manager support

Currently supported:

  • Apt
  • Apk
  • Yum
  • Pacman

Example

Taken from examples/install.rs

use pacmanager_wrapper::{execute_action, PacManagerAction, PacManagerCommand};
use futures_lite::{io::BufReader, prelude::*};

#[tokio::main]
async fn main() {
    // Create a PacManagerAction
    let action = PacManagerAction {
        pacmanager_command: PacManagerCommand::Install("lolcat".to_string()), // The action we want to do (which includes the package)
        internal_config: Default::default(),
        non_interactive: true,
        custom_flags: None,
    };

    // Execute the action with APT and BufRead its output
    let mut child = execute_action(action, pacmanager_wrapper::PacManager::Apt).await.unwrap();
    let mut lines = BufReader::new(child.stdout.take().unwrap()).lines();

    // Print out the PacManager's stdout
    while let Some(line) = lines.next().await {
        println!("{}", line.unwrap());
    }
}

Dependencies

~3–12MB
~153K SLoC