Line 0
Link Here
|
|
|
1 |
diff -urp build/pack.c.orig build/pack.c |
2 |
--- build/pack.c.orig 2008-01-29 14:57:33.000000000 +0100 |
3 |
+++ build/pack.c 2009-06-08 10:54:15.000000000 +0200 |
4 |
@@ -672,6 +672,13 @@ rpmRC writeRPM(Header *hdrp, unsigned ch |
5 |
he->c = 1; |
6 |
xx = headerPut(h, he, 0); |
7 |
(void) rpmlibNeedsFeature(h, "PayloadIsLzma", "4.4.6-1"); |
8 |
+ } else if (s[1] == 'x' && s[2] == 'z') { |
9 |
+ he->tag = RPMTAG_PAYLOADCOMPRESSOR; |
10 |
+ he->t = RPM_STRING_TYPE; |
11 |
+ he->p.str = "xz"; |
12 |
+ he->c = 1; |
13 |
+ xx = headerPut(h, he, 0); |
14 |
+ (void) rpmlibNeedsFeature(h, "PayloadIsXz", "5.2-1"); |
15 |
} |
16 |
strcpy(buf, rpmio_flags); |
17 |
buf[s - rpmio_flags] = '\0'; |
18 |
diff -urp build/parsePrep.c.orig build/parsePrep.c |
19 |
--- build/parsePrep.c.orig 2007-12-31 17:21:47.000000000 +0100 |
20 |
+++ build/parsePrep.c 2009-04-06 08:38:11.000000000 +0200 |
21 |
@@ -159,6 +159,9 @@ static char *doPatch(Spec spec, int c, i |
22 |
case COMPRESSED_LZMA: |
23 |
zipper = "%{__lzma}"; |
24 |
break; |
25 |
+ case COMPRESSED_XZ: |
26 |
+ zipper = "%{__xz}"; |
27 |
+ break; |
28 |
} |
29 |
zipper = rpmGetPath(zipper, NULL); |
30 |
|
31 |
@@ -289,6 +292,9 @@ _rpmmg_debug = 0; |
32 |
case COMPRESSED_LZMA: |
33 |
t = "%{__lzma} -dc"; |
34 |
break; |
35 |
+ case COMPRESSED_XZ: |
36 |
+ t = "%{__xz} -dc"; |
37 |
+ break; |
38 |
case COMPRESSED_ZIP: |
39 |
if (rpmIsVerbose() && !quietly) |
40 |
t = "%{__unzip}"; |
41 |
diff -urp configure.ac.orig configure.ac |
42 |
--- configure.ac.orig 2008-03-03 09:41:37.000000000 +0100 |
43 |
+++ configure.ac 2009-07-29 10:21:26.000000000 +0200 |
44 |
@@ -469,6 +469,7 @@ AC_PATH_PROG(__TCLSH, tclsh, %{_bindir}/ |
45 |
AC_PATH_PROG(__UNZIP, unzip, %{_bindir}/unzip, $MYPATH) |
46 |
AC_PATH_PROG(__WGET, wget, %{_bindir}/wget, $MYPATH) |
47 |
AC_PATH_PROG(__XAR, xar, %{_bindir}/xar, $MYPATH) |
48 |
+AC_PATH_PROG(__XZ, xz, %{_bindir}/xz, $MYPATH) |
49 |
AC_PATH_PROG(__LD, ld, %{_bindir}/ld, $MYPATH) |
50 |
AC_PATH_PROG(__NM, nm, %{_bindir}/nm, $MYPATH) |
51 |
AC_PATH_PROG(__OBJCOPY, objcopy, %{_bindir}/objcopy, $MYPATH) |
52 |
@@ -927,6 +928,13 @@ RPM_CHECK_LIB( |
53 |
[no,external:none], [], |
54 |
[], []) |
55 |
|
56 |
+dnl # LZMA Utils |
57 |
+RPM_CHECK_LIB( |
58 |
+ [XZ libLZMA], [xz], |
59 |
+ [lzma], [lzma_auto_decoder], [lzma.h], |
60 |
+ [no,external:none], [], |
61 |
+ [], []) |
62 |
+ |
63 |
dnl # BeeCrypt |
64 |
RPM_CHECK_LIB( |
65 |
[BeeCrypt], [beecrypt], |
66 |
diff -urp lib/psm.c.orig lib/psm.c |
67 |
--- lib/psm.c.orig 2008-02-05 21:23:53.000000000 +0100 |
68 |
+++ lib/psm.c 2009-04-06 08:38:13.000000000 +0200 |
69 |
@@ -2408,6 +2408,8 @@ psm->te->h = headerFree(psm->te->h); |
70 |
t = stpcpy(t, ".bzdio"); |
71 |
if (!strcmp(payload_compressor, "lzma")) |
72 |
t = stpcpy(t, ".lzdio"); |
73 |
+ if (!strcmp(payload_compressor, "xz")) |
74 |
+ t = stpcpy(t, ".xzdio"); |
75 |
payload_compressor = _free(payload_compressor); |
76 |
|
77 |
he->tag = RPMTAG_PAYLOADFORMAT; |
78 |
diff -urp lib/rpmds.c.orig lib/rpmds.c |
79 |
--- lib/rpmds.c.orig 2007-12-15 12:17:03.000000000 +0100 |
80 |
+++ lib/rpmds.c 2009-04-06 08:38:13.000000000 +0200 |
81 |
@@ -1391,6 +1391,11 @@ static struct rpmlibProvides_s rpmlibPro |
82 |
{ "rpmlib(FileDigestParameterized)", "4.4.6-1", |
83 |
(RPMSENSE_RPMLIB|RPMSENSE_EQUAL), |
84 |
N_("file digests can be other than MD5.") }, |
85 |
+#if defined(HAVE_LZMA_H) |
86 |
+ { "rpmlib(PayloadIsXz)", "5.2-1", |
87 |
+ (RPMSENSE_RPMLIB|RPMSENSE_EQUAL), |
88 |
+ N_("package payload can be compressed using xz.") }, |
89 |
+#endif |
90 |
{ NULL, NULL, 0, NULL } |
91 |
}; |
92 |
|
93 |
diff -urp macros.in.orig macros.in |
94 |
--- macros.in.orig 2008-03-03 09:41:19.000000000 +0100 |
95 |
+++ macros.in 2009-07-29 10:13:06.000000000 +0200 |
96 |
@@ -93,6 +93,7 @@ |
97 |
%__vcheck %{__perl} %{_rpmhome}/vcheck |
98 |
%__wget @__WGET@ |
99 |
%__xar @__XAR@ |
100 |
+%__xz @__XZ@ |
101 |
|
102 |
#============================================================================== |
103 |
# ---- Build system path macros. |
104 |
diff -urp rpmio/macro.c.orig rpmio/macro.c |
105 |
--- rpmio/macro.c.orig 2008-02-05 21:23:56.000000000 +0100 |
106 |
+++ rpmio/macro.c 2009-04-13 09:20:07.000000000 +0200 |
107 |
@@ -1314,6 +1314,9 @@ doFoo(MacroBuf mb, int negate, const cha |
108 |
case 5: /* COMPRESSED_LZMA */ |
109 |
sprintf(be, "%%__lzma -dc '%s'", b); |
110 |
break; |
111 |
+ case 6: /* COMPRESSED_XZ */ |
112 |
+ sprintf(be, "%%__xz -dc '%s'", b); |
113 |
+ break; |
114 |
} |
115 |
b = be; |
116 |
} else if (STREQ("mkstemp", f, fn)) { |
117 |
@@ -2414,6 +2417,10 @@ int isCompressed(const char * file, rpmC |
118 |
magic[11] == (unsigned char) 0x00 && magic[12] == (unsigned char) 0x00) /* lzmash */ |
119 |
*compressed = COMPRESSED_LZMA; |
120 |
else |
121 |
+ if (magic[0] == (unsigned char) 0xFD && magic[1] == 0x37 && magic[2] == 0x7A |
122 |
+ && magic[3] == 0x58 && magic[4] == 0x5A && magic[5] == 0x00) /* xz */ |
123 |
+ *compressed = COMPRESSED_XZ; |
124 |
+ else |
125 |
if ((magic[0] == (unsigned char) 0037 && magic[1] == (unsigned char) 0213) /* gzip */ |
126 |
|| (magic[0] == (unsigned char) 0037 && magic[1] == (unsigned char) 0236) /* old gzip */ |
127 |
|| (magic[0] == (unsigned char) 0037 && magic[1] == (unsigned char) 0036) /* pack */ |
128 |
diff -urp rpmio/rpmio.c.orig rpmio/rpmio.c |
129 |
--- rpmio/rpmio.c.orig 2008-01-29 14:57:50.000000000 +0100 |
130 |
+++ rpmio/rpmio.c 2009-07-29 11:57:14.000000000 +0200 |
131 |
@@ -216,6 +216,10 @@ static /*@observer@*/ const char * fdbg( |
132 |
#endif |
133 |
} else if (fps->io == lzdio) { |
134 |
sprintf(be, "LZD %p fdno %d", fps->fp, fps->fdno); |
135 |
+#if defined(HAVE_LZMA_H) |
136 |
+ } else if (fps->io == xzdio) { |
137 |
+ sprintf(be, "XZD %p fdno %d", fps->fp, fps->fdno); |
138 |
+#endif |
139 |
} else if (fps->io == fpio) { |
140 |
/*@+voidabstract@*/ |
141 |
sprintf(be, "%s %p(%d) fdno %d", |
142 |
@@ -3079,6 +3083,422 @@ static struct FDIO_s lzdio_s = { |
143 |
FDIO_t lzdio = /*@-compmempass@*/ &lzdio_s /*@=compmempass@*/ ; |
144 |
|
145 |
/* =============================================================== */ |
146 |
+/* Support for LZMA compression library. |
147 |
+ */ |
148 |
+#if defined(HAVE_LZMA_H) |
149 |
+ |
150 |
+/* provide necessary defines for inclusion of <lzma.h> |
151 |
+ similar to LZMAUtils's internal <common.h> and as |
152 |
+ explicitly stated in the top-level comment of <lzma.h> */ |
153 |
+#ifndef UINT32_C |
154 |
+# define UINT32_C(n) n ## U |
155 |
+#endif |
156 |
+#ifndef UINT32_MAX |
157 |
+# define UINT32_MAX UINT32_C(4294967295) |
158 |
+#endif |
159 |
+#if SIZEOF_UNSIGNED_LONG == 4 |
160 |
+# ifndef UINT64_C |
161 |
+# define UINT64_C(n) n ## ULL |
162 |
+# endif |
163 |
+#else |
164 |
+# ifndef UINT64_C |
165 |
+# define UINT64_C(n) n ## UL |
166 |
+# endif |
167 |
+#endif |
168 |
+#ifndef UINT64_MAX |
169 |
+# define UINT64_MAX UINT64_C(18446744073709551615) |
170 |
+#endif |
171 |
+ |
172 |
+#include "lzma.h" |
173 |
+ |
174 |
+#ifndef LZMA_PRESET_DEFAULT |
175 |
+#define LZMA_PRESET_DEFAULT UINT32_C(6) |
176 |
+#endif |
177 |
+ |
178 |
+/*@access FD_t @*/ |
179 |
+ |
180 |
+#define XZDONLY(fd) assert(fdGetIo(fd) == xzdio) |
181 |
+ |
182 |
+#define kBufferSize (1 << 15) |
183 |
+ |
184 |
+typedef struct xzfile { |
185 |
+/*@only@*/ |
186 |
+ uint8_t buf[kBufferSize]; /*!< IO buffer */ |
187 |
+ lzma_stream strm; /*!< LZMA stream */ |
188 |
+/*@dependent@*/ |
189 |
+ FILE * fp; |
190 |
+ int encoding; |
191 |
+ int eof; |
192 |
+} XZFILE; |
193 |
+ |
194 |
+/*@-globstate@*/ |
195 |
+/*@null@*/ |
196 |
+static XZFILE *xzopen_internal(const char *path, const char *mode, int fdno, int xz) |
197 |
+ /*@globals fileSystem @*/ |
198 |
+ /*@modifies fileSystem @*/ |
199 |
+{ |
200 |
+ int level = LZMA_PRESET_DEFAULT; |
201 |
+ int encoding = 0; |
202 |
+ FILE *fp; |
203 |
+ XZFILE *xzfile; |
204 |
+ lzma_stream tmp; |
205 |
+ lzma_ret ret; |
206 |
+ |
207 |
+ for (; *mode != '\0'; mode++) { |
208 |
+ if (*mode == 'w') |
209 |
+ encoding = 1; |
210 |
+ else if (*mode == 'r') |
211 |
+ encoding = 0; |
212 |
+ else if (*mode >= '0' && *mode <= '9') |
213 |
+ level = (int)(*mode - '0'); |
214 |
+ } |
215 |
+ if (fdno != -1) |
216 |
+ fp = fdopen(fdno, encoding ? "w" : "r"); |
217 |
+ else |
218 |
+ fp = fopen(path, encoding ? "w" : "r"); |
219 |
+ if (!fp) |
220 |
+ return NULL; |
221 |
+ xzfile = calloc(1, sizeof(*xzfile)); |
222 |
+ if (!xzfile) { |
223 |
+ (void) fclose(fp); |
224 |
+ return NULL; |
225 |
+ } |
226 |
+ xzfile->fp = fp; |
227 |
+ xzfile->encoding = encoding; |
228 |
+ xzfile->eof = 0; |
229 |
+ tmp = (lzma_stream)LZMA_STREAM_INIT; |
230 |
+ xzfile->strm = tmp; |
231 |
+ if (encoding) { |
232 |
+ if (xz) { |
233 |
+ ret = lzma_easy_encoder(&xzfile->strm, level, LZMA_CHECK_CRC32); |
234 |
+ } else { |
235 |
+ lzma_options_lzma options; |
236 |
+ (void) lzma_lzma_preset(&options, level); |
237 |
+ ret = lzma_alone_encoder(&xzfile->strm, &options); |
238 |
+ } |
239 |
+ } else { |
240 |
+ /* We set the memlimit for decompression to 100MiB which should be |
241 |
+ * more than enough to be sufficient for level 9 which requires 65 MiB. |
242 |
+ */ |
243 |
+ ret = lzma_auto_decoder(&xzfile->strm, 100<<20, 0); |
244 |
+ } |
245 |
+ if (ret != LZMA_OK) { |
246 |
+ (void) fclose(fp); |
247 |
+ memset(xzfile, 0, sizeof(*xzfile)); |
248 |
+ free(xzfile); |
249 |
+ return NULL; |
250 |
+ } |
251 |
+ return xzfile; |
252 |
+} |
253 |
+/*@=globstate@*/ |
254 |
+ |
255 |
+/*@null@*/ |
256 |
+static XZFILE *xzopen(const char *path, const char *mode) |
257 |
+ /*@globals fileSystem @*/ |
258 |
+ /*@modifies fileSystem @*/ |
259 |
+{ |
260 |
+ return xzopen_internal(path, mode, -1, 1); |
261 |
+} |
262 |
+ |
263 |
+/*@null@*/ |
264 |
+static XZFILE *xzdopen(int fdno, const char *mode) |
265 |
+ /*@globals fileSystem @*/ |
266 |
+ /*@modifies fileSystem @*/ |
267 |
+{ |
268 |
+ if (fdno < 0) |
269 |
+ return NULL; |
270 |
+ return xzopen_internal(0, mode, fdno, 1); |
271 |
+} |
272 |
+ |
273 |
+static int xzflush(XZFILE *xzfile) |
274 |
+ /*@globals fileSystem @*/ |
275 |
+ /*@modifies xzfile, fileSystem @*/ |
276 |
+{ |
277 |
+ return fflush(xzfile->fp); |
278 |
+} |
279 |
+ |
280 |
+static int xzclose(/*@only@*/ XZFILE *xzfile) |
281 |
+ /*@globals fileSystem @*/ |
282 |
+ /*@modifies *xzfile, fileSystem @*/ |
283 |
+{ |
284 |
+ lzma_ret ret; |
285 |
+ size_t n; |
286 |
+ int rc; |
287 |
+ |
288 |
+ if (!xzfile) |
289 |
+ return -1; |
290 |
+ if (xzfile->encoding) { |
291 |
+ for (;;) { |
292 |
+ xzfile->strm.avail_out = kBufferSize; |
293 |
+ xzfile->strm.next_out = (uint8_t *)xzfile->buf; |
294 |
+ ret = lzma_code(&xzfile->strm, LZMA_FINISH); |
295 |
+ if (ret != LZMA_OK && ret != LZMA_STREAM_END) |
296 |
+ return -1; |
297 |
+ n = kBufferSize - xzfile->strm.avail_out; |
298 |
+ if (n && fwrite(xzfile->buf, 1, n, xzfile->fp) != n) |
299 |
+ return -1; |
300 |
+ if (ret == LZMA_STREAM_END) |
301 |
+ break; |
302 |
+ } |
303 |
+ } |
304 |
+ lzma_end(&xzfile->strm); |
305 |
+ rc = fclose(xzfile->fp); |
306 |
+ memset(xzfile, 0, sizeof(*xzfile)); |
307 |
+ free(xzfile); |
308 |
+ return rc; |
309 |
+} |
310 |
+ |
311 |
+/*@-mustmod@*/ |
312 |
+static ssize_t xzread(XZFILE *xzfile, void *buf, size_t len) |
313 |
+ /*@globals fileSystem @*/ |
314 |
+ /*@modifies xzfile, *buf, fileSystem @*/ |
315 |
+{ |
316 |
+ lzma_ret ret; |
317 |
+ int eof = 0; |
318 |
+ |
319 |
+ if (!xzfile || xzfile->encoding) |
320 |
+ return -1; |
321 |
+ if (xzfile->eof) |
322 |
+ return 0; |
323 |
+/*@-temptrans@*/ |
324 |
+ xzfile->strm.next_out = buf; |
325 |
+/*@=temptrans@*/ |
326 |
+ xzfile->strm.avail_out = len; |
327 |
+ for (;;) { |
328 |
+ if (!xzfile->strm.avail_in) { |
329 |
+ xzfile->strm.next_in = (uint8_t *)xzfile->buf; |
330 |
+ xzfile->strm.avail_in = fread(xzfile->buf, 1, kBufferSize, xzfile->fp); |
331 |
+ if (!xzfile->strm.avail_in) |
332 |
+ eof = 1; |
333 |
+ } |
334 |
+ ret = lzma_code(&xzfile->strm, LZMA_RUN); |
335 |
+ if (ret == LZMA_STREAM_END) { |
336 |
+ xzfile->eof = 1; |
337 |
+ return len - xzfile->strm.avail_out; |
338 |
+ } |
339 |
+ if (ret != LZMA_OK) |
340 |
+ return -1; |
341 |
+ if (!xzfile->strm.avail_out) |
342 |
+ return len; |
343 |
+ if (eof) |
344 |
+ return -1; |
345 |
+ } |
346 |
+ /*@notreached@*/ |
347 |
+} |
348 |
+/*@=mustmod@*/ |
349 |
+ |
350 |
+static ssize_t xzwrite(XZFILE *xzfile, void *buf, size_t len) |
351 |
+ /*@globals fileSystem @*/ |
352 |
+ /*@modifies xzfile, fileSystem @*/ |
353 |
+{ |
354 |
+ lzma_ret ret; |
355 |
+ size_t n; |
356 |
+ |
357 |
+ if (!xzfile || !xzfile->encoding) |
358 |
+ return -1; |
359 |
+ if (!len) |
360 |
+ return 0; |
361 |
+/*@-temptrans@*/ |
362 |
+ xzfile->strm.next_in = buf; |
363 |
+/*@=temptrans@*/ |
364 |
+ xzfile->strm.avail_in = len; |
365 |
+ for (;;) { |
366 |
+ xzfile->strm.next_out = (uint8_t *)xzfile->buf; |
367 |
+ xzfile->strm.avail_out = kBufferSize; |
368 |
+ ret = lzma_code(&xzfile->strm, LZMA_RUN); |
369 |
+ if (ret != LZMA_OK) |
370 |
+ return -1; |
371 |
+ n = kBufferSize - xzfile->strm.avail_out; |
372 |
+ if (n && fwrite(xzfile->buf, 1, n, xzfile->fp) != n) |
373 |
+ return -1; |
374 |
+ if (!xzfile->strm.avail_in) |
375 |
+ return len; |
376 |
+ } |
377 |
+ /*@notreached@*/ |
378 |
+} |
379 |
+ |
380 |
+/* =============================================================== */ |
381 |
+ |
382 |
+static inline /*@dependent@*/ /*@null@*/ void * xzdFileno(FD_t fd) |
383 |
+ /*@*/ |
384 |
+{ |
385 |
+ void * rc = NULL; |
386 |
+ int i; |
387 |
+ |
388 |
+ FDSANE(fd); |
389 |
+ for (i = fd->nfps; i >= 0; i--) { |
390 |
+/*@-boundsread@*/ |
391 |
+ FDSTACK_t * fps = &fd->fps[i]; |
392 |
+/*@=boundsread@*/ |
393 |
+ if (fps->io != xzdio && fps->io != lzdio) |
394 |
+ continue; |
395 |
+ rc = fps->fp; |
396 |
+ break; |
397 |
+ } |
398 |
+ |
399 |
+ return rc; |
400 |
+} |
401 |
+ |
402 |
+/*@-globuse@*/ |
403 |
+static /*@null@*/ FD_t xzdOpen(const char * path, const char * fmode) |
404 |
+ /*@globals fileSystem @*/ |
405 |
+ /*@modifies fileSystem @*/ |
406 |
+{ |
407 |
+ FD_t fd; |
408 |
+ mode_t mode = (fmode && fmode[0] == 'w' ? O_WRONLY : O_RDONLY); |
409 |
+ XZFILE * xzfile = xzopen(path, fmode); |
410 |
+ |
411 |
+ if (xzfile == NULL) |
412 |
+ return NULL; |
413 |
+ fd = fdNew("open (xzdOpen)"); |
414 |
+ fdPop(fd); fdPush(fd, xzdio, xzfile, -1); |
415 |
+ fdSetOpen(fd, path, fileno(xzfile->fp), mode); |
416 |
+ return fdLink(fd, "xzdOpen"); |
417 |
+} |
418 |
+/*@=globuse@*/ |
419 |
+ |
420 |
+/*@-globuse@*/ |
421 |
+static /*@null@*/ FD_t xzdFdopen(void * cookie, const char * fmode) |
422 |
+ /*@globals fileSystem, internalState @*/ |
423 |
+ /*@modifies fileSystem, internalState @*/ |
424 |
+{ |
425 |
+ FD_t fd = c2f(cookie); |
426 |
+ int fdno = fdFileno(fd); |
427 |
+ XZFILE *xzfile; |
428 |
+ |
429 |
+assert(fmode != NULL); |
430 |
+ fdSetFdno(fd, -1); /* XXX skip the fdio close */ |
431 |
+ if (fdno < 0) return NULL; |
432 |
+ xzfile = xzdopen(fdno, fmode); |
433 |
+ if (xzfile == NULL) return NULL; |
434 |
+ fdPush(fd, xzdio, xzfile, fdno); |
435 |
+ return fdLink(fd, "xzdFdopen"); |
436 |
+} |
437 |
+/*@=globuse@*/ |
438 |
+ |
439 |
+/*@-globuse@*/ |
440 |
+static int xzdFlush(void * cookie) |
441 |
+ /*@globals fileSystem @*/ |
442 |
+ /*@modifies fileSystem @*/ |
443 |
+{ |
444 |
+ FD_t fd = c2f(cookie); |
445 |
+ return xzflush(xzdFileno(fd)); |
446 |
+} |
447 |
+/*@=globuse@*/ |
448 |
+ |
449 |
+/* =============================================================== */ |
450 |
+/*@-globuse@*/ |
451 |
+/*@-mustmod@*/ /* LCL: *buf is modified */ |
452 |
+static ssize_t xzdRead(void * cookie, /*@out@*/ char * buf, size_t count) |
453 |
+ /*@globals fileSystem, internalState @*/ |
454 |
+ /*@modifies *buf, fileSystem, internalState @*/ |
455 |
+{ |
456 |
+ FD_t fd = c2f(cookie); |
457 |
+ XZFILE *xzfile; |
458 |
+ ssize_t rc = -1; |
459 |
+ |
460 |
+assert(fd != NULL); |
461 |
+ if (fd->bytesRemain == 0) return 0; /* XXX simulate EOF */ |
462 |
+ xzfile = xzdFileno(fd); |
463 |
+assert(xzfile != NULL); |
464 |
+ fdstat_enter(fd, FDSTAT_READ); |
465 |
+/*@-compdef@*/ |
466 |
+ rc = xzread(xzfile, buf, count); |
467 |
+/*@=compdef@*/ |
468 |
+DBGIO(fd, (stderr, "==>\txzdRead(%p,%p,%u) rc %lx %s\n", cookie, buf, (unsigned)count, (unsigned long)rc, fdbg(fd))); |
469 |
+ if (rc == -1) { |
470 |
+ fd->errcookie = "Lzma: decoding error"; |
471 |
+ } else if (rc >= 0) { |
472 |
+ fdstat_exit(fd, FDSTAT_READ, rc); |
473 |
+ /*@-compdef@*/ |
474 |
+ if (fd->ndigests && rc > 0) fdUpdateDigests(fd, (void *)buf, rc); |
475 |
+ /*@=compdef@*/ |
476 |
+ } |
477 |
+ return rc; |
478 |
+} |
479 |
+/*@=mustmod@*/ |
480 |
+/*@=globuse@*/ |
481 |
+ |
482 |
+/*@-globuse@*/ |
483 |
+static ssize_t xzdWrite(void * cookie, const char * buf, size_t count) |
484 |
+ /*@globals fileSystem, internalState @*/ |
485 |
+ /*@modifies fileSystem, internalState @*/ |
486 |
+{ |
487 |
+ FD_t fd = c2f(cookie); |
488 |
+ XZFILE *xzfile; |
489 |
+ ssize_t rc = 0; |
490 |
+ |
491 |
+ if (fd == NULL || fd->bytesRemain == 0) return 0; /* XXX simulate EOF */ |
492 |
+ |
493 |
+ if (fd->ndigests && count > 0) fdUpdateDigests(fd, (void *)buf, count); |
494 |
+ |
495 |
+ xzfile = xzdFileno(fd); |
496 |
+ |
497 |
+ fdstat_enter(fd, FDSTAT_WRITE); |
498 |
+ rc = xzwrite(xzfile, (void *)buf, count); |
499 |
+DBGIO(fd, (stderr, "==>\txzdWrite(%p,%p,%u) rc %lx %s\n", cookie, buf, (unsigned)count, (unsigned long)rc, fdbg(fd))); |
500 |
+ if (rc < 0) { |
501 |
+ fd->errcookie = "Lzma: encoding error"; |
502 |
+ } else if (rc > 0) { |
503 |
+ fdstat_exit(fd, FDSTAT_WRITE, rc); |
504 |
+ } |
505 |
+ return rc; |
506 |
+} |
507 |
+ |
508 |
+static inline int xzdSeek(void * cookie, /*@unused@*/ _libio_pos_t pos, |
509 |
+ /*@unused@*/ int whence) |
510 |
+ /*@*/ |
511 |
+{ |
512 |
+ FD_t fd = c2f(cookie); |
513 |
+ |
514 |
+ XZDONLY(fd); |
515 |
+ return -2; |
516 |
+} |
517 |
+ |
518 |
+static int xzdClose( /*@only@*/ void * cookie) |
519 |
+ /*@globals fileSystem, internalState @*/ |
520 |
+ /*@modifies fileSystem, internalState @*/ |
521 |
+{ |
522 |
+ FD_t fd = c2f(cookie); |
523 |
+ XZFILE *xzfile; |
524 |
+ const char * errcookie; |
525 |
+ int rc; |
526 |
+ |
527 |
+ xzfile = xzdFileno(fd); |
528 |
+ |
529 |
+ if (xzfile == NULL) return -2; |
530 |
+ errcookie = strerror(ferror(xzfile->fp)); |
531 |
+ |
532 |
+ fdstat_enter(fd, FDSTAT_CLOSE); |
533 |
+ /*@-dependenttrans@*/ |
534 |
+ rc = xzclose(xzfile); |
535 |
+ /*@=dependenttrans@*/ |
536 |
+ fdstat_exit(fd, FDSTAT_CLOSE, rc); |
537 |
+ |
538 |
+ if (fd && rc == -1) |
539 |
+ fd->errcookie = errcookie; |
540 |
+ |
541 |
+DBGIO(fd, (stderr, "==>\txzdClose(%p) rc %lx %s\n", cookie, (unsigned long)rc, fdbg(fd))); |
542 |
+ |
543 |
+ if (_rpmio_debug || rpmIsDebug()) fdstat_print(fd, "XZDIO", stderr); |
544 |
+ /*@-branchstate@*/ |
545 |
+ if (rc == 0) |
546 |
+ fd = fdFree(fd, "open (xzdClose)"); |
547 |
+ /*@=branchstate@*/ |
548 |
+ return rc; |
549 |
+} |
550 |
+ |
551 |
+/*@-type@*/ /* LCL: function typedefs */ |
552 |
+static struct FDIO_s xzdio_s = { |
553 |
+ xzdRead, xzdWrite, xzdSeek, xzdClose, xzdOpen, xzdFdopen, xzdFlush, |
554 |
+}; |
555 |
+/*@=type@*/ |
556 |
+ |
557 |
+FDIO_t xzdio = /*@-compmempass@*/ &xzdio_s /*@=compmempass@*/ ; |
558 |
+ |
559 |
+#endif /* HAVE_LZMA_H */ |
560 |
+ |
561 |
+/* =============================================================== */ |
562 |
/*@observer@*/ |
563 |
static const char * getFdErrstr (FD_t fd) |
564 |
/*@*/ |
565 |
@@ -3099,6 +3519,11 @@ static const char * getFdErrstr (FD_t fd |
566 |
if (fdGetIo(fd) == lzdio) { |
567 |
errstr = fd->errcookie; |
568 |
} else |
569 |
+#ifdef HAVE_LZMA_H |
570 |
+ if (fdGetIo(fd) == xzdio) { |
571 |
+ errstr = fd->errcookie; |
572 |
+ } else |
573 |
+#endif |
574 |
{ |
575 |
errstr = (fd->syserrno ? strerror(fd->syserrno) : ""); |
576 |
} |
577 |
@@ -3416,6 +3841,11 @@ fprintf(stderr, "*** Fdopen(%p,%s) %s\n" |
578 |
} else if (!strcmp(end, "lzdio")) { |
579 |
iof = lzdio; |
580 |
fd = lzdFdopen(fd, zstdio); |
581 |
+#if defined(HAVE_LZMA_H) |
582 |
+ } else if (!strcmp(end, "xzdio")) { |
583 |
+ iof = xzdio; |
584 |
+ fd = xzdFdopen(fd, zstdio); |
585 |
+#endif |
586 |
} else if (!strcmp(end, "ufdio")) { |
587 |
iof = ufdio; |
588 |
} else if (!strcmp(end, "fpio")) { |
589 |
@@ -3568,6 +3998,10 @@ int Fflush(FD_t fd) |
590 |
if (vh && fdGetIo(fd) == bzdio) |
591 |
return bzdFlush(vh); |
592 |
#endif |
593 |
+#if defined(HAVE_LZMA_H) |
594 |
+ if (vh && fdGetIo(fd) == xzdio) |
595 |
+ return xzdFlush(vh); |
596 |
+#endif |
597 |
|
598 |
return 0; |
599 |
} |
600 |
@@ -3602,6 +4036,11 @@ int Ferror(FD_t fd) |
601 |
} else if (fps->io == lzdio) { |
602 |
ec = (fd->syserrno || fd->errcookie != NULL) ? -1 : 0; |
603 |
i--; /* XXX fdio under lzdio always has fdno == -1 */ |
604 |
+#if defined(HAVE_LZMA_H) |
605 |
+ } else if (fps->io == xzdio) { |
606 |
+ ec = (fd->syserrno || fd->errcookie != NULL) ? -1 : 0; |
607 |
+ i--; /* XXX fdio under xzdio always has fdno == -1 */ |
608 |
+#endif |
609 |
} else { |
610 |
/* XXX need to check ufdio/gzdio/bzdio/fdio errors correctly. */ |
611 |
ec = (fdFileno(fd) < 0 ? -1 : 0); |
612 |
diff -urp rpmio/rpmio.h.orig rpmio/rpmio.h |
613 |
--- rpmio/rpmio.h.orig 2007-12-09 14:04:30.000000000 +0100 |
614 |
+++ rpmio/rpmio.h 2009-04-06 08:38:33.000000000 +0200 |
615 |
@@ -793,6 +793,10 @@ int ufdGetFile( /*@killref@*/ FD_t sfd, |
616 |
|
617 |
/** |
618 |
*/ |
619 |
+/*@observer@*/ /*@unchecked@*/ extern FDIO_t xzdio; |
620 |
+ |
621 |
+/** |
622 |
+ */ |
623 |
/*@observer@*/ /*@unchecked@*/ extern FDIO_t fadio; |
624 |
/*@=exportlocal@*/ |
625 |
/*@}*/ |
626 |
diff -urp rpmio/rpmmacro.h.orig rpmio/rpmmacro.h |
627 |
--- rpmio/rpmmacro.h.orig 2008-01-29 14:57:50.000000000 +0100 |
628 |
+++ rpmio/rpmmacro.h 2009-04-06 08:38:33.000000000 +0200 |
629 |
@@ -208,7 +208,8 @@ typedef enum rpmCompressedMagic_e { |
630 |
COMPRESSED_BZIP2 = 2, /*!< bzip2 can handle */ |
631 |
COMPRESSED_ZIP = 3, /*!< unzip can handle */ |
632 |
COMPRESSED_LZOP = 4, /*!< lzop can handle */ |
633 |
- COMPRESSED_LZMA = 5 /*!< lzma can handle */ |
634 |
+ COMPRESSED_LZMA = 5, /*!< lzma can handle */ |
635 |
+ COMPRESSED_XZ = 6 /*!< xz can handle */ |
636 |
} rpmCompressedMagic; |
637 |
|
638 |
/** |
639 |
diff -urp tools/rpm2cpio.c.orig tools/rpm2cpio.c |
640 |
--- tools/rpm2cpio.c.orig 2007-12-09 14:04:30.000000000 +0100 |
641 |
+++ tools/rpm2cpio.c 2009-04-06 08:38:33.000000000 +0200 |
642 |
@@ -89,6 +89,8 @@ int main(int argc, char **argv) |
643 |
t = stpcpy(t, ".bzdio"); |
644 |
if (!strcmp(payload_compressor, "lzma")) |
645 |
t = stpcpy(t, ".lzdio"); |
646 |
+ if (!strcmp(payload_compressor, "xz")) |
647 |
+ t = stpcpy(t, ".xzdio"); |
648 |
he->p.ptr = _free(he->p.ptr); |
649 |
} |
650 |
|