Struct rpm::Package

source ·
pub struct Package {
    pub metadata: PackageMetadata,
    pub content: Vec<u8>,
}
Expand description

A complete rpm file.

Can either be created using the PackageBuilder or used with parse to obtain from a file.

Fields§

§metadata: PackageMetadata

Header and metadata structures.

Contains the constant lead as well as the metadata store.

§content: Vec<u8>

The compressed or uncompressed files.

Implementations§

source§

impl Package

source

pub fn open(path: impl AsRef<Path>) -> Result<Self, Error>

Open and parse a file at the provided path as an RPM package

source

pub fn parse(input: &mut impl BufRead) -> Result<Self, Error>

Parse an RPM package from an existing buffer

source

pub fn write(&self, out: &mut impl Write) -> Result<(), Error>

Write the RPM package to a buffer

source

pub fn write_file(&self, path: impl AsRef<Path>) -> Result<(), Error>

Write the RPM package to a file

source

pub fn sign<S>(&mut self, signer: S) -> Result<(), Error>
where S: Signing<Signature = Vec<u8>>,

Create package signatures using an external key and add them to the signature header

source

pub fn sign_with_timestamp<S>( &mut self, signer: S, t: impl TryInto<Timestamp, Error = impl Debug> ) -> Result<(), Error>
where S: Signing<Signature = Vec<u8>>,

Create package signatures using an external key and provided timestamp. Adds generated signatures to the signature header.

This method is usually used for reproducible builds, otherwise you should prefer using the sign method instead.

§Examples
let mut package = rpm::Package::open("test_assets/ima_signed.rpm")?;
let raw_secret_key = std::fs::read("./test_assets/secret_key.asc")?;
let signer = rpm::signature::pgp::Signer::load_from_asc_bytes(&raw_secret_key)?;
// It's recommended to use timestamp of last commit in your VCS
let source_date = 1_600_000_000;
package.sign_with_timestamp(signer, source_date)?;
source

pub fn signature_key_ids(&self) -> Result<Vec<String>, Error>

Return the key ids (issuers) of the signature as a hexadecimal string

source

pub fn verify_signature<V>(&self, verifier: V) -> Result<(), Error>
where V: Verifying<Signature = Vec<u8>>,

Verify the signature as present within the RPM package.

source

pub fn verify_digests(&self) -> Result<(), Error>

Verify any digests which may be present in the RPM headers

Trait Implementations§

source§

impl Debug for Package

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V