%global upstream_version 1.5.2-3 %global short_version %(echo %{upstream_version} | sed 's/-.*//') # shared library is an internal file %global __provides_exclude_from \\.so$ Name: zstd-jni Version: %(echo %{upstream_version} | tr - .) Release: 1%{?dist} Summary: JNI bindings for Zstd native library # files in the cleaned tarball are under BSD 2-clause # files included from zstd are dual-licensed under (BSD 3-clause or GPLv2) License: (BSD or GPLv2) and BSD URL: https://github.com/luben/zstd-jni # ./generate-tarball.sh Source0: %{name}-%{version}.tar.gz Source1: https://repo1.maven.org/maven2/com/github/luben/zstd-jni/%{upstream_version}/zstd-jni-%{upstream_version}.pom Source2: zstd-%{short_version}.tar.gz Patch1: 0001-Load-native-library-from-predefined-path.patch BuildRequires: gcc BuildRequires: libzstd-devel # Reason for bundling zstd: # zstd-jni depends on internal headers of the zstd project which are not # provided by zstd-devel package Provides: bundled(zstd) = %{short_version} %description JNI bindings for Zstd native library that provides fast and high compression lossless algorithm for Android, Java and all JVM languages. It features: * static compress/decompress methods * implementation of InputStream and OutputStream for transparent compression of data streams fully compatible with the "zstd" program. * minimal performance overhead %package java License: BSD BuildArch: noarch BuildRequires: maven-local Requires: zstd-jni = %{version}-%{release} ExclusiveArch: %{java_arches} noarch Summary: Java library for %{name} %description java Java library for %{name}. %package javadoc License: BSD BuildArch: noarch Summary: Javadoc for %{name} %description javadoc Javadoc for %{name}. %prep %setup -q -n zstd-jni-%{upstream_version} %patch1 -p1 cp -p %{SOURCE1} pom.xml %pom_remove_dep :scalatest_2.13 %pom_remove_dep :scalacheck_2.13 # special file containing the version cat > src/main/java/com/github/luben/zstd/util/ZstdVersion.java << EOF package com.github.luben.zstd.util; public class ZstdVersion { public static final String VERSION = "%{upstream_version}"; } EOF tar -xf %{SOURCE2} # included zstd license files mv zstd-%{short_version}/LICENSE LICENSE-zstd mv zstd-%{short_version}/COPYING COPYING-zstd %mvn_file : %{name} %build # JNI headers CPATH+=:%{_jvmdir}/java/include:%{_jvmdir}/java/include/linux # bundled libzstd headers CPATH+=:zstd-%{short_version}/lib/common export CPATH %{build_cc} -o libzstd-jni-%{upstream_version}.so -fPIC -shared -lzstd %{build_cflags} %{build_ldflags} src/main/native/*.c # Tests require scala and a package scalatest, which we do not have %mvn_build %install install -D -m 755 -t %{buildroot}%{_prefix}/lib/zstd-jni libzstd-jni-%{upstream_version}.so %mvn_install %files %{_prefix}/lib/zstd-jni/libzstd-jni-%{upstream_version}.so %license LICENSE LICENSE-zstd COPYING-zstd %doc README.md %files java -f .mfiles %license LICENSE %doc README.md %files javadoc -f .mfiles-javadoc %license LICENSE %changelog * Mon May 16 2022 Marian Koncek - 1.5.2.3-1 - Initial release