Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an API for reading files from the RPM payload #251

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

dralley
Copy link
Collaborator

@dralley dralley commented Jan 17, 2025

📜 Checklist

  • Commits are cleanly separated and have useful messages
  • A changelog entry or entries has been added to CHANGELOG.md
  • Documentation is thorough
  • Test coverage is excellent and passes
  • Works when tests are run --all-features enabled

Note: I'm working on tests, but they will be easier to merge as part of the test overhaul PR. In the meantime I did some manual testing for this PR.

@dralley dralley requested a review from drahnr January 17, 2025 03:08
@dralley dralley force-pushed the cpio branch 3 times, most recently from f908a1b to 66d7a6f Compare January 17, 2025 03:22
@dralley dralley force-pushed the cpio branch 5 times, most recently from 76478d8 to b36edcf Compare January 17, 2025 22:04
@dralley
Copy link
Collaborator Author

dralley commented Jan 17, 2025

Here's a bit of example code for demo purposes:

use rpm;
use std::env::args;

fn main() {
    let rpm_path = args().nth(1).expect("provide an RPM to extract");
    let package =
    rpm::Package::open(rpm_path).unwrap();

    let dest_path = args().nth(2).unwrap_or(package.metadata.get_name().unwrap().to_owned());

    package.extract(&dest_path).unwrap();

    for f in package.files().unwrap() {
        let f = f.unwrap();
        println!("{}", f.metadata.path.display());
    }
}

@dralley dralley force-pushed the cpio branch 5 times, most recently from 390129d to 8ffcf4d Compare January 17, 2025 23:13
Copy link
Contributor

@drahnr drahnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, bar some more documentation details

@dralley
Copy link
Collaborator Author

dralley commented Jan 20, 2025

@drahnr I tweaked the behavior slightly such that it uses create_dir instead of create_dir_all. That simplifies the semantics.

@dralley dralley merged commit 114faee into rpm-rs:master Jan 21, 2025
15 checks passed
@dralley dralley deleted the cpio branch January 21, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants