RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Ralf S. Engelschall Root: /v/rpm/cvs Email: [EMAIL PROTECTED] Module: rpm Date: 13-Apr-2008 10:48:27 Branch: HEAD Handle: 2008041308482700 Modified files: rpm VENDOR rpm/rpmio macro.c Log: OpenPKG-specific change: "extension-based-compression-detection" RPM tries to detect file compression by inspecting "magic" bytes at the front of a file. This works for formats with known "magic" bytes just fine, but fails horribly for formats like LZMA where no such "magic" bytes exist. As a result RPM 5 this way too often thinks .tar files are LZMA compressed and stumbles over this during build-time. For OpenPKG we prefer to first use file extension based determination (if someone is mis-names his distribution files we have to take action anyway) and fall back to "magic" byte based determination only if no well known extension is found. Additionally, detecting LZMA we want to do via file extension only. Summary: Revision Changes Path 2.48 +18 -0 rpm/VENDOR 2.194 +38 -0 rpm/rpmio/macro.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/VENDOR ============================================================================ $ cvs diff -u -r2.47 -r2.48 VENDOR --- rpm/VENDOR 2 Apr 2008 21:56:46 -0000 2.47 +++ rpm/VENDOR 13 Apr 2008 08:48:27 -0000 2.48 @@ -368,6 +368,24 @@ not for the complete command argument line. ________________________________________________________________________ + Change: extension-based-compression-detection + Purpose: Prefer file extension for detecting file compression. + Reason: RPM tries to detect file compression by inspecting + "magic" bytes at the front of a file. This works + for formats with known "magic" bytes just fine, + but fails horribly for formats like LZMA where no + such "magic" bytes exist. As a result RPM 5 this + way too often thinks .tar files are LZMA compressed + and stumbles over this during build-time. For + OpenPKG we prefer to first use file extension + based determination (if someone is mis-names + his distribution files we have to take action + anyway) and fall back to "magic" byte based + determination only if no well known extension is + found. Additionally, detecting LZMA we want to do + via file extension only. + ________________________________________________________________________ + o Name: RPM4DARWIN Vendor: RPM for Darwin (Mac OS X) <http://rpm4darwin.sourceforge.net/> Representative: Anders F. Bjorklund <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/macro.c ============================================================================ $ cvs diff -u -r2.193 -r2.194 macro.c --- rpm/rpmio/macro.c 2 Apr 2008 21:10:52 -0000 2.193 +++ rpm/rpmio/macro.c 13 Apr 2008 08:48:27 -0000 2.194 @@ -2388,9 +2388,45 @@ ssize_t nb; int rc = -1; unsigned char magic[13]; +#if defined(RPM_VENDOR_OPENPKG) /* extension-based-compression-detection */ + size_t file_len; +#endif *compressed = COMPRESSED_NOT; +#if defined(RPM_VENDOR_OPENPKG) /* extension-based-compression-detection */ + file_len = strlen(file); + if ( (file_len > 4 && strcasecmp(file+file_len-4, ".tbz") == 0) + || (file_len > 4 && strcasecmp(file+file_len-4, ".bz2") == 0)) { + *compressed = COMPRESSED_BZIP2; + return 0; + } + else if (file_len > 4 && strcasecmp(file+file_len-4, ".zip") == 0) { + *compressed = COMPRESSED_ZIP; + return 0; + } + else if ( (file_len > 3 && strcasecmp(file+file_len-3, ".lz") == 0) + || (file_len > 3 && strcasecmp(file+file_len-3, ".7z") == 0) + || (file_len > 5 && strcasecmp(file+file_len-5, ".lzma") == 0)) { + *compressed = COMPRESSED_LZMA; + return 0; + } + else if ( (file_len > 4 && strcasecmp(file+file_len-4, ".tgz") == 0) + || (file_len > 3 && strcasecmp(file+file_len-3, ".gz") == 0) + || (file_len > 2 && strcasecmp(file+file_len-2, ".Z") == 0)) { + *compressed = COMPRESSED_OTHER; + return 0; + } + else if (file_len > 5 && strcasecmp(file+file_len-5, ".cpio") == 0) { + *compressed = COMPRESSED_NOT; + return 0; + } + else if (file_len > 4 && strcasecmp(file+file_len-4, ".tar") == 0) { + *compressed = COMPRESSED_NOT; + return 0; + } +#endif + fd = Fopen(file, "r"); if (fd == NULL || Ferror(fd)) { /* XXX Fstrerror */ @@ -2424,11 +2460,13 @@ && magic[2] == 'Z' && magic[3] == 'O') /* lzop */ *compressed = COMPRESSED_LZOP; else +#if !defined(RPM_VENDOR_OPENPKG) /* extension-based-compression-detection */ /* XXX Ick, LZMA has no magic. See http://lkml.org/lkml/2005/6/13/285 */ if (magic[ 9] == (unsigned char) 0x00 && magic[10] == (unsigned char) 0x00 && magic[11] == (unsigned char) 0x00 && magic[12] == (unsigned char) 0x00) /* lzmash */ *compressed = COMPRESSED_LZMA; else +#endif if ((magic[0] == (unsigned char) 0037 && magic[1] == (unsigned char) 0213) /* gzip */ || (magic[0] == (unsigned char) 0037 && magic[1] == (unsigned char) 0236) /* old gzip */ || (magic[0] == (unsigned char) 0037 && magic[1] == (unsigned char) 0036) /* pack */ @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org