#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

#672 in Unix APIs

Download history 88/week @ 2023-12-17 140/week @ 2023-12-24 67/week @ 2023-12-31 75/week @ 2024-01-07 70/week @ 2024-01-14 72/week @ 2024-01-21 105/week @ 2024-01-28 102/week @ 2024-02-04 115/week @ 2024-02-11 109/week @ 2024-02-18 129/week @ 2024-02-25 130/week @ 2024-03-03 144/week @ 2024-03-10 128/week @ 2024-03-17 186/week @ 2024-03-24 172/week @ 2024-03-31

656 downloads per month
Used in 6 crates (via libmacchina)


127 lines


Counts installed RPM packages using librpm.

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


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).


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