A new user interface for you! Read more...

File rpm-lzmaalpha-xz.diff of Package rpm.SLE_11

--- ./build/pack.c.orig	2011-06-15 15:41:24.000000000 +0000
+++ ./build/pack.c	2011-06-15 15:46:42.000000000 +0000
@@ -482,7 +482,12 @@ int writeRPM(Header *hdrp, unsigned char
 	if (s[1] == 'l' && s[2] == 'z') {
 	    (void) headerAddEntry(h, RPMTAG_PAYLOADCOMPRESSOR, RPM_STRING_TYPE,
 		"lzma", 1);
-	    (void) rpmlibNeedsFeature(h, "PayloadIsLzma", "4.4.2-1");
+	    (void) rpmlibNeedsFeature(h, "PayloadIsLzma", "4.4.6-1");
+	}
+	if (s[1] == 'x' && s[2] == 'z') {
+	    (void) headerAddEntry(h, RPMTAG_PAYLOADCOMPRESSOR, RPM_STRING_TYPE,
+		"xz", 1);
+	    (void) rpmlibNeedsFeature(h, "PayloadIsXz", "5.2-1");
 	}
 	strcpy(buf, rpmio_flags);
 	buf[s - rpmio_flags] = '\0';
--- ./build/parsePrep.c.orig	2011-06-15 15:55:46.000000000 +0000
+++ ./build/parsePrep.c	2011-06-15 15:56:17.000000000 +0000
@@ -258,6 +258,9 @@ static char *doPatch(Spec spec, int c, i
 	case COMPRESSED_LZMA:
 	    t = "%{__lzma} -dc";
 	    break;
+	case COMPRESSED_XZ:
+	    t = "%{__xz} -dc";
+	    break;
 	}
 	zipper = rpmGetPath(t, NULL);
 	buf[0] = '\0';
--- ./lib/psm.c.orig	2011-06-15 15:40:08.000000000 +0000
+++ ./lib/psm.c	2011-06-15 15:40:43.000000000 +0000
@@ -2105,7 +2105,9 @@ psm->te->h = headerFree(psm->te->h);
 	if (!strcmp(payload_compressor, "bzip2"))
 	    t = stpcpy(t, ".bzdio");
 	if (!strcmp(payload_compressor, "lzma"))
-     		t = stpcpy(t, ".lzdio");
+	    t = stpcpy(t, ".lzdio");
+	if (!strcmp(payload_compressor, "xz"))
+	    t = stpcpy(t, ".xzdio");
 	rc = RPMRC_OK;
     }	break;
 
--- ./lib/rpmlibprov.c.orig	2011-06-15 15:38:51.000000000 +0000
+++ ./lib/rpmlibprov.c	2011-06-15 15:39:43.000000000 +0000
@@ -62,6 +62,9 @@ static struct rpmlibProvides_s rpmlibPro
     { "rpmlib(PayloadIsLzma)",         "4.4.2-1",
 	(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
      N_("package payload can be compressed using lzma.") },
+    { "rpmlib(PayloadIsXz)",		"5.2-1",
+	(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
+     N_("package payload can be compressed using xz.") },
     { NULL,				NULL, 0,	NULL }
 };
 
--- ./macros.in.orig	2011-06-15 15:52:48.000000000 +0000
+++ ./macros.in	2011-06-15 15:53:34.000000000 +0000
@@ -49,6 +49,7 @@
 %__install		@__INSTALL@
 %__ln_s			@LN_S@
 %__lzma			@__LZMA@
+%__xz			/usr/bin/xz
 %__make			@__MAKE@
 %__mkdir		@__MKDIR@
 %__mkdir_p		@MKDIR_P@
--- ./rpm2cpio.c.orig	2011-06-15 15:57:40.000000000 +0000
+++ ./rpm2cpio.c	2011-06-15 15:57:55.000000000 +0000
@@ -78,6 +78,8 @@ int main(int argc, char **argv)
 	    t = stpcpy(t, ".bzdio");
 	if (!strcmp(payload_compressor, "lzma"))
 	    t = stpcpy(t, ".lzdio");
+	if (!strcmp(payload_compressor, "xz"))
+	    t = stpcpy(t, ".xzdio");
     }
 
     gzdi = Fdopen(fdi, rpmio_flags);	/* XXX gzdi == fdi */
--- ./rpmio/Makefile.am.orig	2011-06-15 14:38:11.000000000 +0000
+++ ./rpmio/Makefile.am	2011-06-15 14:45:56.000000000 +0000
@@ -15,6 +15,7 @@ INCLUDES = -I. \
 	@WITH_LUA_INCLUDE@ \
 	@WITH_POPT_INCLUDE@ \
 	-I$(top_srcdir)/misc \
+	-I$(top_srcdir)/lzmaalpha-utils/src/liblzma/api \
 	@INCPATH@
 
 pkgincdir = $(pkgincludedir)
@@ -41,7 +42,7 @@ librpmio_la_LDFLAGS = -release 4.4 $(LDF
 	@WITH_MAGIC_LIB@ \
 	@WITH_ZLIB_LIB@ \
 	-lpthread
-librpmio_la_LIBADD = $(BEECRYPTLOBJS) -llzma
+librpmio_la_LIBADD = $(BEECRYPTLOBJS) $(top_srcdir)/lzmaalpha-utils/liblzmaalpha.a -llzma
 librpmio_la_DEPENDENCIES = .created
 
 .created:
--- ./rpmio/macro.c.orig	2011-06-15 15:51:14.000000000 +0000
+++ ./rpmio/macro.c	2011-06-15 15:52:25.000000000 +0000
@@ -1184,6 +1184,9 @@ doFoo(MacroBuf mb, int negate, const cha
         case COMPRESSED_LZMA:
             sprintf(be, "%%_lzma -dc %s", b);
             break;
+        case COMPRESSED_XZ:
+            sprintf(be, "%%_xz -dc %s", b);
+            break;
 	}
 	b = be;
     } else if (STREQ("S", f, fn)) {
@@ -2115,6 +2118,11 @@ int isCompressed(const char * file, rpmC
     } else if ((magic[0] == 0120) && (magic[1] == 0113) &&
 	 (magic[2] == 0003) && (magic[3] == 0004)) {	/* pkzip */
 	*compressed = COMPRESSED_ZIP;
+    } else if ((magic[0] == 0xfd) && (magic[1] == 0x37) &&
+               (magic[2] == 0x7a) && (magic[3] == 0x58) &&
+               (magic[4] == 0x5a) && (magic[5] == 0x00)) {
+        /* new style xz (lzma) with magic */
+        *compressed = COMPRESSED_XZ;
     } else if ((magic[0] == 0xff) && (magic[1] == 0x4c) &&
 	       (magic[2] == 0x5a) && (magic[3] == 0x4d) &&
 	       (magic[4] == 0x41) && (magic[5] == 0x00)) {
--- ./rpmio/rpmio.c.orig	2011-06-15 14:17:18.000000000 +0000
+++ ./rpmio/rpmio.c	2011-06-15 14:37:40.000000000 +0000
@@ -85,6 +85,7 @@ static int inet_aton(const char *cp, str
 #define	GZDONLY(fd)	assert(fdGetIo(fd) == gzdio)
 #define	BZDONLY(fd)	assert(fdGetIo(fd) == bzdio)
 #define	LZDONLY(fd)	assert(fdGetIo(fd) == lzdio)
+#define	XZDONLY(fd)	assert(fdGetIo(fd) == xzdio)
 
 #define	UFDONLY(fd)	/* assert(fdGetIo(fd) == ufdio) */
 
@@ -192,6 +193,8 @@ static /*@observer@*/ const char * fdbg(
 #endif
 	} else if (fps->io == lzdio) {
 	    sprintf(be, "LZD %p fdno %d", fps->fp, fps->fdno);
+	} else if (fps->io == xzdio) {
+	    sprintf(be, "XZD %p fdno %d", fps->fp, fps->fdno);
 	} else if (fps->io == fpio) {
 	    /*@+voidabstract@*/
 	    sprintf(be, "%s %p(%d) fdno %d",
@@ -2787,6 +2790,8 @@ FDIO_t bzdio = /*@-compmempass@*/ &bzdio
 
 #include <sys/types.h>
 #include <inttypes.h>
+
+#include <lzmaalpha.h>
 #include <lzma.h>
 
 #define kBufferSize (1 << 15)
@@ -2795,7 +2800,7 @@ typedef struct lzfile {
   /* IO buffer */
     uint8_t buf[kBufferSize];
 
-    lzma_stream strm;
+    lzmaalpha_stream strm;
 
     FILE *file;
 
@@ -2810,7 +2815,7 @@ static LZFILE *lzopen_internal(const cha
     int encoding = 0;
     FILE *fp;
     LZFILE *lzfile;
-    lzma_ret ret;
+    lzmaalpha_ret ret;
 
     for (; *mode; mode++) {
 	if (*mode == 'w')
@@ -2834,16 +2839,16 @@ static LZFILE *lzopen_internal(const cha
     lzfile->file = fp;
     lzfile->encoding = encoding;
     lzfile->eof = 0;
-    lzfile->strm = LZMA_STREAM_INIT_VAR;
+    lzfile->strm = LZMAALPHA_STREAM_INIT_VAR;
     if (encoding) {
-	lzma_options_alone alone;
-	alone.uncompressed_size = LZMA_VLI_VALUE_UNKNOWN;
-	memcpy(&alone.lzma, &lzma_preset_lzma[level - 1], sizeof(alone.lzma));
-	ret = lzma_alone_encoder(&lzfile->strm, &alone);
+	lzmaalpha_options_alone alone;
+	alone.uncompressed_size = LZMAALPHA_VLI_VALUE_UNKNOWN;
+	memcpy(&alone.lzma, &lzmaalpha_preset_lzma[level - 1], sizeof(alone.lzma));
+	ret = lzmaalpha_alone_encoder(&lzfile->strm, &alone);
     } else {
-	ret = lzma_auto_decoder(&lzfile->strm, 0, 0);
+	ret = lzmaalpha_auto_decoder(&lzfile->strm, 0, 0);
     }
-    if (ret != LZMA_OK) {
+    if (ret != LZMAALPHA_OK) {
 	fclose(fp);
 	free(lzfile);
 	return 0;
@@ -2870,8 +2875,9 @@ static int lzflush(LZFILE *lzfile)
 
 static int lzclose(LZFILE *lzfile)
 {
-    lzma_ret ret;
+    lzmaalpha_ret ret;
     int n;
+    int rc;
 
     if (!lzfile)
 	return -1;
@@ -2879,24 +2885,25 @@ static int lzclose(LZFILE *lzfile)
 	for (;;) {
 	    lzfile->strm.avail_out = kBufferSize;
 	    lzfile->strm.next_out = lzfile->buf;
-	    ret = lzma_code(&lzfile->strm, LZMA_FINISH);
-	    if (ret != LZMA_OK && ret != LZMA_STREAM_END)
+	    ret = lzmaalpha_code(&lzfile->strm, LZMAALPHA_FINISH);
+	    if (ret != LZMAALPHA_OK && ret != LZMAALPHA_STREAM_END)
 		return -1;
 	    n = kBufferSize - lzfile->strm.avail_out;
 	    if (n && fwrite(lzfile->buf, 1, n, lzfile->file) != n)
 		return -1;
-	    if (ret == LZMA_STREAM_END)
+	    if (ret == LZMAALPHA_STREAM_END)
 		break;
 	}
     }
-    lzma_end(&lzfile->strm);
-    return fclose(lzfile->file);
+    lzmaalpha_end(&lzfile->strm);
+    rc = fclose(lzfile->file);
     free(lzfile);
+    return rc;
 }
 
 static ssize_t lzread(LZFILE *lzfile, void *buf, size_t len)
 {
-    lzma_ret ret;
+    lzmaalpha_ret ret;
     int eof = 0;
 
     if (!lzfile || lzfile->encoding)
@@ -2912,12 +2919,12 @@ static ssize_t lzread(LZFILE *lzfile, vo
 	    if (!lzfile->strm.avail_in)
 		eof = 1;
 	}
-	ret = lzma_code(&lzfile->strm, LZMA_RUN);
-	if (ret == LZMA_STREAM_END) {
+	ret = lzmaalpha_code(&lzfile->strm, LZMAALPHA_RUN);
+	if (ret == LZMAALPHA_STREAM_END) {
 	    lzfile->eof = 1;
 	    return len - lzfile->strm.avail_out;
 	}
-	if (ret != LZMA_OK)
+	if (ret != LZMAALPHA_OK)
 	    return -1;
 	if (!lzfile->strm.avail_out)
 	    return len;
@@ -2928,7 +2935,7 @@ static ssize_t lzread(LZFILE *lzfile, vo
 
 static ssize_t lzwrite(LZFILE *lzfile, void *buf, size_t len)
 {
-    lzma_ret ret;
+    lzmaalpha_ret ret;
     int n;
     if (!lzfile || !lzfile->encoding)
 	return -1;
@@ -2939,8 +2946,8 @@ static ssize_t lzwrite(LZFILE *lzfile, v
     for (;;) {
 	lzfile->strm.next_out = lzfile->buf;
 	lzfile->strm.avail_out = kBufferSize;
-	ret = lzma_code(&lzfile->strm, LZMA_RUN);
-	if (ret != LZMA_OK)
+	ret = lzmaalpha_code(&lzfile->strm, LZMAALPHA_RUN);
+	if (ret != LZMAALPHA_OK)
 	    return -1;
 	n = kBufferSize - lzfile->strm.avail_out;
 	if (n && fwrite(lzfile->buf, 1, n, lzfile->file) != n)
@@ -3127,6 +3134,346 @@ static struct FDIO_s lzdio_s = {
 /*@=type@*/
 FDIO_t lzdio = /*@-compmempass@*/ &lzdio_s /*@=compmempass@*/ ;
 
+
+typedef struct xzfile {
+  /* IO buffer */
+    uint8_t buf[kBufferSize];
+
+    lzma_stream strm;
+
+    FILE *file;
+
+    int encoding;
+    int eof;
+
+} XZFILE;
+
+static XZFILE *xzopen_internal(const char *path, const char *mode, int fd)
+{
+    int level = 7;
+    int encoding = 0;
+    FILE *fp;
+    XZFILE *xzfile;
+    lzma_ret ret;
+    lzma_stream init_strm = LZMA_STREAM_INIT;
+
+    for (; *mode; mode++) {
+	if (*mode == 'w')
+	    encoding = 1;
+	else if (*mode == 'r')
+	    encoding = 0;
+	else if (*mode >= '1' && *mode <= '9')
+	    level = *mode - '0';
+    }
+    if (fd != -1)
+	fp = fdopen(fd, encoding ? "w" : "r");
+    else
+	fp = fopen(path, encoding ? "w" : "r");
+    if (!fp)
+	return 0;
+    xzfile = calloc(1, sizeof(*xzfile));
+    if (!xzfile) {
+	fclose(fp);
+	return 0;
+    }
+    xzfile->file = fp;
+    xzfile->encoding = encoding;
+    xzfile->eof = 0;
+    xzfile->strm = init_strm;
+    if (encoding) {
+	ret = lzma_easy_encoder(&xzfile->strm, level, LZMA_CHECK_SHA256);
+    } else {
+	ret = lzma_auto_decoder(&xzfile->strm, 100<<20, 0);
+    }
+    if (ret != LZMA_OK) {
+	fclose(fp);
+	free(xzfile);
+	return 0;
+    }
+    return xzfile;
+}
+
+static XZFILE *xzopen(const char *path, const char *mode)
+{
+    return xzopen_internal(path, mode, -1);
+}
+
+static XZFILE *xzdopen(int fd, const char *mode)
+{
+    if (fd < 0)
+	return 0;
+    return xzopen_internal(0, mode, fd);
+}
+
+static int xzflush(XZFILE *xzfile)
+{
+    return fflush(xzfile->file);
+}
+
+static int xzclose(XZFILE *xzfile)
+{
+    lzma_ret ret;
+    int n;
+    int rc;
+
+    if (!xzfile)
+	return -1;
+    if (xzfile->encoding) {
+	for (;;) {
+	    xzfile->strm.avail_out = kBufferSize;
+	    xzfile->strm.next_out = xzfile->buf;
+	    ret = lzma_code(&xzfile->strm, LZMA_FINISH);
+	    if (ret != LZMA_OK && ret != LZMA_STREAM_END)
+		return -1;
+	    n = kBufferSize - xzfile->strm.avail_out;
+	    if (n && fwrite(xzfile->buf, 1, n, xzfile->file) != n)
+		return -1;
+	    if (ret == LZMA_STREAM_END)
+		break;
+	}
+    }
+    lzma_end(&xzfile->strm);
+    rc = fclose(xzfile->file);
+    free(xzfile);
+    return rc;
+}
+
+static ssize_t xzread(XZFILE *xzfile, void *buf, size_t len)
+{
+    lzma_ret ret;
+    int eof = 0;
+
+    if (!xzfile || xzfile->encoding)
+      return -1;
+    if (xzfile->eof)
+      return 0;
+    xzfile->strm.next_out = buf;
+    xzfile->strm.avail_out = len;
+    for (;;) {
+	if (!xzfile->strm.avail_in) {
+	    xzfile->strm.next_in = xzfile->buf;
+	    xzfile->strm.avail_in = fread(xzfile->buf, 1, kBufferSize, xzfile->file);
+	    if (!xzfile->strm.avail_in)
+		eof = 1;
+	}
+	ret = lzma_code(&xzfile->strm, LZMA_RUN);
+	if (ret == LZMA_STREAM_END) {
+	    xzfile->eof = 1;
+	    return len - xzfile->strm.avail_out;
+	}
+	if (ret != LZMA_OK)
+	    return -1;
+	if (!xzfile->strm.avail_out)
+	    return len;
+	if (eof)
+	    return -1;
+      }
+}
+
+static ssize_t xzwrite(XZFILE *xzfile, void *buf, size_t len)
+{
+    lzma_ret ret;
+    int n;
+    if (!xzfile || !xzfile->encoding)
+	return -1;
+    if (!len)
+	return 0;
+    xzfile->strm.next_in = buf;
+    xzfile->strm.avail_in = len;
+    for (;;) {
+	xzfile->strm.next_out = xzfile->buf;
+	xzfile->strm.avail_out = kBufferSize;
+	ret = lzma_code(&xzfile->strm, LZMA_RUN);
+	if (ret != LZMA_OK)
+	    return -1;
+	n = kBufferSize - xzfile->strm.avail_out;
+	if (n && fwrite(xzfile->buf, 1, n, xzfile->file) != n)
+	    return -1;
+	if (!xzfile->strm.avail_in)
+	    return len;
+    }
+}
+
+/* =============================================================== */
+
+static inline /*@dependent@*/ void * xzdFileno(FD_t fd)
+	/*@*/
+{
+    void * rc = NULL;
+    int i;
+
+    FDSANE(fd);
+    for (i = fd->nfps; i >= 0; i--) {
+/*@-boundsread@*/
+	    FDSTACK_t * fps = &fd->fps[i];
+/*@=boundsread@*/
+	    if (fps->io != xzdio)
+		continue;
+	    rc = fps->fp;
+	break;
+    }
+    
+    return rc;
+}
+
+/*@-globuse@*/
+static /*@null@*/ FD_t xzdOpen(const char * path, const char * mode)
+	/*@globals fileSystem @*/
+	/*@modifies fileSystem @*/
+{
+    FD_t fd;
+    XZFILE *xzfile;
+    if ((xzfile = xzopen(path, mode)) == NULL)
+	return NULL;
+    fd = fdNew("open (xzdOpen)");
+    fdPop(fd); fdPush(fd, xzdio, xzfile, -1);
+    return fdLink(fd, "xzdOpen");
+}
+/*@=globuse@*/
+
+
+/*@-globuse@*/
+static /*@null@*/ FD_t xzdFdopen(void * cookie, const char * fmode)
+	/*@globals fileSystem, internalState @*/
+	/*@modifies fileSystem, internalState @*/
+{
+    FD_t fd = c2f(cookie);
+    int fdno;
+    XZFILE *xzfile;
+
+    if (fmode == NULL) return NULL;
+    fdno = fdFileno(fd);
+    fdSetFdno(fd, -1);          /* XXX skip the fdio close */
+    if (fdno < 0) return NULL;
+    xzfile = xzdopen(fdno, fmode);
+    if (xzfile == NULL) return NULL;
+    fdPush(fd, xzdio, xzfile, fdno);
+    return fdLink(fd, "xzdFdopen");
+}
+/*@=globuse@*/
+
+/*@-globuse@*/
+static int xzdFlush(FD_t fd)
+	/*@globals fileSystem @*/
+	/*@modifies fileSystem @*/
+{
+    return xzflush(xzdFileno(fd));
+}
+/*@=globuse@*/
+
+/* =============================================================== */
+/*@-globuse@*/
+/*@-mustmod@*/          /* LCL: *buf is modified */
+static ssize_t xzdRead(void * cookie, /*@out@*/ char * buf, size_t count)
+	/*@globals fileSystem, internalState @*/
+	/*@modifies *buf, fileSystem, internalState @*/
+{
+    FD_t fd = c2f(cookie);
+    XZFILE *xzfile;
+    ssize_t rc = 0;
+
+    if (fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
+    xzfile = xzdFileno(fd);
+    fdstat_enter(fd, FDSTAT_READ);
+    if (xzfile)
+	/*@-compdef@*/
+	rc = xzread(xzfile, buf, count);
+	/*@=compdef@*/
+    if (rc == -1) {
+	fd->errcookie = "xz: decoding error";
+    } else if (rc >= 0) {
+	fdstat_exit(fd, FDSTAT_READ, rc);
+	/*@-compdef@*/
+	if (fd->ndigests && rc > 0) fdUpdateDigests(fd, (void *)buf, rc);
+	/*@=compdef@*/
+    }
+    return rc;
+}
+/*@=mustmod@*/
+/*@=globuse@*/
+
+/*@-globuse@*/
+static ssize_t xzdWrite(void * cookie, const char * buf, size_t count)
+/*@globals fileSystem, internalState @*/
+/*@modifies fileSystem, internalState @*/
+{
+    FD_t fd = c2f(cookie);
+    XZFILE *xzfile;
+    ssize_t rc = 0;
+
+    if (fd == NULL || fd->bytesRemain == 0) return 0;   /* XXX simulate EOF */
+
+    if (fd->ndigests && count > 0) fdUpdateDigests(fd, (void *)buf, count);
+
+    xzfile = xzdFileno(fd);
+
+    fdstat_enter(fd, FDSTAT_WRITE);
+    rc = xzwrite(xzfile, (void *)buf, count);
+    if (rc < 0) {
+	fd->errcookie = "xz: encoding error";
+    } else if (rc > 0) {
+	fdstat_exit(fd, FDSTAT_WRITE, rc);
+    }
+    return rc;
+}
+
+static inline int xzdSeek(void * cookie, /*@unused@*/ _libio_pos_t pos,
+			/*@unused@*/ int whence)
+	/*@*/
+{
+    FD_t fd = c2f(cookie);
+
+    XZDONLY(fd);
+    return -2;
+}
+
+static int xzdClose( /*@only@*/ void * cookie)
+	/*@globals fileSystem, internalState @*/
+	/*@modifies fileSystem, internalState @*/
+{
+    FD_t fd = c2f(cookie);
+    XZFILE *xzfile;
+    int rc;
+
+    xzfile = xzdFileno(fd);
+
+    if (xzfile == NULL) return -2;
+    fdstat_enter(fd, FDSTAT_CLOSE);
+    /*@-dependenttrans@*/
+    rc = xzclose(xzfile);
+    /*@=dependenttrans@*/
+
+    /* XXX TODO: preserve fd if errors */
+
+    if (fd) {
+	if (rc == -1) {
+	    fd->errcookie = strerror(ferror(xzfile->file));
+	} else if (rc >= 0) {
+	    fdstat_exit(fd, FDSTAT_CLOSE, rc);
+	}
+    }
+
+DBGIO(fd, (stderr, "==>\txzdClose(%p) rc %lx %s\n", cookie, (unsigned long)rc, fdbg(fd)));
+
+    if (_rpmio_debug || rpmIsDebug()) fdstat_print(fd, "XZDIO", stderr);
+    /*@-branchstate@*/
+    if (rc == 0)
+	fd = fdFree(fd, "open (xzdClose)");
+    /*@=branchstate@*/
+    return rc;
+}
+
+/*@-type@*/ /* LCL: function typedefs */
+static struct FDIO_s xzdio_s = {
+  xzdRead, xzdWrite, xzdSeek, xzdClose, XfdLink, XfdFree, XfdNew, fdFileno,
+  NULL, xzdOpen, xzdFileno, xzdFlush,	NULL, NULL, NULL, NULL, NULL
+};
+/*@=type@*/
+FDIO_t xzdio = /*@-compmempass@*/ &xzdio_s /*@=compmempass@*/ ;
+
+
+
+
 /* =============================================================== */
 /*@observer@*/
 static const char * getFdErrstr (FD_t fd)
@@ -3146,7 +3493,10 @@ static const char * getFdErrstr (FD_t fd
     } else
 #endif	/* HAVE_BZLIB_H */
     if (fdGetIo(fd) == lzdio) {
-    errstr = fd->errcookie;
+	errstr = fd->errcookie;
+    } else 
+    if (fdGetIo(fd) == xzdio) {
+	errstr = fd->errcookie;
     } else 
     {
 	errstr = (fd->syserrno ? strerror(fd->syserrno) : "");
@@ -3461,9 +3811,12 @@ fprintf(stderr, "*** Fdopen(%p,%s) %s\n"
 	    fd = bzdFdopen(fd, zstdio);
 	    /*@=internalglobs@*/
 #endif
-    } else if (!strcmp(end, "lzdio")) {
-        iof = lzdio;
-        fd = lzdFdopen(fd, zstdio);
+	} else if (!strcmp(end, "lzdio")) {
+	    iof = lzdio;
+	    fd = lzdFdopen(fd, zstdio);
+	} else if (!strcmp(end, "xzdio")) {
+	    iof = xzdio;
+	    fd = xzdFdopen(fd, zstdio);
 	} else if (!strcmp(end, "ufdio")) {
 	    iof = ufdio;
 	} else if (!strcmp(end, "fpio")) {
@@ -3651,7 +4004,10 @@ int Ferror(FD_t fd)
 	    ec = (fd->syserrno  || fd->errcookie != NULL) ? -1 : 0;
 	    i--;	/* XXX fdio under bzdio always has fdno == -1 */
 #endif
-    } else if (fps->io == lzdio) {
+	} else if (fps->io == lzdio) {
+	    ec = (fd->syserrno  || fd->errcookie != NULL) ? -1 : 0;
+	    i--;	/* XXX fdio under lzdio always has fdno == -1 */
+	} else if (fps->io == xzdio) {
 	    ec = (fd->syserrno  || fd->errcookie != NULL) ? -1 : 0;
 	    i--;	/* XXX fdio under lzdio always has fdno == -1 */
 	} else {
--- ./rpmio/rpmio.h.orig	2011-06-15 15:31:03.000000000 +0000
+++ ./rpmio/rpmio.h	2011-06-15 15:31:15.000000000 +0000
@@ -673,6 +673,10 @@ int ufdGetFile( /*@killref@*/ FD_t sfd,
 
 /**
  */
+/*@observer@*/ /*@unchecked@*/ extern FDIO_t xzdio;
+
+/**
+ */
 /*@observer@*/ /*@unchecked@*/ extern FDIO_t fadio;
 /*@=exportlocal@*/
 /*@}*/
--- ./rpmio/rpmmacro.h.orig	2011-06-15 15:48:20.000000000 +0000
+++ ./rpmio/rpmmacro.h	2011-06-15 15:49:00.000000000 +0000
@@ -176,7 +176,8 @@ typedef enum rpmCompressedMagic_e {
     COMPRESSED_OTHER		= 1,	/*!< gzip can handle */
     COMPRESSED_BZIP2		= 2,	/*!< bzip2 can handle */
     COMPRESSED_ZIP		= 3,	/*!< unzip can handle */
-    COMPRESSED_LZMA		= 4	/*!< lzma can handle */
+    COMPRESSED_LZMA		= 4,	/*!< lzma can handle */
+    COMPRESSED_XZ		= 5	/*!< xz can handle */
 } rpmCompressedMagic;
 
 /**