adjust defconfig
[buildroot.git] / package / busybox / busybox-1.7.0-targz_nommu.patch
blobaa3c046fd0d3183a34e6c77c777584d7852e3fbd
1 diff -urN busybox-1.7.0/archival/bbunzip.c busybox-1.7.0-targz_nommu/archival/bbunzip.c
2 --- busybox-1.7.0/archival/bbunzip.c 2007-08-24 11:49:45.000000000 +0100
3 +++ busybox-1.7.0-targz_nommu/archival/bbunzip.c 2007-09-06 17:42:02.000000000 +0100
4 @@ -298,7 +298,7 @@
5 int unlzma_main(int argc, char **argv);
6 int unlzma_main(int argc, char **argv)
8 - getopt32(argv, "c");
9 + getopt32(argv, "cf");
10 argv += optind;
11 /* lzmacat? */
12 if (applet_name[4] == 'c')
13 diff -urN busybox-1.7.0/archival/libunarchive/Kbuild busybox-1.7.0-targz_nommu/archival/libunarchive/Kbuild
14 --- busybox-1.7.0/archival/libunarchive/Kbuild 2007-08-24 11:49:45.000000000 +0100
15 +++ busybox-1.7.0-targz_nommu/archival/libunarchive/Kbuild 2007-09-06 17:42:02.000000000 +0100
16 @@ -35,36 +35,34 @@
17 get_header_tar.o \
18 filter_accept_list_reassign.o
20 -# open_transformer uses fork(). Compile it only if absolutely necessary
21 lib-$(CONFIG_RPM) += open_transformer.o
22 -lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o
23 -lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o
24 -lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o
25 -lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o
26 -lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o
27 -lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o
28 -lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.o
30 -lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
31 -lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
32 -lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
33 -lib-$(CONFIG_CPIO) += get_header_cpio.o
34 -lib-$(CONFIG_DPKG) += $(DPKG_FILES)
35 -lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
36 -lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
37 -lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
38 -lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
39 -lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
40 -lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
41 -lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
42 -lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
43 -lib-$(CONFIG_FEATURE_RPM_BZ2) += decompress_bunzip2.o
44 -lib-$(CONFIG_TAR) += get_header_tar.o
45 -lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
46 -lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
47 -lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
48 -lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
49 -lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
50 -lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
51 -lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
52 +lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o
53 +lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o
54 +lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o
55 +lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o
56 +lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o
57 +lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o
58 +lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.o
60 +lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
61 +lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
62 +lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
63 +lib-$(CONFIG_CPIO) += get_header_cpio.o
64 +lib-$(CONFIG_DPKG) += $(DPKG_FILES)
65 +lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
66 +lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
67 +lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
68 +lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
69 +lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
70 +lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
71 +lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
72 +lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
73 +lib-$(CONFIG_FEATURE_RPM_BZ2) += decompress_bunzip2.o
74 +lib-$(CONFIG_TAR) += get_header_tar.o
75 +lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
76 +lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
77 +lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
78 +lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
79 +lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
80 +lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
81 +lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
82 diff -urN busybox-1.7.0/archival/libunarchive/get_header_tar_bz2.c busybox-1.7.0-targz_nommu/archival/libunarchive/get_header_tar_bz2.c
83 --- busybox-1.7.0/archival/libunarchive/get_header_tar_bz2.c 2007-08-24 11:49:45.000000000 +0100
84 +++ busybox-1.7.0-targz_nommu/archival/libunarchive/get_header_tar_bz2.c 2007-09-06 17:42:02.000000000 +0100
85 @@ -11,7 +11,7 @@
86 /* Can't lseek over pipes */
87 archive_handle->seek = seek_by_read;
89 - archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream);
90 + archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2", "bunzip2", "-cf", "-", NULL);
91 archive_handle->offset = 0;
92 while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
94 diff -urN busybox-1.7.0/archival/libunarchive/get_header_tar_gz.c busybox-1.7.0-targz_nommu/archival/libunarchive/get_header_tar_gz.c
95 --- busybox-1.7.0/archival/libunarchive/get_header_tar_gz.c 2007-08-24 11:49:45.000000000 +0100
96 +++ busybox-1.7.0-targz_nommu/archival/libunarchive/get_header_tar_gz.c 2007-09-06 17:42:02.000000000 +0100
97 @@ -8,19 +8,26 @@
99 char get_header_tar_gz(archive_handle_t *archive_handle)
101 +#if BB_MMU
102 unsigned char magic[2];
103 +#endif
105 /* Can't lseek over pipes */
106 archive_handle->seek = seek_by_read;
108 + /* Check gzip magic only if open_transformer will invoke unpack_gz_stream (MMU case).
109 + * Otherwise, it will invoke an external helper "gunzip -cf" (NOMMU case) which will
110 + * need the header. */
111 +#if BB_MMU
112 xread(archive_handle->src_fd, &magic, 2);
113 if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
114 bb_error_msg_and_die("invalid gzip magic");
117 check_header_gzip_or_die(archive_handle->src_fd);
118 +#endif
120 - archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream);
121 + archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip", "gunzip", "-cf", "-", NULL);
122 archive_handle->offset = 0;
123 while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
125 diff -urN busybox-1.7.0/archival/libunarchive/get_header_tar_lzma.c busybox-1.7.0-targz_nommu/archival/libunarchive/get_header_tar_lzma.c
126 --- busybox-1.7.0/archival/libunarchive/get_header_tar_lzma.c 2007-08-24 11:49:45.000000000 +0100
127 +++ busybox-1.7.0-targz_nommu/archival/libunarchive/get_header_tar_lzma.c 2007-09-06 17:42:02.000000000 +0100
128 @@ -14,7 +14,7 @@
129 /* Can't lseek over pipes */
130 archive_handle->seek = seek_by_read;
132 - archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream);
133 + archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma", "unlzma", "-cf", "-", NULL);
134 archive_handle->offset = 0;
135 while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
137 diff -urN busybox-1.7.0/archival/libunarchive/open_transformer.c busybox-1.7.0-targz_nommu/archival/libunarchive/open_transformer.c
138 --- busybox-1.7.0/archival/libunarchive/open_transformer.c 2007-08-24 11:49:45.000000000 +0100
139 +++ busybox-1.7.0-targz_nommu/archival/libunarchive/open_transformer.c 2007-09-05 12:28:55.000000000 +0100
140 @@ -7,27 +7,48 @@
141 #include "unarchive.h"
143 /* transformer(), more than meets the eye */
145 + * On MMU machine, the transform_prog and ... are stripped
146 + * by a macro in include/unarchive.h. On NOMMU, transformer is stripped.
147 + */
148 int open_transformer(int src_fd,
149 - USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd))
150 + USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd),
151 + const char *transform_prog, ...)
153 int fd_pipe[2];
154 int pid;
156 xpipe(fd_pipe);
158 +#if BB_MMU
159 pid = fork();
160 - if (pid == -1) {
161 +#else
162 + pid = vfork();
163 +#endif
164 + if (pid == -1)
165 bb_perror_msg_and_die("fork failed");
168 if (pid == 0) {
169 +#if !BB_MMU
170 + va_list ap;
171 +#endif
172 /* child process */
173 close(fd_pipe[0]); /* We don't wan't to read from the parent */
174 // FIXME: error check?
175 +#if BB_MMU
176 transformer(src_fd, fd_pipe[1]);
177 - close(fd_pipe[1]); /* Send EOF */
178 - close(src_fd);
179 + if (ENABLE_FEATURE_CLEAN_UP) {
180 + close(fd_pipe[1]); /* Send EOF */
181 + close(src_fd);
183 exit(0);
184 +#else
185 + xmove_fd(src_fd, 0);
186 + xmove_fd(fd_pipe[1], 1);
187 + va_start(ap, transform_prog);
188 + BB_EXECVP(transform_prog, ap);
189 + bb_perror_and_die("exec failed");
190 +#endif
191 /* notreached */
194 diff -urN busybox-1.7.0/archival/rpm.c busybox-1.7.0-targz_nommu/archival/rpm.c
195 --- busybox-1.7.0/archival/rpm.c 2007-08-24 11:49:45.000000000 +0100
196 +++ busybox-1.7.0-targz_nommu/archival/rpm.c 2007-09-06 17:42:02.000000000 +0100
197 @@ -187,9 +187,15 @@
199 static void extract_cpio_gz(int fd)
201 - USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd);
202 archive_handle_t *archive_handle;
203 unsigned char magic[2];
204 +#if BB_MMU
205 + USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd);
206 + enum { xformer_prog = 0 };
207 +#else
208 + enum { xformer = 0 };
209 + const char *xformer_prog;
210 +#endif
212 /* Initialize */
213 archive_handle = init_handle();
214 @@ -202,11 +208,19 @@
215 archive_handle->offset = 0;
217 xread(archive_handle->src_fd, &magic, 2);
218 +#if BB_MMU
219 xformer = unpack_gz_stream;
220 +#else
221 + xformer_prog = "gunzip";
222 +#endif
223 if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
224 if (ENABLE_FEATURE_RPM_BZ2
225 && (magic[0] == 0x42) && (magic[1] == 0x5a)) {
226 +#if BB_MMU
227 xformer = unpack_bz2_stream;
228 +#else
229 + xformer_prog = "bunzip2";
230 +#endif
231 /* We can do better, need modifying unpack_bz2_stream to not require
232 * first 2 bytes. Not very hard to do... I mean, TODO :) */
233 xlseek(archive_handle->src_fd, -2, SEEK_CUR);
234 @@ -214,11 +228,17 @@
235 bb_error_msg_and_die("no gzip"
236 USE_FEATURE_RPM_BZ2("/bzip")
237 " magic");
238 - } else
239 + } else {
240 check_header_gzip_or_die(archive_handle->src_fd);
241 +#if !BB_MMU
242 + /* NOMMU version of open_transformer execs an external unzipper that should
243 + * have the file position at the start of the file */
244 + xlseek(archive_handle->src_fd, 0, SEEK_SET);
245 +#endif
248 xchdir("/"); /* Install RPM's to root */
249 - archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer);
250 + archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog, xformer_prog, "-cf", "-", NULL);
251 archive_handle->offset = 0;
252 while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
253 continue;
254 diff -urN busybox-1.7.0/archival/tar.c busybox-1.7.0-targz_nommu/archival/tar.c
255 --- busybox-1.7.0/archival/tar.c 2007-08-24 11:49:45.000000000 +0100
256 +++ busybox-1.7.0-targz_nommu/archival/tar.c 2007-09-06 17:42:02.000000000 +0100
257 @@ -648,7 +648,7 @@
258 bb_error_msg_and_die("invalid magic");
261 - archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress);
262 + archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress", "uncompress", "-cf", "-", NULL);
263 archive_handle->offset = 0;
264 while (get_header_tar(archive_handle) == EXIT_SUCCESS)
265 /* nothing */;
266 diff -urN busybox-1.7.0/include/unarchive.h busybox-1.7.0-targz_nommu/include/unarchive.h
267 --- busybox-1.7.0/include/unarchive.h 2007-08-24 11:49:55.000000000 +0100
268 +++ busybox-1.7.0-targz_nommu/include/unarchive.h 2007-09-06 17:42:02.000000000 +0100
269 @@ -115,7 +115,13 @@
270 extern USE_DESKTOP(long long) int unpack_gz_stream(int src_fd, int dst_fd);
271 extern USE_DESKTOP(long long) int unpack_lzma_stream(int src_fd, int dst_fd);
273 +#if BB_MMU
274 extern int open_transformer(int src_fd,
275 USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd));
276 +#define open_transformer(src_fd, transformer, transform_prog, ...) open_transformer(src_fd, transformer)
277 +#else
278 +extern int open_transformer(int src_fd, const char *transform_prog, ...);
279 +#define open_transformer(src_fd, transformer, transform_prog, ...) open_transformer(src_fd, transform_prog, __VA_ARGS__)
280 +#endif
282 #endif