From 0cf64c8b5d86d603903397bfce87dea5a862caec Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 10 Aug 2017 10:35:08 +0200 Subject: rpm2cpio: handle LZMA compressed rpms. closes 10166 function old new delta rpm2cpio_main 78 120 +42 setup_lzma_on_fd - 29 +29 fork_transformer_and_free - 28 +28 ... setup_unzip_on_fd 56 32 -24 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/5 up/down: 104/-67) Total: 37 bytes Signed-off-by: Denys Vlasenko --- archival/rpm.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'archival/rpm.c') diff --git a/archival/rpm.c b/archival/rpm.c index f46d88b92..cca17da33 100644 --- a/archival/rpm.c +++ b/archival/rpm.c @@ -56,6 +56,8 @@ #define TAG_DIRINDEXES 1116 #define TAG_BASENAMES 1117 #define TAG_DIRNAMES 1118 +#define TAG_PAYLOADCOMPRESSOR 1125 + #define RPMFILE_CONFIG (1 << 0) #define RPMFILE_DOC (1 << 1) @@ -510,6 +512,7 @@ int rpm_main(int argc, char **argv) int rpm2cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int rpm2cpio_main(int argc UNUSED_PARAM, char **argv) { + const char *str; int rpm_fd; G.pagesize = getpagesize(); @@ -520,11 +523,17 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv) // /* We need to know whether child (gzip/bzip/etc) exits abnormally */ // signal(SIGCHLD, check_errors_in_children); -//TODO: look for rpm tag RPMTAG_PAYLOADCOMPRESSOR (dec 1125, hex 0x465), -// if the value is "lzma", set up decompressor without detection -// (lzma can't be detected). + if (ENABLE_FEATURE_SEAMLESS_LZMA + && (str = rpm_getstr0(TAG_PAYLOADCOMPRESSOR)) != NULL + && strcmp(str, "lzma") == 0 + ) { + // lzma compression can't be detected + // set up decompressor without detection + setup_lzma_on_fd(rpm_fd); + } else { + setup_unzip_on_fd(rpm_fd, /*fail_if_not_compressed:*/ 1); + } - setup_unzip_on_fd(rpm_fd, /*fail_if_not_compressed:*/ 1); if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0) bb_error_msg_and_die("error unpacking"); -- cgit v1.2.3