From c07f28ef16ec5e9a3164fc5bc84a0c6c437ea113 Mon Sep 17 00:00:00 2001 From: Alexander Stefanov Date: Sun, 12 Apr 2020 19:55:36 +0000 Subject: [PATCH] adjust build, use cmake --- pzstd.1.patch | 13 ++-- zstd-1.3.4-multi-thread-default.patch | 13 ++++ zstd.spec | 89 +++++++++++++-------------- 3 files changed, 63 insertions(+), 52 deletions(-) create mode 100644 zstd-1.3.4-multi-thread-default.patch diff --git a/pzstd.1.patch b/pzstd.1.patch index cfe2e45..c0c451a 100644 --- a/pzstd.1.patch +++ b/pzstd.1.patch @@ -1,11 +1,10 @@ -diff -Naur -Naru zstd-1.3.4/programs/zstd.1 zstd-1.3.4.new/programs/zstd.1 ---- zstd-1.3.4/programs/zstd.1 2018-03-26 22:19:34.000000000 +0000 -+++ zstd-1.3.4.new/programs/zstd.1 2018-03-28 04:28:27.532777239 +0000 -@@ -177,7 +177,14 @@ +diff -Naur zstd-1.4.4.orig/programs/zstd.1 zstd-1.4.4/programs/zstd.1 +--- zstd-1.4.4.orig/programs/zstd.1 2019-11-04 17:54:32.000000000 +0000 ++++ zstd-1.4.4/programs/zstd.1 2020-01-15 14:25:34.227060058 +0000 +@@ -209,6 +209,14 @@ .TP \fB\-\-\fR All arguments after \fB\-\-\fR are treated as files --. + +.SH Parallel Zstd OPTIONS +Additional options for the pzstd utility @@ -14,6 +13,6 @@ diff -Naur -Naru zstd-1.3.4/programs/zstd.1 zstd-1.3.4.new/programs/zstd.1 + number of threads to use for (de)compression (default:4) + + - .SH "DICTIONARY BUILDER" - \fBzstd\fR offers \fIdictionary\fR compression, which greatly improves efficiency on small files and messages\. It\'s possible to train \fBzstd\fR with a set of samples, the result of which is saved into a file called a \fBdictionary\fR\. Then during compression and decompression, reference the same dictionary, using command \fB\-D dictionaryFileName\fR\. Compression of small files similar to the sample set will be greatly improved\. . + .SS "Restricted usage of Environment Variables" + Using environment variables to set parameters has security implications\. Therefore, this avenue is intentionally restricted\. Only \fBZSTD_CLEVEL\fR is supported currently, for setting compression level\. \fBZSTD_CLEVEL\fR can be used to set the level between 1 and 19 (the "normal" range)\. If the value of \fBZSTD_CLEVEL\fR is not a valid integer, it will be ignored with a warning message\. \fBZSTD_CLEVEL\fR just replaces the default compression level (\fB3\fR)\. It can be overridden by corresponding command line arguments\. diff --git a/zstd-1.3.4-multi-thread-default.patch b/zstd-1.3.4-multi-thread-default.patch new file mode 100644 index 0000000..025acfd --- /dev/null +++ b/zstd-1.3.4-multi-thread-default.patch @@ -0,0 +1,13 @@ +diff -Naur zstd-1.3.8/programs/zstdcli.c zstd-1.3.8/programs/new-zstdcli.c +--- zstd-1.3.8/programs/zstdcli.c 2018-12-27 13:42:44.000000000 +0100 ++++ zstd-1.3.8/programs/new-zstdcli.c 2019-01-01 04:30:50.000000000 +0100 +@@ -576,7 +576,7 @@ + cLevel = init_cLevel(); + programName = lastNameFromPath(programName); + #ifdef ZSTD_MULTITHREAD +- nbWorkers = 1; ++ nbWorkers = 0; + #endif + + /* preset behaviors */ + diff --git a/zstd.spec b/zstd.spec index 2069e59..35995a7 100644 --- a/zstd.spec +++ b/zstd.spec @@ -2,12 +2,8 @@ %define major 1 %define libname %mklibname %{oname} %{major} %define devname %mklibname %{oname} -d - -# aarch64 and armv7hl at least currently segfault -# in ThreadPool test for the pzstd util -%ifarch %{ix86} x86_64 -%bcond_without pzstd -%endif +# static libraries are used by qemu. Please don't disable them. +%define sdevname %mklibname %{name} -d -s %bcond_with tests @@ -19,30 +15,28 @@ License: BSD and GPLv2+ Group: Archiving/Compression Url: http://www.zstd.net/ Source0: https://github.com/facebook/zstd/archive/v%{version}/%{name}-%{version}.tar.gz +Patch0: zstd-1.3.4-multi-thread-default.patch Patch1: pzstd.1.patch BuildRequires: gtest-devel +BuildRequires: pkgconfig(liblz4) +BuildRequires: pkgconfig(liblzma) +BuildRequires: pkgconfig(zlib) +BuildRequires: cmake +BuildRequires: ninja %description Zstd, short for Zstandard, is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level compression ratio. %files -%doc CHANGELOG README.md %{_bindir}/%{name} %{_bindir}/%{name}cat %{_bindir}/%{name}grep %{_bindir}/%{name}less %{_bindir}/%{name}mt -%if %{with pzstd} %{_bindir}/p%{name} -%{_mandir}/man1/p%{name}.1* -%endif %{_bindir}/un%{name} -%{_mandir}/man1/%{name}.1* -%{_mandir}/man1/%{name}cat.1* -%{_mandir}/man1/%{name}grep.1* -%{_mandir}/man1/%{name}less.1* -%{_mandir}/man1/un%{name}.1* +%{_mandir}/man1/* #---------------------------------------------------------------------------- @@ -68,44 +62,49 @@ Provides: %{name}-devel = %{EVRD} Header files for Zstd library. %files -n %{devname} -%{_includedir}/zbuff.h -%{_includedir}/zdict.h -%{_includedir}/zstd.h -%{_includedir}/zstd_errors.h +%doc %{_docdir}/zstd +%{_includedir}/*.h %{_libdir}/pkgconfig/libzstd.pc %{_libdir}/libzstd.so #---------------------------------------------------------------------------- +%package -n %{sdevname} +Summary: Static libraries for zstd +Group: Development/C +Requires: %{devname} = %{version}-%{release} + +%description -n %{sdevname} +Static library for zstd. + +%files -n %{sdevname} +%{_libdir}/libzstd.a + +#---------------------------------------------------------------------------- + %prep -%setup -q +%autosetup -p1 +# Get rid of -L/usr/lib insanity +sed -i -e 's,-L\${libdir} ,,g' lib/*.pc.in +sed -i -e '/^Cflags:/d' lib/*.pc.in find -name .gitignore -delete -%if %{with pzstd} -%patch1 -p1 -%endif %build -for dir in lib programs; do - CFLAGS="%{optflags}" LDFLAGS="%{ldflags}" %make CC=%{__cc} -C "$dir" -done -%if %{with pzstd} -CFLAGS="%{optflags}" LDFLAGS="%{ldflags}" CXXFLAGS="%{optflags} -std=c++11" %make CC=%{__cc} -C 'contrib/pzstd' -%endif +%set_build_flags +pushd build/cmake +%cmake -DZSTD_BUILD_CONTRIB:BOOL=ON \ + -DZSTD_LEGACY_SUPPORT:BOOL=ON \ + -DZSTD_LZ4_SUPPORT:BOOL=ON \ + -DZSTD_LZMA_SUPPORT:BOOL=ON \ + -DZSTD_PROGRAMS_LINK_SHARED:BOOL=ON \ + -DZSTD_ZLIB_SUPPORT:BOOL=ON -G Ninja + +%ninja_build +popd %install -%makeinstall_std PREFIX=%{_prefix} LIBDIR=%{_libdir} - -# Don't install the static lib -rm %{buildroot}%{_libdir}/libzstd.a -%if %{with pzstd} -install -D -m755 contrib/pzstd/pzstd %{buildroot}%{_bindir}/pzstd -install -D -m644 programs/%{name}.1 %{buildroot}%{_mandir}/man1/p%{name}.1 -%endif - -%if %{with tests} -%check -CFLAGS="%{optflags}" LDFLAGS="%{ldflags}" make -C tests test-zstd -%if %{with pzstd} -CFLAGS="%{optflags}" LDFLAGS="%{ldflags}" CXXFLAGS="%{optflags} -std=c++11" make -C contrib/pzstd test -%endif -%endif +pushd build/cmake +%ninja_install -C build +install -m 755 build/contrib/pzstd/pzstd %{buildroot}%{_bindir}/ +install -D -m644 build/programs/%{name}.1 %{buildroot}%{_mandir}/man1/p%{name}.1 +popd