commit 86742fea5d2069fafcca9c572e7d794ac03973a3 Author: tigro Date: Tue Sep 19 18:46:36 2023 +0300 import miniz-2.2.0-2.el9 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..78f863f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/miniz-2.2.0.zip diff --git a/.miniz.metadata b/.miniz.metadata new file mode 100644 index 0000000..2c70b56 --- /dev/null +++ b/.miniz.metadata @@ -0,0 +1 @@ +f51c5eaf0c474e7c7a2999f9ee1f8070d3985c93 SOURCES/miniz-2.2.0.zip diff --git a/SOURCES/miniz-2.2.0-Examples-to-include-system-miniz.h.patch b/SOURCES/miniz-2.2.0-Examples-to-include-system-miniz.h.patch new file mode 100644 index 0000000..07d0cb3 --- /dev/null +++ b/SOURCES/miniz-2.2.0-Examples-to-include-system-miniz.h.patch @@ -0,0 +1,101 @@ +From dd5cf5e228a90ecfc66257e04fc6dd053fd9c686 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Wed, 22 May 2019 12:34:13 +0200 +Subject: [PATCH] Examples to include system miniz.h +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We build miniz as a dynamic library. Adjust examples to use a miniz +header file from a system location. + +Signed-off-by: Petr Písař +--- + examples/example1.c | 2 +- + examples/example2.c | 2 +- + examples/example3.c | 2 +- + examples/example4.c | 2 +- + examples/example5.c | 2 +- + examples/example6.c | 2 +- + 6 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/examples/example1.c b/examples/example1.c +index d6e33fa..7cb2556 100644 +--- a/examples/example1.c ++++ b/examples/example1.c +@@ -1,7 +1,7 @@ + // example1.c - Demonstrates miniz.c's compress() and uncompress() functions (same as zlib's). + // Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c. + #include +-#include "miniz.h" ++#include + typedef unsigned char uint8; + typedef unsigned short uint16; + typedef unsigned int uint; +diff --git a/examples/example2.c b/examples/example2.c +index 03d2409..bc9fba5 100644 +--- a/examples/example2.c ++++ b/examples/example2.c +@@ -13,7 +13,7 @@ + #endif + + #include +-#include "miniz.h" ++#include + + typedef unsigned char uint8; + typedef unsigned short uint16; +diff --git a/examples/example3.c b/examples/example3.c +index a97ba84..7aaac31 100644 +--- a/examples/example3.c ++++ b/examples/example3.c +@@ -3,7 +3,7 @@ + // For simplicity, this example is limited to files smaller than 4GB, but this is not a limitation of miniz.c. + #include + #include +-#include "miniz.h" ++#include + + typedef unsigned char uint8; + typedef unsigned short uint16; +diff --git a/examples/example4.c b/examples/example4.c +index 3f2d7cf..2e6d3f6 100644 +--- a/examples/example4.c ++++ b/examples/example4.c +@@ -1,6 +1,6 @@ + // example4.c - Uses tinfl.c to decompress a zlib stream in memory to an output file + // Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c. +-#include "miniz.h" ++#include + #include + #include + +diff --git a/examples/example5.c b/examples/example5.c +index a190357..0d93a9a 100644 +--- a/examples/example5.c ++++ b/examples/example5.c +@@ -9,7 +9,7 @@ + #define MINIZ_NO_TIME + #define MINIZ_NO_ZLIB_APIS + #define MINIZ_NO_MALLOC +-#include "miniz.h" ++#include + + // Now include stdio.h because this test uses fopen(), etc. (but we still don't want miniz.c's stdio stuff, for testing). + #include +diff --git a/examples/example6.c b/examples/example6.c +index abbb64f..7878848 100644 +--- a/examples/example6.c ++++ b/examples/example6.c +@@ -7,7 +7,7 @@ + #define MINIZ_NO_STDIO + #define MINIZ_NO_TIME + #define MINIZ_NO_ZLIB_APIS +-#include "miniz.h" ++#include + + // Now include stdio.h because this test uses fopen(), etc. (but we still don't want miniz.c's stdio stuff, for testing). + #include +-- +2.31.1 + diff --git a/SOURCES/miniz-2.2.0-Fix-MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8-not-being-s.patch b/SOURCES/miniz-2.2.0-Fix-MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8-not-being-s.patch new file mode 100644 index 0000000..ec6c03d --- /dev/null +++ b/SOURCES/miniz-2.2.0-Fix-MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8-not-being-s.patch @@ -0,0 +1,39 @@ +From aff8d486584f91d5b8358f7aa9be759ddb2cd005 Mon Sep 17 00:00:00 2001 +From: Martin +Date: Sat, 11 Dec 2021 12:51:50 +0100 +Subject: [PATCH] Fix MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8 not being set +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Petr Písař: Ported to 2.2.0. + +Signed-off-by: Petr Písař +--- + miniz.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/miniz.c b/miniz.c +index 071367f..95e4186 100644 +--- a/miniz.c ++++ b/miniz.c +@@ -6407,13 +6407,13 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA + mz_zip_internal_state *pState; + mz_uint64 file_ofs = 0, cur_archive_header_file_ofs; + +- if (!(level_and_flags & MZ_ZIP_FLAG_ASCII_FILENAME)) +- gen_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8; +- + if ((int)level_and_flags < 0) + level_and_flags = MZ_DEFAULT_LEVEL; + level = level_and_flags & 0xF; + ++ if (!(level_and_flags & MZ_ZIP_FLAG_ASCII_FILENAME)) ++ gen_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8; ++ + /* Sanity checks */ + if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION)) + return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); +-- +2.34.1 + diff --git a/SOURCES/miniz-2.2.0-Fix-unaligned-pointer-access.patch b/SOURCES/miniz-2.2.0-Fix-unaligned-pointer-access.patch new file mode 100644 index 0000000..63cd4e1 --- /dev/null +++ b/SOURCES/miniz-2.2.0-Fix-unaligned-pointer-access.patch @@ -0,0 +1,37 @@ +From f3906fd616c92168c63bb92accc72e79a24b0c04 Mon Sep 17 00:00:00 2001 +From: Martin +Date: Sun, 28 Nov 2021 18:37:55 +0100 +Subject: [PATCH] Fix unaligned pointer access +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Petr Písař: Ported to 2.2.0. + +Signed-off-by: Petr Písař +--- + miniz.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/miniz.c b/miniz.c +index af27389..071367f 100644 +--- a/miniz.c ++++ b/miniz.c +@@ -7118,10 +7118,10 @@ mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive * + if (pZip->m_pState->m_zip64) + { + /* dest is zip64, so upgrade the data descriptor */ +- const mz_uint32 *pSrc_descriptor = (const mz_uint32 *)((const mz_uint8 *)pBuf + (has_id ? sizeof(mz_uint32) : 0)); +- const mz_uint32 src_crc32 = pSrc_descriptor[0]; +- const mz_uint64 src_comp_size = pSrc_descriptor[1]; +- const mz_uint64 src_uncomp_size = pSrc_descriptor[2]; ++ const mz_uint8 *pSrc_descriptor = (const mz_uint8 *)pBuf + (has_id ? sizeof(mz_uint32) : 0); ++ const mz_uint32 src_crc32 = MZ_READ_LE32(pSrc_descriptor); ++ const mz_uint64 src_comp_size = MZ_READ_LE32(pSrc_descriptor + sizeof(mz_uint32)); ++ const mz_uint64 src_uncomp_size = MZ_READ_LE32(pSrc_descriptor + 2*sizeof(mz_uint32)); + + mz_write_le32((mz_uint8 *)pBuf, MZ_ZIP_DATA_DESCRIPTOR_ID); + mz_write_le32((mz_uint8 *)pBuf + sizeof(mz_uint32) * 1, src_crc32); +-- +2.34.1 + diff --git a/SOURCES/miniz-2.2.0-Fix-use-of-uninitialized-memory-in-tinfl_decompress_.patch b/SOURCES/miniz-2.2.0-Fix-use-of-uninitialized-memory-in-tinfl_decompress_.patch new file mode 100644 index 0000000..80ec355 --- /dev/null +++ b/SOURCES/miniz-2.2.0-Fix-use-of-uninitialized-memory-in-tinfl_decompress_.patch @@ -0,0 +1,32 @@ +From 98f4698e81e6d06653201639cf9a75c3c1464884 Mon Sep 17 00:00:00 2001 +From: Cameron Cawley +Date: Sun, 25 Jul 2021 15:36:22 +0100 +Subject: [PATCH] Fix use of uninitialized memory in + tinfl_decompress_mem_to_callback() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: sezero +Petr Písař: Ported to 2.2.0. + +Signed-off-by: Petr Písař +--- + miniz.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/miniz.c b/miniz.c +index 87bdedb..af27389 100644 +--- a/miniz.c ++++ b/miniz.c +@@ -2916,6 +2916,7 @@ int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, + size_t in_buf_ofs = 0, dict_ofs = 0; + if (!pDict) + return TINFL_STATUS_FAILED; ++ memset(pDict,0,TINFL_LZ_DICT_SIZE); + tinfl_init(&decomp); + for (;;) + { +-- +2.34.1 + diff --git a/SOURCES/miniz-2.2.0-miniz_zip-fix-mz_zip_reader_extract_to_heap-to-read-.patch b/SOURCES/miniz-2.2.0-miniz_zip-fix-mz_zip_reader_extract_to_heap-to-read-.patch new file mode 100644 index 0000000..6d3e2b3 --- /dev/null +++ b/SOURCES/miniz-2.2.0-miniz_zip-fix-mz_zip_reader_extract_to_heap-to-read-.patch @@ -0,0 +1,108 @@ +From f37c338de59d335e6fee6f5040653a3fe731e825 Mon Sep 17 00:00:00 2001 +From: Ozkan Sezer +Date: Sun, 2 Jan 2022 20:56:56 +0300 +Subject: [PATCH] miniz_zip: fix mz_zip_reader_extract_to_heap to read correct + sizes +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fixes: https://github.com/richgel999/miniz/issues/218 +Petr Písař: Ported to 2.2.0 from +501a76154940c465bc3e97f7e2d16134021bd8aa and +f3d9e2293bdf9da952747cdd794a4fa83e0e5b24. + +Signed-off-by: Petr Písař +--- + miniz.c | 31 +++++++++++++++++-------------- + 1 file changed, 17 insertions(+), 14 deletions(-) + +diff --git a/miniz.c b/miniz.c +index 845a107..e32f892 100644 +--- a/miniz.c ++++ b/miniz.c +@@ -4385,7 +4385,8 @@ mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, co + return mz_zip_set_error(pZip, MZ_ZIP_FILE_NOT_FOUND); + } + +-mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) ++static ++mz_bool mz_zip_reader_extract_to_mem_no_alloc1(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size, const mz_zip_archive_file_stat *st) + { + int status = TINFL_STATUS_DONE; + mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail; +@@ -4398,6 +4399,9 @@ mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file + if ((!pZip) || (!pZip->m_pState) || ((buf_size) && (!pBuf)) || ((user_read_buf_size) && (!pUser_read_buf)) || (!pZip->m_pRead)) + return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); + ++ if (st) { ++ file_stat = *st; ++ } else + if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) + return MZ_FALSE; + +@@ -4528,17 +4532,22 @@ mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file + return status == TINFL_STATUS_DONE; + } + ++mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) ++{ ++ return mz_zip_reader_extract_to_mem_no_alloc1(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size, NULL); ++} ++ + mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) + { + mz_uint32 file_index; + if (!mz_zip_reader_locate_file_v2(pZip, pFilename, NULL, flags, &file_index)) + return MZ_FALSE; +- return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size); ++ return mz_zip_reader_extract_to_mem_no_alloc1(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size, NULL); + } + + mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags) + { +- return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, NULL, 0); ++ return mz_zip_reader_extract_to_mem_no_alloc1(pZip, file_index, pBuf, buf_size, flags, NULL, 0, NULL); + } + + mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags) +@@ -4548,23 +4557,17 @@ mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFil + + void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags) + { +- mz_uint64 comp_size, uncomp_size, alloc_size; +- const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index); ++ mz_zip_archive_file_stat file_stat; ++ mz_uint64 alloc_size; + void *pBuf; + + if (pSize) + *pSize = 0; + +- if (!p) +- { +- mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); ++ if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) + return NULL; +- } +- +- comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); +- uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); + +- alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size; ++ alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size : file_stat.m_uncomp_size; + if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) + { + mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR); +@@ -4577,7 +4580,7 @@ void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, si + return NULL; + } + +- if (!mz_zip_reader_extract_to_mem(pZip, file_index, pBuf, (size_t)alloc_size, flags)) ++ if (!mz_zip_reader_extract_to_mem_no_alloc1(pZip, file_index, pBuf, (size_t)alloc_size, flags, NULL, 0, &file_stat)) + { + pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); + return NULL; +-- +2.34.1 + diff --git a/SOURCES/miniz-2.2.0-tinfl_decompress-avoid-NULL-ptr-arithmetic-UB.patch b/SOURCES/miniz-2.2.0-tinfl_decompress-avoid-NULL-ptr-arithmetic-UB.patch new file mode 100644 index 0000000..c1988cf --- /dev/null +++ b/SOURCES/miniz-2.2.0-tinfl_decompress-avoid-NULL-ptr-arithmetic-UB.patch @@ -0,0 +1,36 @@ +From c33612fb4ee893d4591e5949d02e25ae3b997834 Mon Sep 17 00:00:00 2001 +From: Ozkan Sezer +Date: Mon, 27 Dec 2021 10:50:32 +0300 +Subject: [PATCH] tinfl_decompress: avoid NULL ptr arithmetic UB: +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fixes: https://github.com/richgel999/miniz/issues/216 + +Also see: +https://github.com/mitkus/miniz/commit/6b8c30e4a95dd649adf14cf4bcad90701e323b9a + +Petr Písař: Ported to 2.2.0. + +Signed-off-by: Petr Písař +--- + miniz.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/miniz.c b/miniz.c +index 95e4186..845a107 100644 +--- a/miniz.c ++++ b/miniz.c +@@ -2401,7 +2401,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex + mz_uint32 num_bits, dist, counter, num_extra; + tinfl_bit_buf_t bit_buf; + const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; +- mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size; ++ mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next ? pOut_buf_next + *pOut_buf_size : NULL; + size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t)-1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start; + + /* Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter). */ +-- +2.34.1 + diff --git a/SPECS/miniz.spec b/SPECS/miniz.spec new file mode 100644 index 0000000..cb5ead2 --- /dev/null +++ b/SPECS/miniz.spec @@ -0,0 +1,229 @@ +%if !%{defined toolchain} +%global toolchain gcc +%endif + +Name: miniz +Version: 2.2.0 +Release: 2%{?dist} +Summary: Compression library implementing the zlib and Deflate +# LICENSE: MIT text +# miniz.c: MIT +# examples/example1.c: Unlicense (refers to "unlicense" statement at the end +# of tinfl.c from miniz-1.15) +# miniz.h: Unlicense (See "unlicense" statement at the end of this file.) +License: MIT and Unlicense +URL: https://github.com/richgel999/%{name} +Source0: %{url}/releases/download/%{version}/%{name}-%{version}.zip +# Adjust examples for building against a system miniz library, +# not suitable for upstream that prefers a copy-lib approach. +Patch0: miniz-2.2.0-Examples-to-include-system-miniz.h.patch +# Fix an unitialized memory in tinfl_decompress_mem_to_callback(), GH#197, +# in upstream after 2.2.0. +Patch1: miniz-2.2.0-Fix-use-of-uninitialized-memory-in-tinfl_decompress_.patch +# Fix an unaligned memory access, in upstream after 2.2.0. +Patch2: miniz-2.2.0-Fix-unaligned-pointer-access.patch +# Fix setting MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8, in upstream after 2.2.0. +Patch3: miniz-2.2.0-Fix-MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8-not-being-s.patch +# Fix an undefined behaviour in tinfl_decompress(), GH#216, +# in upstream after 2.2.0. +Patch4: miniz-2.2.0-tinfl_decompress-avoid-NULL-ptr-arithmetic-UB.patch +# Fix mz_zip_reader_extract_to_heap() to read correct sizes, GH#220, +# in upstream after 2.2.0. +Patch5: miniz-2.2.0-miniz_zip-fix-mz_zip_reader_extract_to_heap-to-read-.patch +BuildRequires: coreutils +# diffutils for cmp +BuildRequires: diffutils +%if "%{toolchain}" == "gcc" +BuildRequires: gcc +%else +%if "%{toolchain}" == "clang" +BuildRequires: clang +%else +%{error:Unknown toolchain.} +%endif +%endif +BuildRequires: sed +BuildRequires: unzip + +%description +Miniz is a lossless, high performance data compression library in a single +source file that implements the zlib (RFC 1950) and Deflate (RFC 1951) +compressed data format specification standards. It supports the most commonly +used functions exported by the zlib library, but is a completely independent +implementation so zlib's licensing requirements do not apply. It also +contains simple to use functions for writing PNG format image files and +reading/writing/appending ZIP format archives. Miniz's compression speed has +been tuned to be comparable to zlib's, and it also has a specialized real-time +compressor function designed to compare well against fastlz/minilzo. + +%package devel +Summary: Development files for the %{name} library +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +Header files for developing applications that use the %{name} library. + + +%prep +%setup -c -T -n %{name}-%{version} +unzip -e '%{SOURCE0}' +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +# Normalize end-of-lines +sed -e 's/\r$//' ChangeLog.md > ChangeLog.md.new +touch -r ChangeLog.md ChangeLog.md.new +mv ChangeLog.md.new ChangeLog.md + +%global soname lib%{name}.so.0.2 + +%build +# Export CC environment variable +%{set_build_flags} +# Inject downstream SONAME, bug #1152653 +"$CC" %{optflags} -fPIC -DPIC -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 \ + %{name}.c -c -o %{name}.o +"$CC" %{?__global_ldflags} -fPIC -shared -Wl,-soname,%{soname} \ + %{name}.o -o %{soname} +ln -s %{soname} lib%{name}.so +# Build examples against the library +pushd examples +for EXAMPLE in *.c; do + EXAMPLE=${EXAMPLE%.c} + %{__cc} %{optflags} -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 \ + -I.. "${EXAMPLE}.c" -c -o "${EXAMPLE}.o" + case "$EXAMPLE" in + example6) + %{__cc} %{?__global_ldflags} "${EXAMPLE}.o" -L.. -l%{name} -lm -o "$EXAMPLE" + ;; + *) + %{__cc} %{?__global_ldflags} "${EXAMPLE}.o" -L.. -l%{name} -o "$EXAMPLE" + ;; + esac +done + +%check +pushd examples +for EXAMPLE in *.c; do + EXAMPLE=${EXAMPLE%.c} + case "$EXAMPLE" in + example3) + LD_LIBRARY_PATH=.. "./${EXAMPLE}" c ../readme.md readme.md.z + LD_LIBRARY_PATH=.. "./${EXAMPLE}" d readme.md.z readme.md + cmp ../readme.md readme.md + ;; + example4) + LD_LIBRARY_PATH=.. "./${EXAMPLE}" readme.md.z readme.md + cmp ../readme.md readme.md + ;; + example5) + LD_LIBRARY_PATH=.. "./${EXAMPLE}" c ../readme.md readme.md.z + LD_LIBRARY_PATH=.. "./${EXAMPLE}" d readme.md.z readme.md + cmp ../readme.md readme.md + ;; + *) + LD_LIBRARY_PATH=.. "./${EXAMPLE}" + ;; + esac +done + +%install +install -d '%{buildroot}/%{_libdir}' +install %{soname} '%{buildroot}/%{_libdir}' +ln -s %{soname} '%{buildroot}/%{_libdir}/lib%{name}.so' +install -d '%{buildroot}/%{_includedir}' +install -m 0644 %{name}.h '%{buildroot}/%{_includedir}' + +%files +%license LICENSE +%doc ChangeLog.md readme.md +%{_libdir}/%{soname} + +%files devel +%doc examples/*.c +%{_includedir}/%{name}.h +%{_libdir}/lib%{name}.so + + +%changelog +* Tue Sep 19 2023 Arkady L. Shane - 2.2.0-2 +- Rebuilt for MSVSphere 9.2 + +* Mon Jan 24 2022 Petr Pisar - 2.2.0-2 +- Fix an unitialized memory in tinfl_decompress_mem_to_callback() (GH#197) +- Fix an unaligned memory access +- Fix setting MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8 +- Fix an undefined behaviour in tinfl_decompress() (GH#216) +- Fix mz_zip_reader_extract_to_heap() to read correct sizes (GH#220) + +* Wed Aug 11 2021 Petr Pisar - 2.2.0-1 +- 2.2.0 bump + +* Thu Jul 22 2021 Fedora Release Engineering - 2.1.0-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Tue Jan 26 2021 Fedora Release Engineering - 2.1.0-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Mon Jan 25 2021 Tom Stellard - 2.1.0-6 +- Use toolchain macro instead of hard-coding gcc + +* Tue Jul 28 2020 Fedora Release Engineering - 2.1.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Wed Jan 29 2020 Fedora Release Engineering - 2.1.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Jul 25 2019 Fedora Release Engineering - 2.1.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Thu May 23 2019 Petr Pisar - 2.1.0-2 +- Remove a dependency on gcc from miniz-devel +- Normalize end-of-lines in a change log + +* Wed May 22 2019 Petr Pisar - 2.1.0-1 +- 2.1.0 bump +- Upstream moved to +- License changed from "Unlicense" to "MIT and Unlicense" +- ABI changed, API preserved + +* Fri Feb 01 2019 Fedora Release Engineering - 1.15-12.r4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Mon Nov 19 2018 Petr Pisar - 1.15-11.r4 +- Fix link order + +* Fri Jul 13 2018 Fedora Release Engineering - 1.15-10.r4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Fri Mar 23 2018 Petr Pisar - 1.15-9.r4 +- Modernize a spec file + +* Thu Feb 08 2018 Fedora Release Engineering - 1.15-8.r4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Thu Aug 03 2017 Fedora Release Engineering - 1.15-7.r4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 1.15-6.r4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Fri Feb 10 2017 Fedora Release Engineering - 1.15-5.r4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Tue Mar 08 2016 Petr Pisar - 1.15-4.r4 +- Correct dependency on libc headers + +* Thu Feb 04 2016 Fedora Release Engineering - 1.15-3.r4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Jun 17 2015 Fedora Release Engineering - 1.15-2.r4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Tue Oct 14 2014 Petr Pisar - 1.15-1.r4 +- 1.15r4 version packaged + +