blob: 151dd9fb407e72c3295606fc9c8d3c1e254acd13 [file] [log] [blame]
Glenn L McGrathb8756312004-07-23 01:20:57 +00001diff -ur busybox/archival/Config.in busybox/archival/Config.in
2--- busybox/archival/Config.in Sun May 23 09:15:37 2004
3+++ busybox/archival/Config.in Sun May 23 09:15:58 2004
4@@ -127,6 +127,14 @@
5 help
6 Converts an RPM file into a CPIO archive.
7
8+config CONFIG_FEATURE_RPM2CPIO_BZIP2
9+ bool " Support bzip2 decompression"
10+ default n
11+ depends on CONFIG_RPM2CPIO
12+ help
13+ If you enable this option you'll be able to extract
14+ rpms compressed with bzip2.
15+
16 config CONFIG_RPM
17 bool "rpm"
18 default n
19diff -ur busybox/archival/libunarchive/Makefile.in busybox/archival/libunarchive/Makefile.in
20--- busybox/archival/libunarchive/Makefile.in Sun May 23 09:15:04 2004
21+++ busybox/archival/libunarchive/Makefile.in Sun May 23 09:16:42 2004
22@@ -65,6 +65,7 @@
23 LIBUNARCHIVE-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
24 LIBUNARCHIVE-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
25 LIBUNARCHIVE-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
26+LIBUNARCHIVE-$(CONFIG_FEATURE_RPM2CPIO_BZIP2) += decompress_bunzip2.o
27 LIBUNARCHIVE-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
28 LIBUNARCHIVE-$(CONFIG_TAR) += get_header_tar.o
29 LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
30diff -ur busybox/archival/rpm2cpio.c busybox/archival/rpm2cpio.c
31--- busybox/archival/rpm2cpio.c Sun May 23 09:15:04 2004
32+++ busybox/archival/rpm2cpio.c Sun May 23 09:19:03 2004
33@@ -91,14 +91,26 @@
34 skip_header(rpm_fd);
35
36 bb_xread_all(rpm_fd, &magic, 2);
37- if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
38- bb_error_msg_and_die("Invalid gzip magic");
39+ if ((magic[0] == 0x1f) || (magic[1] == 0x8b)) {
40+ check_header_gzip(rpm_fd);
41+ if (inflate_gunzip(rpm_fd, fileno(stdout)) != 0)
42+ bb_error_msg("Error inflating (gzip)");
43 }
44
45- check_header_gzip(rpm_fd);
46- if (inflate_gunzip(rpm_fd, STDOUT_FILENO) != 0) {
47- bb_error_msg("Error inflating");
48+ if ((magic[0] == 'B') && (magic[1] == 'Z')) {
49+#ifdef CONFIG_FEATURE_RPM2CPIO_BZIP2
50+ /* return to position before magic (eek..!) */
51+ lseek(rpm_fd, -2, SEEK_CUR);
52+ if(uncompressStream(rpm_fd, fileno(stdout)) != 0)
53+ bb_error_msg("Error inflating (bzip2)");
54+#else
55+ bb_error_msg_and_die("bzip2 not supported");
56+#endif
57 }
58+
59+ else
60+ bb_error_msg_and_die("not gzip or bzip2 compressed");
61+
62
63 close(rpm_fd);