From 211f7f88ae67e875bed50409b2edbb6d740fc648 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 5 Sep 2007 11:48:32 +0000 Subject: tar + gzip/bzip2/etc: support NOMMU machines (by Alex Landau ) --- archival/rpm.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'archival/rpm.c') diff --git a/archival/rpm.c b/archival/rpm.c index 674ee2640..4d723b73f 100644 --- a/archival/rpm.c +++ b/archival/rpm.c @@ -187,9 +187,15 @@ 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]; +#if BB_MMU + USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd); + enum { xformer_prog = 0 }; +#else + enum { xformer = 0 }; + const char *xformer_prog; +#endif /* Initialize */ archive_handle = init_handle(); @@ -202,11 +208,19 @@ static void extract_cpio_gz(int fd) archive_handle->offset = 0; xread(archive_handle->src_fd, &magic, 2); +#if BB_MMU xformer = unpack_gz_stream; +#else + xformer_prog = "gunzip"; +#endif if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { if (ENABLE_FEATURE_RPM_BZ2 && (magic[0] == 0x42) && (magic[1] == 0x5a)) { +#if BB_MMU xformer = unpack_bz2_stream; +#else + xformer_prog = "bunzip2"; +#endif /* 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); @@ -214,11 +228,17 @@ static void extract_cpio_gz(int fd) bb_error_msg_and_die("no gzip" USE_FEATURE_RPM_BZ2("/bzip") " magic"); - } else + } else { check_header_gzip_or_die(archive_handle->src_fd); +#if !BB_MMU + /* NOMMU version of open_transformer execs an external unzipper that should + * have the file position at the start of the file */ + xlseek(archive_handle->src_fd, 0, SEEK_SET); +#endif + } xchdir("/"); /* Install RPM's to root */ - archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer); + archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog, xformer_prog, "-cf", "-", NULL); archive_handle->offset = 0; while (get_header_cpio(archive_handle) == EXIT_SUCCESS) continue; -- cgit v1.2.3