diff options
Diffstat (limited to 'archival/rpm2cpio.c')
-rw-r--r-- | archival/rpm2cpio.c | 54 |
1 files changed, 12 insertions, 42 deletions
diff --git a/archival/rpm2cpio.c b/archival/rpm2cpio.c index 28b43a181..898d4aca4 100644 --- a/archival/rpm2cpio.c +++ b/archival/rpm2cpio.c | |||
@@ -66,54 +66,24 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv) | |||
66 | /* Skip the main header */ | 66 | /* Skip the main header */ |
67 | skip_header(); | 67 | skip_header(); |
68 | 68 | ||
69 | #if 0 | 69 | //if (SEAMLESS_COMPRESSION) |
70 | // /* We need to know whether child (gzip/bzip/etc) exits abnormally */ | ||
71 | // signal(SIGCHLD, check_errors_in_children); | ||
72 | |||
70 | /* This works, but doesn't report uncompress errors (they happen in child) */ | 73 | /* This works, but doesn't report uncompress errors (they happen in child) */ |
71 | setup_unzip_on_fd(rpm_fd /*fail_if_not_detected: 1*/); | 74 | setup_unzip_on_fd(rpm_fd, /*fail_if_not_detected:*/ 1); |
72 | if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0) | 75 | if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0) |
73 | bb_error_msg_and_die("error unpacking"); | 76 | bb_error_msg_and_die("error unpacking"); |
74 | #else | ||
75 | /* BLOAT */ | ||
76 | { | ||
77 | union { | ||
78 | uint8_t b[4]; | ||
79 | uint16_t b16[2]; | ||
80 | uint32_t b32[1]; | ||
81 | } magic; | ||
82 | IF_DESKTOP(long long) int FAST_FUNC (*unpack)(int src_fd, int dst_fd); | ||
83 | |||
84 | xread(rpm_fd, magic.b16, sizeof(magic.b16[0])); | ||
85 | if (magic.b16[0] == GZIP_MAGIC) { | ||
86 | unpack = unpack_gz_stream; | ||
87 | } else | ||
88 | if (ENABLE_FEATURE_SEAMLESS_BZ2 | ||
89 | && magic.b16[0] == BZIP2_MAGIC | ||
90 | ) { | ||
91 | unpack = unpack_bz2_stream; | ||
92 | } else | ||
93 | if (ENABLE_FEATURE_SEAMLESS_XZ | ||
94 | && magic.b16[0] == XZ_MAGIC1 | ||
95 | ) { | ||
96 | xread(rpm_fd, magic.b32, sizeof(magic.b32[0])); | ||
97 | if (magic.b32[0] != XZ_MAGIC2) | ||
98 | goto no_magic; | ||
99 | /* unpack_xz_stream wants fd at position 6, no need to seek */ | ||
100 | //xlseek(rpm_fd, -6, SEEK_CUR); | ||
101 | unpack = unpack_xz_stream; | ||
102 | } else { | ||
103 | no_magic: | ||
104 | bb_error_msg_and_die("no gzip" | ||
105 | IF_FEATURE_SEAMLESS_BZ2("/bzip2") | ||
106 | IF_FEATURE_SEAMLESS_XZ("/xz") | ||
107 | " magic"); | ||
108 | } | ||
109 | if (unpack(rpm_fd, STDOUT_FILENO) < 0) | ||
110 | bb_error_msg_and_die("error unpacking"); | ||
111 | } | ||
112 | #endif | ||
113 | 77 | ||
114 | if (ENABLE_FEATURE_CLEAN_UP) { | 78 | if (ENABLE_FEATURE_CLEAN_UP) { |
115 | close(rpm_fd); | 79 | close(rpm_fd); |
116 | } | 80 | } |
117 | 81 | ||
118 | return 0; | 82 | #if !ENABLE_PLATFORM_MINGW32 |
83 | if (SEAMLESS_COMPRESSION) { | ||
84 | check_errors_in_children(0); | ||
85 | return bb_got_signal; | ||
86 | } | ||
87 | #endif | ||
88 | return EXIT_SUCCESS; | ||
119 | } | 89 | } |