rpm2cpio: extract cpio even if compression is not known

This is more useful than failing outright.

function                                             old     new   delta
rpm2cpio_main                                        110     144     +34
.rodata                                           105681  105715     +34
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 68/0)               Total: 68 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2025-04-20 23:59:38 +02:00
parent c61fdadf97
commit f13f68288f

View file

@ -533,6 +533,7 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv)
// /* We need to know whether child (gzip/bzip/etc) exits abnormally */ // /* We need to know whether child (gzip/bzip/etc) exits abnormally */
// signal(SIGCHLD, check_errors_in_children); // signal(SIGCHLD, check_errors_in_children);
str = NULL;
if (ENABLE_FEATURE_SEAMLESS_LZMA if (ENABLE_FEATURE_SEAMLESS_LZMA
&& (str = rpm_getstr0(TAG_PAYLOADCOMPRESSOR)) != NULL && (str = rpm_getstr0(TAG_PAYLOADCOMPRESSOR)) != NULL
&& strcmp(str, "lzma") == 0 && strcmp(str, "lzma") == 0
@ -541,7 +542,11 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv)
// set up decompressor without detection // set up decompressor without detection
setup_lzma_on_fd(rpm_fd); setup_lzma_on_fd(rpm_fd);
} else { } else {
setup_unzip_on_fd(rpm_fd, /*die_if_not_compressed:*/ 1); int signature_bytes = setup_unzip_on_fd(rpm_fd, /*die_if_not_compressed:*/ 0);
if (signature_bytes != 0) {
xlseek(rpm_fd, - signature_bytes, SEEK_CUR);
bb_error_msg("warning, unknown compression '%s'", str);
}
} }
if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0) if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0)