aboutsummaryrefslogtreecommitdiff
path: root/archival/rpm.c
diff options
context:
space:
mode:
authorGravatar Denis Vlasenko <vda.linux@googlemail.com>2007-06-08 13:05:39 +0000
committerGravatar Denis Vlasenko <vda.linux@googlemail.com>2007-06-08 13:05:39 +0000
commitc14d39e83a7f55ab9b92e98673a281fd6565c32d (patch)
treef1cfe7f071b228cf7f1a732046cabf18fa9421b8 /archival/rpm.c
parentdef8260219797b0f9f734915f4918f34e85e7049 (diff)
downloadbusybox-c14d39e83a7f55ab9b92e98673a281fd6565c32d.tar.gz
busybox-c14d39e83a7f55ab9b92e98673a281fd6565c32d.tar.bz2
rmp: add optional support for bz2 data. +50 bytes of code
Diffstat (limited to 'archival/rpm.c')
-rw-r--r--archival/rpm.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/archival/rpm.c b/archival/rpm.c
index 71ed32e41..674ee2640 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -187,10 +187,11 @@ int rpm_main(int argc, char **argv)
static void extract_cpio_gz(int fd)
{
+ USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd);
archive_handle_t *archive_handle;
unsigned char magic[2];
- /* Initialise */
+ /* Initialize */
archive_handle = init_handle();
archive_handle->seek = seek_by_read;
//archive_handle->action_header = header_list;
@@ -201,16 +202,26 @@ static void extract_cpio_gz(int fd)
archive_handle->offset = 0;
xread(archive_handle->src_fd, &magic, 2);
+ xformer = unpack_gz_stream;
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
- bb_error_msg_and_die("invalid gzip magic");
- }
- check_header_gzip_or_die(archive_handle->src_fd);
- xchdir("/"); /* Install RPM's to root */
+ if (ENABLE_FEATURE_RPM_BZ2
+ && (magic[0] == 0x42) && (magic[1] == 0x5a)) {
+ xformer = unpack_bz2_stream;
+ /* We can do better, need modifying unpack_bz2_stream to not require
+ * first 2 bytes. Not very hard to do... I mean, TODO :) */
+ xlseek(archive_handle->src_fd, -2, SEEK_CUR);
+ } else
+ bb_error_msg_and_die("no gzip"
+ USE_FEATURE_RPM_BZ2("/bzip")
+ " magic");
+ } else
+ check_header_gzip_or_die(archive_handle->src_fd);
- archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
+ xchdir("/"); /* Install RPM's to root */
+ archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer);
archive_handle->offset = 0;
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
- /* loop */;
+ continue;
}