Expand description
§rpm-rs
A library providing API to parse rpms as well as creating rpms from individual files.
§Example
use rpm::{
signature::pgp::{
Signer,
Verifier
},
};
use std::str::FromStr;
let raw_secret_key = std::fs::read("./test_assets/secret_key.asc")?;
// It's recommended to use timestamp of last commit in your VCS
let source_date = 1_600_000_000;
let pkg = rpm::PackageBuilder::new("test", "1.0.0", "MIT", "x86_64", "some awesome package")
.compression(rpm::CompressionType::Gzip)
.with_file(
"./test_assets/awesome.toml",
rpm::FileOptions::new("/etc/awesome/config.toml").is_config(),
)?
// file mode is inherited from source file
.with_file(
"./test_assets/awesome.py",
rpm::FileOptions::new("/usr/bin/awesome"),
)?
.with_file(
"./test_assets/awesome.toml",
// you can set a custom mode and custom user too
rpm::FileOptions::new("/etc/awesome/second.toml")
.mode(rpm::FileMode::regular(0o644))
.user("hugo"),
)?
.pre_install_script("echo preinst")
// If you don't need reproducible builds,
// you can remove the following line
.source_date(source_date)
.build_host(gethostname::gethostname().to_str().unwrap_or("host"))
.add_changelog_entry(
"Max Mustermann <max@example.com> - 0.1-29",
"- was awesome, eh?",
chrono::DateTime::parse_from_rfc2822("Wed, 19 Apr 2023 23:16:09 GMT")
.expect("Date 1 is correct. qed"),
)
.add_changelog_entry(
"Charlie Yom <test2@example.com> - 0.1-28",
"- yeah, it was",
// Raw timestamp for 1996-08-14 05:20:00
840_000_000,
)
.requires(rpm::Dependency::any("wget"))
.vendor("corporation or individual")
.url("www.github.com/repo")
.vcs("git:repo=example_repo:branch=example_branch:sha=example_sha")
.build_and_sign(Signer::load_from_asc_bytes(&raw_secret_key)?)?;
let mut f = std::fs::File::create("/tmp/awesome.rpm")?;
pkg.write(&mut f)?;
// reading
let raw_pub_key = std::fs::read("test_assets/public_key.asc")?;
let pkg = rpm::Package::open("/tmp/awesome.rpm")?;
// verifying
pkg.verify_signature(Verifier::load_from_asc_bytes(&raw_pub_key)?)?;Re-exports§
pub use ::chrono;
Modules§
Structs§
- Changelog
Entry - User facing accessor type for a changelog entry
- Dependency
- Description of a dependency as present in a RPM header record.
- Dependency
Flags - Digests
- Combined digest of signature header tags
RPMSIGTAG_MD5andRPMSIGTAG_SHA1 - Empty
- Initial empty builder.
- File
Entry - User facing accessor type for a file entry with contextual information
- File
Flags - File
Options - Description of file modes.
- File
Options Builder - File
Ownership - User facing accessor type representing ownership of a file
- File
Verify Flags - Header
- Package
- A complete rpm file.
- Package
Builder - Create an RPM file by specifying metadata and files using the builder pattern.
- Package
File Entry - Describes a file present in the rpm file.
- Package
Metadata - Package
Segment Offsets - Offsets into an RPM Package (from the start of the file) demarking locations of each section
- Sha256
Writer - A wrapper for calculating the sha256 checksum of the contents written to it
- Signature
Header Builder - base signature header builder
- Timestamp
- Timestamp as a number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
- With
Digest - Builder beyond the empty stage, already containing a digest.
- With
Signature - Builder already has a hash and is ready for completion.
Enums§
- Compression
Type - Supported payload compression types.
- Compression
With Level - Supported compression types, with an associated compression level. This is used for setting a custom compression configuration during RPM building.
- Compressor
- Digest
Algorithm - Error
- File
Digest - File
Mode - Index
Signature Tag - Index
Tag - Timestamp
Error
Constants§
- HEADER_
I18NTABLE - HEADER_
IMAGE - HEADER_
IMMUTABLE - HEADER_
MAGIC - header magic recognition (not the lead!)
- HEADER_
REGIONS - HEADER_
SIGBASE - HEADER_
SIGNATURES - HEADER_
TAGBASE - INDEX_
ENTRY_ SIZE - Size (in bytes) of each entry in the index
- INDEX_
HEADER_ SIZE - Size (in bytes) of the index header (the fixed portion of each header)
- LEAD_
SIZE - Size (in bytes) of the package “lead” section
- RPMTAG_
SIG_ BASE - RPM_
MAGIC - rpm magic as part of the lead header
Traits§
- Construction
Stage - A marker trait for builder stages
- Tag
- Header tag.