rpm-pkg-count

Crates.iorpm-pkg-count
lib.rsrpm-pkg-count
version0.2.1
sourcesrc
created_at2023-05-13 15:44:11.409557
updated_at2023-05-15 13:34:52.219734
descriptionCounts installed RPM packages using librpm
homepage
repositoryhttps://github.com/RubixDev/rpm-pkg-count
max_upload_size
id863780
size49,625
Silas Groh (RubixDev)

documentation

README

rpm-pkg-count

Counts installed RPM packages using librpm.

Note: This crate does not make use of librpm-sys but links to the C library itself.

Requirements

In order to compile this crate, one must have librpm installed on the system. It is usually provided by package managers under the name rpm-devel (e.g., OpenSUSE), rpm-tools (e.g., Arch Linux) or librpm-dev (e.g., Debian).

Usage

The crate provides two cargo features, exactly one of them must be enabled.

  1. compile-time: Link to librpm during compile-time using Rust's extern "C" functionality. This requires librpm to be installed on every target's system for a binary to run at all.
  2. runtime: Link to librpm during runtime using the libloading crate. This way, count() simply returns None if librpm is not installed on the target system.

The crate then exposes exactly one public function which takes no arguments and returns the package count as an Option<u32>. An example usage is shown here:

use rpm_pkg_count::count;

match unsafe { count() } {
    Some(count) => println!("{count} packages installed."),
    None => println!("packages could not be counted"),
}
Commit count: 11

cargo fmt