#rpm #fetch #librpm

sys rpm-pkg-count

Counts installed RPM packages using librpm

3 unstable releases

0.2.1 May 15, 2023
0.2.0 May 14, 2023
0.1.0 May 13, 2023

#18 in #rpm

Download history 199/week @ 2024-07-28 95/week @ 2024-08-04 129/week @ 2024-08-11 87/week @ 2024-08-18 98/week @ 2024-08-25 156/week @ 2024-09-01 663/week @ 2024-09-08 341/week @ 2024-09-15 295/week @ 2024-09-22 297/week @ 2024-09-29 318/week @ 2024-10-06 229/week @ 2024-10-13 333/week @ 2024-10-20 532/week @ 2024-10-27 294/week @ 2024-11-03 310/week @ 2024-11-10

1,496 downloads per month
Used in 10 crates (2 directly)

GPL-3.0-only

18KB
127 lines

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"),
}

Dependencies

~0–4.5MB