Add support for 7zip compressed tarballs
authorChristophe Fergeau <cfergeau@redhat.com>
Thu, 10 May 2012 21:27:56 +0000 (23:27 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 22 May 2012 10:48:01 +0000 (13:48 +0300)
Teach %prep and %uncompress how to handle 7zip tarballs, with
the mingw toolchain landing in fedora, this may be useful when
crossbuilding Windows sources compressed using 7zip (CxImage is
one such project).

build/parsePrep.c
configure.ac
macros.in
rpmio/macro.c
rpmio/rpmfileutil.c
rpmio/rpmfileutil.h

index 1efbcf2..fd4d30c 100644 (file)
@@ -193,6 +193,10 @@ static char *doUntar(rpmSpec spec, uint32_t c, int quietly)
        case COMPRESSED_LRZIP:
            t = "%{__lrzip} -dqo-";
            break;
+       case COMPRESSED_7ZIP:
+           t = "%{__7zip} x";
+           needtar = 0;
+           break;
        }
        zipper = rpmGetPath(t, NULL);
        if (needtar) {
index 4501b5c..622affe 100644 (file)
@@ -91,6 +91,7 @@ fi
 dnl
 dnl Find some common programs
 dnl
+AC_PATH_PROG(__7ZIP, 7zip, /usr/bin/7za, $MYPATH)
 AC_PATH_PROG(__BZIP2, bzip2, /usr/bin/bzip2, $MYPATH)
 AC_PATH_PROG(__CAT, cat, /bin/cat, $MYPATH)
 AC_PATH_PROG(__CHGRP, chgrp, /bin/chgrp, $MYPATH)
index b0b78aa..0bf0fa4 100644 (file)
--- a/macros.in
+++ b/macros.in
@@ -31,6 +31,7 @@
 #==============================================================================
 # ---- Generally useful path macros.
 #
+%__7zip                        @__7ZIP@
 %__awk                 @AWK@
 %__bzip2               @__BZIP2@
 %__cat                 @__CAT@
index 238ebcd..e5a3463 100644 (file)
@@ -971,6 +971,9 @@ doFoo(MacroBuf mb, int negate, const char * f, size_t fn,
        case COMPRESSED_LRZIP:
            sprintf(be, "%%__lrzip -dqo- %s", b);
            break;
+       case COMPRESSED_7ZIP:
+           sprintf(be, "%%__7zip x %s", b);
+           break;
        }
        b = be;
     } else if (STREQ("getenv", f, fn)) {
index d9c9f5b..f82401f 100644 (file)
@@ -388,6 +388,10 @@ int rpmFileIsCompressed(const char * file, rpmCompressedMagic * compressed)
        ((magic[0] == 0037) && (magic[1] == 0235))      /* compress */
        ) {
        *compressed = COMPRESSED_OTHER;
+    } else if ((magic[0] == '7') && (magic[1] == 'z') &&
+               (magic[2] == 0xbc) && (magic[3] == 0xaf) &&
+               (magic[4] == 0x27) && (magic[5] == 0x1c)) {
+       *compressed = COMPRESSED_7ZIP;
     } else if (rpmFileHasSuffix(file, ".lzma")) {
        *compressed = COMPRESSED_LZMA;
     }
index 28c6d8a..52f8fba 100644 (file)
@@ -25,7 +25,8 @@ typedef enum rpmCompressedMagic_e {
     COMPRESSED_LZMA            = 4,    /*!< lzma can handle */
     COMPRESSED_XZ              = 5,    /*!< xz can handle */
     COMPRESSED_LZIP            = 6,    /*!< lzip can handle */
-    COMPRESSED_LRZIP           = 7     /*!< lrzip can handle */
+    COMPRESSED_LRZIP           = 7,    /*!< lrzip can handle */
+    COMPRESSED_7ZIP            = 8     /*!< 7zip can handle */
 } rpmCompressedMagic;
 
 /** \ingroup rpmfileutil