[Rpm-maint] rpm: support lzip compression for %setup (patch)

Jan Engelhardt jengelh at medozas.de
Wed Nov 26 21:55:52 UTC 2008


LZIP is the new stable lzma compression utility 
( http://freshmeat.net/p/lzip/ ) with magic bytes and checksum.

===

commit edacdf5e91e25393d6394e88d6d920b3b1cc0cac
Author: Jan Engelhardt <jengelh at medozas.de>
Date:   Wed Nov 26 22:50:50 2008 +0100

Support LZIP compression
---
 build/parsePrep.c   |    3 +++
 configure.ac        |   15 +++------------
 macros.in           |    1 +
 rpmio/macro.c       |    3 +++
 rpmio/rpmfileutil.c |    3 +++
 rpmio/rpmfileutil.h |    3 ++-
 6 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/build/parsePrep.c b/build/parsePrep.c
index 34906c8..cc1738d 100644
--- a/build/parsePrep.c
+++ b/build/parsePrep.c
@@ -218,6 +218,9 @@ static char *doUntar(rpmSpec spec, uint32_t c, int quietly)
 	case COMPRESSED_LZMA:
 	    t = "%{__lzma} -dc";
 	    break;
+	case COMPRESSED_LZIP:
+	    t = "%__lzip -dc";
+	    break;
 	}
 	zipper = rpmGetPath(t, NULL);
 	if (needtar) {
diff --git a/configure.ac b/configure.ac
index 6779968..36dc970 100644
--- a/configure.ac
+++ b/configure.ac
@@ -155,6 +155,7 @@ AC_SUBST(__ID_U)
 
 AC_PATH_PROG(__INSTALL, install, /usr/bin/install, $MYPATH)
 AC_PATH_PROG(__LZMA, lzma, /usr/bin/lzma, $MYPATH)
+AC_PATH_PROG([__LZIP], [lzip], [/usr/bin/lzip], [$MYPATH])
 AC_PATH_PROG(__MAKE, make, /usr/bin/make, $MYPATH)
 AC_PATH_PROG(__MKDIR, mkdir, /bin/mkdir, $MYPATH)
 AC_PATH_PROG(__MV, mv, /bin/mv, $MYPATH)
@@ -302,18 +303,8 @@ AM_CONDITIONAL(LIBDWARF,[test "$WITH_LIBDWARF" = yes])
 # We need nss.h from NSS which needs nspr.h. Unfortunately both glibc and NSS 
 # have a header named nss.h... so make extra check for NSS's sechash.h 
 # which we use too and hopefully is slightly more unique to NSS.
-WITH_NSS_INCLUDE=
-WITH_NSS_LIB=
-AC_CHECK_HEADERS([nspr.h nss.h sechash.h], [], [
-  AC_MSG_ERROR([missing required NSPR / NSS header])
-])
-AC_CHECK_LIB(nss3, NSS_NoDB_Init, [
-  WITH_NSS_LIB=-lnss3
-], [
-  AC_MSG_ERROR([missing required NSS library 'nss3'])
-])
-AC_SUBST(WITH_NSS_INCLUDE)
-AC_SUBST(WITH_NSS_LIB)
+PKG_CHECK_MODULES([libnspr], [nspr])
+PKG_CHECK_MODULES([libnss], [nss])
 
 #=================
 # Check for magic library.
diff --git a/macros.in b/macros.in
index c3c5025..cac51b1 100644
--- a/macros.in
+++ b/macros.in
@@ -47,6 +47,7 @@
 %__install		@__INSTALL@
 %__ln_s			@LN_S@
 %__lzma			@__LZMA@
+%__lzip			@__LZIP@
 %__make			@__MAKE@
 %__mkdir		@__MKDIR@
 %__mkdir_p		@MKDIR_P@
diff --git a/rpmio/macro.c b/rpmio/macro.c
index afe41cb..f0fe9c1 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -981,6 +981,9 @@ doFoo(MacroBuf mb, int negate, const char * f, size_t fn,
         case COMPRESSED_LZMA:
             sprintf(be, "%%__lzma -dc %s", b);
             break;
+        case COMPRESSED_LZIP:
+	    sprintf(be, "%%__lzip -dc %s", b);
+	    break;
 	}
 	b = be;
     } else if (STREQ("S", f, fn)) {
diff --git a/rpmio/rpmfileutil.c b/rpmio/rpmfileutil.c
index d0f4646..b2c22b4 100644
--- a/rpmio/rpmfileutil.c
+++ b/rpmio/rpmfileutil.c
@@ -360,6 +360,9 @@ int rpmFileIsCompressed(const char * file, rpmCompressedMagic * compressed)
 	       (magic[4] == 0x5a) && (magic[5] == 0x00)) {
 	/* new style lzma with magic */
 	*compressed = COMPRESSED_LZMA;
+    } else if (magic[0] == 'L' && magic[1] == 'Z' &&
+        magic[2] == 'I' && magic[3] == 'P') {
+            *compressed = COMPRESSED_LZIP;
     } else if (((magic[0] == 0037) && (magic[1] == 0213)) || /* gzip */
 	((magic[0] == 0037) && (magic[1] == 0236)) ||	/* old gzip */
 	((magic[0] == 0037) && (magic[1] == 0036)) ||	/* pack */
diff --git a/rpmio/rpmfileutil.h b/rpmio/rpmfileutil.h
index 471509e..74f10ff 100644
--- a/rpmio/rpmfileutil.h
+++ b/rpmio/rpmfileutil.h
@@ -18,7 +18,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_LZIP		= 5,
 } rpmCompressedMagic;
 
 /** \ingroup rpmfileutil



More information about the Rpm-maint mailing list