Skip to content

Enhance rpm2archive(8) to support cpio format too #2758

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

Merged
merged 9 commits into from
Nov 10, 2023

Conversation

pmatilai
Copy link
Member

@pmatilai pmatilai commented Nov 9, 2023

Enhance rpm2archive to support cpio format too, replace rpm2cpio with it entirely.

This is important as rpm2cpio can't deal with 64bit file sizes which will be the norm in v6.
For details, see the commit messages.

@pmatilai pmatilai added cleanup v6 Related to rpm v6 (readiness) labels Nov 9, 2023
@pmatilai pmatilai force-pushed the cpio-obs branch 2 times, most recently from 6733d12 to 41ae1fc Compare November 9, 2023 13:59
No actual change, just allows more comprehensive testing, easier to
read and add more.
runroot is the wrong thing to use with rpm2cpio which doesn't understand
things like --define. This has only worked because rpm2cpio is dumb
enough not to look at its arguments at all.
Take advantage of rpmfiStat() and archive_entry_copy_stat() which
handle most of the dirty work here. Hardlink sizes are special because
in archives, the file size is 0 except for the one with the content,
but otherwise of course hardlinked files have sizes as usual.
cpio is a legacy format but content in that format will remain with us
for a very, very, very long time still. Better support the format here
than have to support a separate tool just for the purpose.

The "new ascii cpio" format can't host files larger than 4GB, but
most rpm content fits and will continue to do so in that range easily,
so instead of just outlawing the good 'ole format, just skip over
anything we can't handle and emit a warning.

Additionally, if invoked as "rpm2cpio", behave like it: no compression,
cpio format.
Do all the entry fillup in the function intended for that,
no functional changes intended. Drop the unnecessary nlink check
from the unpacking: if there's content, it should unpacked.
Now that rpm2archive knows how to impersonate rpm2cpio when called by
that name, we can just drop the latter entirely. The one notable
behavior change is src.rpm contents now getting ./ prepended to the
paths. We could fixup for that too, but there's doesn't seem to be
any reason to bother.

It's crucial that we start steering people away from rpm2cpio because it
wont be able to deal with v6 content. cpio is obsolete even in POSIX now.
Copy link
Contributor

@dmnks dmnks 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!

@@ -237,6 +273,12 @@ int main(int argc, const char *argv[])

optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
poptSetOtherOptionHelp(optCon, "[OPTIONS]* <FILES>");

if (rstreq(basename(argv[0]), "rpm2cpio")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Clever! 😄

@pmatilai
Copy link
Member Author

Okay, I guess we'll just merge then. Thanks for the eyeballs 😄

@pmatilai pmatilai merged commit 833cd91 into rpm-software-management:master Nov 10, 2023
@pmatilai pmatilai deleted the cpio-obs branch November 10, 2023 14:05
@dmnks dmnks changed the title Replace rpm2cpio with rpm2archive Enhance rpm2archive to support cpio format too Apr 8, 2024
@dmnks dmnks added RFE CLI Command-line interface and removed cleanup labels Apr 8, 2024
@dmnks dmnks changed the title Enhance rpm2archive to support cpio format too Enhance rpm2archive(8) to support cpio format too Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI Command-line interface RFE v6 Related to rpm v6 (readiness)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants