archlinux / alpm.rs

Rust bindings for libalpm
GNU General Public License v3.0
112 stars 21 forks source link

APIs for file checksums? #36

Open VorpalBlade opened 7 months ago

VorpalBlade commented 7 months ago

pacman -Qii can list changed config files, and paccheck can find any changed files from packages. I can find neither functionality in the alpm crate (but maybe I missed something?). I would have expected it to be found in https://docs.rs/alpm/latest/alpm/struct.File.html

Is this something that would be possible to expose (getting the expected checksums of installed files). I'm also interested in getting the expected file contents of any of those changed files (in order to generate diffs for changed config files).

VorpalBlade commented 7 months ago

So I figured this out: You need to enable the mtree feature. Which is not enabled when building the docs on docs.rs. I believe it is possible to build with all features in the future though by adding some lines in Cargo.toml: https://docs.rs/about/metadata

So, I'm not closing this bug yet (I think it morphed into "enable all features for docs.rs")

Morganamilo commented 7 months ago

Yeah mtree is the way to get this. Tell me if it works for you as I believe there were some issues with it last time I checked (a few years ago) which come from the libarchive library segfaulting.

VorpalBlade commented 7 months ago

Unfortunately it seems your/libarchive's mtree API doesn't expose the checksums though, so it isn't usable for my needs anyway. I found an old native-rust crate for parsing mtrees that does support this, but it seems unmaintained.