From 272d591973ce001d50c745f1796873e8ad1e8d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20Cors=C3=A9pius?= Date: Wed, 10 Oct 2007 08:39:01 +0200 Subject: Add support for lzma compressed "Sources". --- rpmio/macro.c | 11 ++++++++++- rpmio/rpmmacro.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'rpmio') diff --git a/rpmio/macro.c b/rpmio/macro.c index 972869304..84b48cedc 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -1044,6 +1044,9 @@ doFoo(MacroBuf mb, int negate, const char * f, size_t fn, case COMPRESSED_ZIP: sprintf(be, "%%_unzip %s", b); break; + case COMPRESSED_LZMA: + sprintf(be, "%%_lzma -dc %s", b); + break; } b = be; } else if (STREQ("S", f, fn)) { @@ -1891,7 +1894,7 @@ int isCompressed(const char * file, rpmCompressedMagic * compressed) FD_t fd; ssize_t nb; int rc = -1; - unsigned char magic[4]; + unsigned char magic[13]; *compressed = COMPRESSED_NOT; @@ -1922,6 +1925,12 @@ int isCompressed(const char * file, rpmCompressedMagic * compressed) } else if ((magic[0] == 0120) && (magic[1] == 0113) && (magic[2] == 0003) && (magic[3] == 0004)) { /* pkzip */ *compressed = COMPRESSED_ZIP; + } else if ((magic[ 9] == 0x00) && (magic[10] == 0x00) && + (magic[11] == 0x00) && (magic[12] == 0x00)) { + /* lzma */ + /* FIXME: lzma doesn't have a magic, + * consider to additionally check the filename */ + *compressed = COMPRESSED_LZMA; } 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/rpmmacro.h b/rpmio/rpmmacro.h index 2b58ecd87..171cdd7e7 100644 --- a/rpmio/rpmmacro.h +++ b/rpmio/rpmmacro.h @@ -143,7 +143,8 @@ typedef enum rpmCompressedMagic_e { COMPRESSED_NOT = 0, /*!< not compressed */ COMPRESSED_OTHER = 1, /*!< gzip can handle */ COMPRESSED_BZIP2 = 2, /*!< bzip2 can handle */ - COMPRESSED_ZIP = 3 /*!< unzip can handle */ + COMPRESSED_ZIP = 3, /*!< unzip can handle */ + COMPRESSED_LZMA = 4 /*!< lzma can handle */ } rpmCompressedMagic; /** -- cgit v1.2.3