aboutsummaryrefslogtreecommitdiff
path: root/archival/rpm.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-09-05 11:48:32 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-09-05 11:48:32 +0000
commit211f7f88ae67e875bed50409b2edbb6d740fc648 (patch)
treeae37652f75374919fff81e732fd2ab867e6a947a /archival/rpm.c
parentbeffd43d8e393b68787a00d9c6078a2b367afd01 (diff)
downloadbusybox-211f7f88ae67e875bed50409b2edbb6d740fc648.tar.gz
tar + gzip/bzip2/etc: support NOMMU machines (by Alex Landau <landau_alex@yahoo.com>)
Diffstat (limited to 'archival/rpm.c')
-rw-r--r--archival/rpm.c26
1 files changed, 23 insertions, 3 deletions
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;