A pure rust library for parsing and creating RPM files.
RPM has a lot of cryptic features. I do not want to re-implement all of them. This library focuses on the ones that I assume as useful. This library does not build software like rpmbuild. It is meant for finished artifacts that need to be packaged as RPM.
```rust use std::str::FromStr;
use rpm; use rpm::signature::pgp::{Signer,Verifier};
let rawsecretkey = std::fs::read("/path/to/gpg.secret.key")?; let pkg = rpm::RPMBuilder::new("test", "1.0.0", "MIT", "x8664", "some awesome package") .compression(rpm::Compressor::fromstr("gzip")?) .withfile( "./awesome-config.toml", rpm::RPMFileOptions::new("/etc/awesome/config.toml").isconfig(), )? // file mode is inherited from source file .withfile( "./awesome-bin", rpm::RPMFileOptions::new("/usr/bin/awesome"), )? .withfile( "./awesome-config.toml", // you can set a custom mode and custom user too rpm::RPMFileOptions::new("/etc/awesome/second.toml").mode(0o100744).user("hugo"), )? .preinstallscript("echo preinst") .addchangelogentry("Max Mustermann max@example.com", "- was awesome, eh?", chrono::DateTime::parsefromrfc2822("Wed, 19 April 2023 23:16:09 GMT")) .addchangelogentry("Charlie Yom test2@example.com", "- yeah, it was", chrono::DateTime::parsefromrfc3339("1996-12-19T16:39:57-08:00")) .requires(rpm::Dependency::any("wget")) .vendor("corporation or individual") .url("www.github.com/repo") .vcs("git:repo=examplerepo:branch=examplebranch:sha=examplesha") .buildandsign(Signer::loadfromascbytes(&rawsecretkey)?);
let mut f = std::fs::File::create("./awesome.rpm")?; pkg.write(&mut f)?;
// reading let rawpubkey = std::fs::read("/path/to/gpg.key.pub")?; let pkg = rpm::RPMPackage::open("testassets/389-ds-base-devel-1.3.8.4-15.el7.x8664.rpm")?;
// verifying pkg.verifysignature(Verifier::loadfromascbytes(&rawpubkey)?)?; ```