librpm.rs icon indicating copy to clipboard operation
librpm.rs copied to clipboard

Error Buildin librpm

Open ghost opened this issue 7 years ago • 7 comments

This is my function to get the number of total installed packages on a system with rpm. I am building on Fedora 28

fn rpm() -> usize {
    use librpm::*;
    librpm::config::read_file(None).unwrap();
    let cache = installed_packages();
    let total_packages = cache.map(|_| ()).count();
}

I am getting an error

librpm_sys::delMacro(self.0, cstr.as_ptr());
   |               ^^^^^^^^ not found in `librpm_sys`

ghost avatar Jan 22 '19 19:01 ghost

It's a bit hard to read the error since it looks misaligned, but it appears to be saying that delMacro is undefined.

That function would be defined by bindgen, and is ultimately defined by the librpm C library:

http://ftp.rpm.org/api/4.7.0/group__rpmmacro.html#g6365bacb2f43539de94cd6c275968311

You might check your rpm-libs version (it looks like Fedora 28 has 4.14?). That said, to my knowledge it's a relatively old function and one I wouldn't expect they'd remove, especially in a stable version.

It might be an issue with bindgen. You could try running cargo doc on the librpm-sys crate and seeing what functions are available.

tarcieri avatar Jan 22 '19 19:01 tarcieri

You are correct Fedora uses 4.14. I ran cargo doc -p librpm-sys --open, Should I expect to see any functions that aren't crates.io's docs?

ghost avatar Jan 25 '19 22:01 ghost

Do you see delMacro on your local copy of the docs?

https://rustrpm.org/librpm_sys/fn.delMacro.html

tarcieri avatar Jan 28 '19 16:01 tarcieri

Yes I do

ghost avatar Feb 03 '19 14:02 ghost

That's strange, because that error seems to indicate your local copy of librpm_sys is missing the delMacro function

tarcieri avatar Feb 03 '19 14:02 tarcieri

I had this same issue, and my machine is using librpm 4.14.2. Is there any planned support for the API changes that came with 4.14?

ErichDonGubler avatar Aug 07 '19 22:08 ErichDonGubler