diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..68c30cf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/lz4-1.7.5.tar.gz diff --git a/.lz4.metadata b/.lz4.metadata new file mode 100644 index 0000000..c2f95d3 --- /dev/null +++ b/.lz4.metadata @@ -0,0 +1 @@ +a710a7d45beb0951806d2b98f0c1739107e97c14 SOURCES/lz4-1.7.5.tar.gz diff --git a/SOURCES/lz4-1.7.5-dont-change-dev-null.patch b/SOURCES/lz4-1.7.5-dont-change-dev-null.patch new file mode 100644 index 0000000..32fbdd0 --- /dev/null +++ b/SOURCES/lz4-1.7.5-dont-change-dev-null.patch @@ -0,0 +1,211 @@ +From a33bf89c62b1573a604144adaa797d94d97cb990 Mon Sep 17 00:00:00 2001 +From: Yann Collet +Date: Wed, 15 Mar 2017 17:20:22 -0700 +Subject: [PATCH] fix #332 : do not modify /dev/null permissions + +--- + NEWS | 4 +++ + programs/lz4io.c | 68 ++++++++++++++++++++++-------------------------- + programs/util.h | 10 +++---- + 3 files changed, 40 insertions(+), 42 deletions(-) + +diff --git a/programs/lz4io.c b/programs/lz4io.c +index 5264b148..5bf54744 100644 +--- a/programs/lz4io.c ++++ b/programs/lz4io.c +@@ -222,7 +222,7 @@ static int LZ4IO_isSkippableMagicNumber(unsigned int magic) { return (magic & LZ + + + /** LZ4IO_openSrcFile() : +- * condition : `dstFileName` must be non-NULL. ++ * condition : `srcFileName` must be non-NULL. + * @result : FILE* to `dstFileName`, or NULL if it fails */ + static FILE* LZ4IO_openSrcFile(const char* srcFileName) + { +@@ -291,7 +291,7 @@ static FILE* LZ4IO_openDstFile(const char* dstFileName) + /* unoptimized version; solves endianess & alignment issues */ + static void LZ4IO_writeLE32 (void* p, unsigned value32) + { +- unsigned char* dstPtr = (unsigned char*)p; ++ unsigned char* const dstPtr = (unsigned char*)p; + dstPtr[0] = (unsigned char)value32; + dstPtr[1] = (unsigned char)(value32 >> 8); + dstPtr[2] = (unsigned char)(value32 >> 16); +@@ -317,10 +317,10 @@ int LZ4IO_compressFilename_Legacy(const char* input_filename, const char* output + const int outBuffSize = LZ4_compressBound(LEGACY_BLOCKSIZE); + FILE* finput; + FILE* foutput; +- clock_t end; ++ clock_t clockEnd; + + /* Init */ +- clock_t const start = clock(); ++ clock_t const clockStart = clock(); + if (compressionlevel < 3) compressionFunction = LZ4IO_LZ4_compress; else compressionFunction = LZ4_compress_HC; + + finput = LZ4IO_openSrcFile(input_filename); +@@ -336,7 +336,7 @@ int LZ4IO_compressFilename_Legacy(const char* input_filename, const char* output + /* Write Archive Header */ + LZ4IO_writeLE32(out_buff, LEGACY_MAGICNUMBER); + { size_t const sizeCheck = fwrite(out_buff, 1, MAGICNUMBER_SIZE, foutput); +- if (sizeCheck!=MAGICNUMBER_SIZE) EXM_THROW(22, "Write error : cannot write header"); } ++ if (sizeCheck != MAGICNUMBER_SIZE) EXM_THROW(22, "Write error : cannot write header"); } + + /* Main Loop */ + while (1) { +@@ -360,13 +360,13 @@ int LZ4IO_compressFilename_Legacy(const char* input_filename, const char* output + if (ferror(finput)) EXM_THROW(25, "Error while reading %s ", input_filename); + + /* Status */ +- end = clock(); +- if (end==start) end+=1; /* avoid division by zero (speed) */ ++ clockEnd = clock(); ++ if (clockEnd==clockStart) clockEnd+=1; /* avoid division by zero (speed) */ + filesize += !filesize; /* avoid division by zero (ratio) */ + DISPLAYLEVEL(2, "\r%79s\r", ""); /* blank line */ + DISPLAYLEVEL(2,"Compressed %llu bytes into %llu bytes ==> %.2f%%\n", + filesize, compressedfilesize, (double)compressedfilesize / filesize * 100); +- { double const seconds = (double)(end - start) / CLOCKS_PER_SEC; ++ { double const seconds = (double)(clockEnd - clockStart) / CLOCKS_PER_SEC; + DISPLAYLEVEL(4,"Done in %.2f s ==> %.2f MB/s\n", seconds, (double)filesize / seconds / 1024 / 1024); + } + +@@ -603,11 +603,11 @@ static unsigned LZ4IO_readLE32 (const void* s) + return value32; + } + +-#define sizeT sizeof(size_t) +-#define maskT (sizeT - 1) + + static unsigned LZ4IO_fwriteSparse(FILE* file, const void* buffer, size_t bufferSize, unsigned storedSkips) + { ++ const size_t sizeT = sizeof(size_t); ++ const size_t maskT = sizeT -1 ; + const size_t* const bufferT = (const size_t*)buffer; /* Buffer is supposed malloc'ed, hence aligned on size_t */ + const size_t* ptrT = bufferT; + size_t bufferSizeT = bufferSize / sizeT; +@@ -682,22 +682,19 @@ static void LZ4IO_fwriteSparseEnd(FILE* file, unsigned storedSkips) + } + + +-static unsigned g_magicRead = 0; ++static unsigned g_magicRead = 0; /* out-parameter of LZ4IO_decodeLegacyStream() */ + static unsigned long long LZ4IO_decodeLegacyStream(FILE* finput, FILE* foutput) + { +- unsigned long long filesize = 0; +- char* in_buff; +- char* out_buff; ++ unsigned long long streamSize = 0; + unsigned storedSkips = 0; + + /* Allocate Memory */ +- in_buff = (char*)malloc(LZ4_compressBound(LEGACY_BLOCKSIZE)); +- out_buff = (char*)malloc(LEGACY_BLOCKSIZE); ++ char* const in_buff = (char*)malloc(LZ4_compressBound(LEGACY_BLOCKSIZE)); ++ char* const out_buff = (char*)malloc(LEGACY_BLOCKSIZE); + if (!in_buff || !out_buff) EXM_THROW(51, "Allocation error : not enough memory"); + + /* Main Loop */ + while (1) { +- int decodeSize; + unsigned int blockSize; + + /* Block Size */ +@@ -716,13 +713,12 @@ static unsigned long long LZ4IO_decodeLegacyStream(FILE* finput, FILE* foutput) + if (sizeCheck!=blockSize) EXM_THROW(52, "Read error : cannot access compressed block !"); } + + /* Decode Block */ +- decodeSize = LZ4_decompress_safe(in_buff, out_buff, blockSize, LEGACY_BLOCKSIZE); +- if (decodeSize < 0) EXM_THROW(53, "Decoding Failed ! Corrupted input detected !"); +- filesize += decodeSize; +- +- /* Write Block */ +- storedSkips = LZ4IO_fwriteSparse(foutput, out_buff, decodeSize, storedSkips); +- } ++ { int const decodeSize = LZ4_decompress_safe(in_buff, out_buff, blockSize, LEGACY_BLOCKSIZE); ++ if (decodeSize < 0) EXM_THROW(53, "Decoding Failed ! Corrupted input detected !"); ++ streamSize += decodeSize; ++ /* Write Block */ ++ storedSkips = LZ4IO_fwriteSparse(foutput, out_buff, decodeSize, storedSkips); /* success or die */ ++ } } + if (ferror(finput)) EXM_THROW(54, "Read error : ferror"); + + LZ4IO_fwriteSparseEnd(foutput, storedSkips); +@@ -731,7 +727,7 @@ static unsigned long long LZ4IO_decodeLegacyStream(FILE* finput, FILE* foutput) + free(in_buff); + free(out_buff); + +- return filesize; ++ return streamSize; + } + + +@@ -925,10 +921,9 @@ static int LZ4IO_decompressSrcFile(dRess_t ress, const char* input_filename, con + { + FILE* const foutput = ress.dstFile; + unsigned long long filesize = 0, decodedSize=0; +- FILE* finput; + + /* Init */ +- finput = LZ4IO_openSrcFile(input_filename); ++ FILE* const finput = LZ4IO_openSrcFile(input_filename); + if (finput==NULL) return 1; + + /* Loop over multiple streams */ +@@ -954,10 +949,7 @@ static int LZ4IO_decompressSrcFile(dRess_t ress, const char* input_filename, con + + static int LZ4IO_decompressDstFile(dRess_t ress, const char* input_filename, const char* output_filename) + { +- FILE* foutput; +- +- /* Init */ +- foutput = LZ4IO_openDstFile(output_filename); ++ FILE* const foutput = LZ4IO_openDstFile(output_filename); /* success or die */ + if (foutput==NULL) return 1; /* failure */ + + ress.dstFile = foutput; +@@ -967,8 +959,11 @@ static int LZ4IO_decompressDstFile(dRess_t ress, const char* input_filename, con + + /* Copy owner, file permissions and modification time */ + { stat_t statbuf; +- if (strcmp (input_filename, stdinmark) && strcmp (output_filename, stdoutmark) && UTIL_getFileStat(input_filename, &statbuf)) +- UTIL_setFileStat(output_filename, &statbuf); ++ if (strcmp (input_filename, stdinmark) ++ && strcmp (output_filename, stdoutmark) ++ && strcmp (output_filename, nulmark) ++ && UTIL_getFileStat(input_filename, &statbuf)) ++ UTIL_setFileStat(output_filename, &statbuf); /* should return value be read ? or is silent fail good enough ? */ + } + + return 0; +@@ -982,10 +977,9 @@ int LZ4IO_decompressFilename(const char* input_filename, const char* output_file + + int const missingFiles = LZ4IO_decompressDstFile(ress, input_filename, output_filename); + +- { clock_t const end = clock(); +- double const seconds = (double)(end - start) / CLOCKS_PER_SEC; +- DISPLAYLEVEL(4, "Done in %.2f sec \n", seconds); +- } ++ clock_t const end = clock(); ++ double const seconds = (double)(end - start) / CLOCKS_PER_SEC; ++ DISPLAYLEVEL(4, "Done in %.2f sec \n", seconds); + + LZ4IO_freeDResources(ress); + return missingFiles; +diff --git a/programs/util.h b/programs/util.h +index 044085f3..5a69c55c 100644 +--- a/programs/util.h ++++ b/programs/util.h +@@ -199,9 +199,9 @@ UTIL_STATIC int UTIL_setFileStat(const char *filename, stat_t *statbuf) + int res = 0; + struct utimbuf timebuf; + +- timebuf.actime = time(NULL); +- timebuf.modtime = statbuf->st_mtime; +- res += utime(filename, &timebuf); /* set access and modification times */ ++ timebuf.actime = time(NULL); ++ timebuf.modtime = statbuf->st_mtime; ++ res += utime(filename, &timebuf); /* set access and modification times */ + + #if !defined(_WIN32) + res += chown(filename, statbuf->st_uid, statbuf->st_gid); /* Copy ownership */ diff --git a/SPECS/lz4.spec b/SPECS/lz4.spec new file mode 100644 index 0000000..5b1b5fe --- /dev/null +++ b/SPECS/lz4.spec @@ -0,0 +1,192 @@ +Name: lz4 +Version: 1.7.5 +Release: 3%{?dist} +Summary: Extremely fast compression algorithm + +License: GPLv2+ and BSD +URL: https://lz4.github.io/lz4/ +Source0: https://github.com/Cyan4973/lz4/archive/v%{version}/%{name}-%{version}.tar.gz +Patch1: lz4-1.7.5-dont-change-dev-null.patch + +%description +LZ4 is an extremely fast loss-less compression algorithm, providing compression +speed at 400 MB/s per core, scalable with multi-core CPU. It also features +an extremely fast decoder, with speed in multiple GB/s per core, typically +reaching RAM speed limits on multi-core systems. + +%package devel +Summary: Development files for lz4 +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +This package contains the header(.h) and library(.so) files required to build +applications using liblz4 library. + +%package static +Summary: Static library for lz4 + +%description static +LZ4 is an extremely fast loss-less compression algorithm. This package +contains static libraries for static linking of applications. + +%prep +%autosetup -p1 -v +echo '#!/bin/sh' > ./configure +chmod +x ./configure + +%build +%configure +%make_build + +%install +%configure +%make_install LIBDIR=%{_libdir} PREFIX=%{_prefix} INSTALL="install -p" + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%files +%license programs/COPYING lib/LICENSE +%doc NEWS +%{_bindir}/lz4 +%{_bindir}/lz4c +%{_bindir}/lz4cat +%{_bindir}/unlz4 +%{_mandir}/man1/lz4.1* +%{_mandir}/man1/lz4c.1* +%{_mandir}/man1/lz4cat.1* +%{_mandir}/man1/unlz4.1* +%{_libdir}/liblz4.so.* + +%files devel +%doc lib/LICENSE +%{_includedir}/lz4*.h +%{_libdir}/liblz4.so +%{_libdir}/pkgconfig/liblz4.pc + +%files static +%doc lib/LICENSE +%{_libdir}/liblz4.a + +%changelog +* Tue Mar 12 2019 Jakub Martisko - 1.7.5-3 +- Fix: lz4 -t corrupts /dev/null permissions +- Resolves: #1680671 + +* Wed Sep 27 2017 Jakub Martisko - 1.7.5-1 - 2 +- Initial RHEL release + +* Thu Jan 05 2017 pjp - 1.7.5-1 - 1 +- Update to 1.7.5 + +* Sat Nov 19 2016 Igor Gnatenko - 1.7.3-1 +- Update to 1.7.3 (RHBZ #1395458) + +* Mon Jul 06 2015 pjp - r131-1 +- New: Dos/DJGPP target #114. +- Added: Example using lz4frame library #118. +- Changed: liblz4.a no longer compiled with -fPIC by default. + +* Thu Jun 18 2015 pjp - r130-1 +- Fixed: incompatibility sparse mode vs console. +- Fixed: LZ4IO exits too early when frame crc not present. +- Fixed: incompatibility sparse mode vs append mode. +- Performance fix: big compression speed boost for clang(+30%). + +* Wed Jun 17 2015 Fedora Release Engineering - r129-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Wed May 27 2015 pjp - r129-1 +- New LZ4_compress_fast() API. +- New LZ4 CLI improved performance with multiple files. +- Other bug fix and documentation updates. + +* Mon Apr 06 2015 pjp - r128-2 +- Update files section to install unlz4 & its manual + +* Wed Apr 01 2015 pjp - r128-1 +- lz4cli sparse file support +- Restored lz4hc compression ratio +- lz4 cli supports long commands +- Introduced lz4-static sub package BZ#1208203 + +* Thu Jan 08 2015 pjp - r127-2 +- Bump dist to override an earlier build. + +* Wed Jan 07 2015 pjp - r127-1 +- Fixed a bug in LZ4 HC streaming mode +- New lz4frame API integrated into liblz4 +- Fixed a GCC 4.9 bug on highest performance settings + +* Thu Nov 13 2014 pjp - r124-1 +- New LZ4 HC Streaming mode + +* Tue Sep 30 2014 pjp - r123-1 +- Added experimental lz4frame API. +- Fix s390x support. + +* Sat Aug 30 2014 pjp - r122-1 +- new release +- Fixed AIX & AIX64 support (SamG) +- Fixed mips 64-bits support (lew van) + +* Sun Aug 17 2014 Fedora Release Engineering - r121-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Fri Aug 08 2014 Igor Gnatenko - r121-2 +- fix destdir + +* Fri Aug 08 2014 pjp - r121-1 +- new release +- Added a pkg-config file. +- Fixed a LZ4 streaming crash bug. + +* Thu Jul 03 2014 pjp - r119-1 +- new release +- Fixed a high Address allocation issue in 32-bits mode. + +* Sat Jun 28 2014 pjp - r118-1 +- new release +- install libraries under appropriate _libdir directories. + +* Sat Jun 14 2014 pjp - r117-3 +- Move shared library object to -devel package. + +* Sat Jun 07 2014 pjp - r117-2 +- Skip static library from installation. + +* Sat Jun 07 2014 Fedora Release Engineering - r117-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Fri Jun 06 2014 pjp - r117-1 +- new release +- added lz4c & lz4cat manual pages. + +* Sun Apr 13 2014 pjp - r116-1 +- new release 116 +- added lz4cat utility for posix systems + +* Sat Mar 15 2014 pjp - r114-1 +- new release r114 +- added RPM_OPT_FLAGS to CFLAGS +- introduced a devel package to build liblz4 + +* Thu Jan 02 2014 pjp - r110-1 +- new release r110 + +* Sun Nov 10 2013 pjp - r108-1 +- new release r108 + +* Wed Oct 23 2013 pjp - r107-1 +- new release r107 + +* Mon Oct 07 2013 pjp - r106-3 +- fixed install section to replace /usr/ with a macro. + -> https://bugzilla.redhat.com/show_bug.cgi?id=1015263#c5 + +* Sat Oct 05 2013 pjp - r106-2 +- fixed install section above as suggested in the review. + -> https://bugzilla.redhat.com/show_bug.cgi?id=1015263#c1 + +* Sun Sep 22 2013 pjp - r106-1 +- Initial RPM release of lz4-r106