diff --git a/CheckLibrary.java b/CheckLibrary.java new file mode 100644 index 0000000..2d2e942 --- /dev/null +++ b/CheckLibrary.java @@ -0,0 +1,8 @@ +import org.apache.tomcat.jni.Library; + +public class CheckLibrary { + + public static void main(String[] a) throws Exception{ + Library.initialize(null); + } +} diff --git a/fixLibNames.patch.in b/fixLibNames.patch.in new file mode 100644 index 0000000..42627cb --- /dev/null +++ b/fixLibNames.patch.in @@ -0,0 +1,40 @@ +--- netty-tcnative-netty-tcnative-1.1.30.Fork2/src/main/java/org/apache/tomcat/jni/Library (copy).java ++++ netty-tcnative-netty-tcnative-1.1.30.Fork2/src/main/java/org/apache/tomcat/jni/Library.java +@@ -24,7 +24,7 @@ + public final class Library { + + /* Default library names */ +- private static final String [] NAMES = {"tcnative-1", "libtcnative-1"}; ++ private static final String [] NAMES = {"netty-tcnative", "libnetty-tcnative", "netty-tcnative-1", "libnetty-tcnative-1"}; + /* + * A handle to the unique Library singleton instance. + */ +@@ -36,8 +36,9 @@ + boolean loaded = false; + StringBuilder err = new StringBuilder(); + for (int i = 0; i < NAMES.length; i++) { ++ String name = "@PATH@/" + NAMES[i] + ".so"; + try { +- System.loadLibrary(NAMES[i]); ++ System.load(name); + loaded = true; + } + catch (Throwable t) { +@@ -47,16 +48,10 @@ + if (t instanceof VirtualMachineError) { + throw (VirtualMachineError) t; + } +- String name = System.mapLibraryName(NAMES[i]); +- String path = System.getProperty("java.library.path"); +- String sep = System.getProperty("path.separator"); +- String [] paths = path.split(sep); +- for (int j=0; j 0) + err.append(", "); + err.append(t.getMessage()); diff --git a/i388aprFix.patch b/i388aprFix.patch new file mode 100644 index 0000000..a0d17b4 --- /dev/null +++ b/i388aprFix.patch @@ -0,0 +1,12 @@ +--- netty-tcnative-netty-tcnative-1.1.30.Fork2/src/main/native-package/m4/custom.m4 ++++ netty-tcnative-netty-tcnative-1.1.30.Fork2/src/main/native-package/m4/custom.m4 +@@ -47,7 +47,7 @@ + fi + + dnl Update the compiler/linker flags to add APR and OpenSSL to the build path. +- CFLAGS="$CFLAGS $TCN_OPENSSL_INC $APR_INCLUDES" ++ CFLAGS="$CFLAGS $TCN_OPENSSL_INC $APR_INCLUDES -D_LARGEFILE64_SOURCE" + CXXFLAGS="$CXXFLAGS $TCN_OPENSSL_INC $APR_INCLUDES" + LDFLAGS="$LDFLAGS $TCN_OPENSSL_LIBS $APR_LIBS" + AC_SUBST(CFLAGS) + diff --git a/netty-tcnative-1.1.30.Fork2.tar.gz b/netty-tcnative-1.1.30.Fork2.tar.gz new file mode 100644 index 0000000..ba6f509 Binary files /dev/null and b/netty-tcnative-1.1.30.Fork2.tar.gz differ diff --git a/netty-tcnative.spec b/netty-tcnative.spec new file mode 100644 index 0000000..2ac0358 --- /dev/null +++ b/netty-tcnative.spec @@ -0,0 +1,68 @@ +%global name_reltag .Fork2 +%global name_ver %{version}%{name_reltag} + +Name: netty-tcnative +Version: 1.1.30 +Release: 13 +Summary: Fork of Tomcat Native with improved OpenSSL and mavenized build +License: ASL 2.0 +URL: https://github.com/netty/netty/wiki/Forked-Tomcat-Native +Source0: https://github.com/netty/netty-tcnative/archive/%{name}-%{name_ver}.tar.gz +Source1: CheckLibrary.java +Patch1: i388aprFix.patch +Patch2: fixLibNames.patch.in + +BuildRequires: apr-devel autoconf automake compat-openssl10-devel glibc-devel +BuildRequires: libtool maven-antrun-plugin maven-hawtjni-plugin maven-local +BuildRequires: maven-plugin-build-helper maven-plugin-bundle +BuildRequires: maven-remote-resources-plugin maven-source-plugin netty +BuildRequires: sonatype-oss-parent +BuildRequires: mvn(kr.motd.maven:os-maven-plugin) + +Provides: netty-tcnative-javadoc +Obsoletes: netty-tcnative-javadoc + +%description +netty-tcnative is a fork of Tomcat Native. It includes a set of changes +contributed by Twitter, Inc, such as: + * Simplified distribution and linkage of native library + * Complete mavenization of the project + * Improved OpenSSL support +To minimize the maintenance burden, we create a dedicated branch for each stable +upstream release and apply our own changes on top of it, while keeping the +number of maintained branches to minimum + + +%prep +%setup -q -n %{name}-%{name}-%{name_ver} +%patch1 -p1 +patch=`mktemp` +sed "s;@PATH@;%{_libdir}/%{name};g" < %{PATCH2} > $patch +patch -p1 < $patch + + +%build +%set_build_flags +%mvn_build -f + +%install +%mvn_install +mkdir -p %{buildroot}%{_libdir}/%{name}/ +cp target/native-build/target/lib/lib%{name}-%{name_ver}.so %{buildroot}%{_libdir}/%{name}/lib%{name}.so + + +%check +javac -d . -cp %{buildroot}%{_jnidir}/%{name}/%{name}.jar %{SOURCE1} + + +%files -f .mfiles +%doc %{_javadocdir}/%{name} +%dir %{_jnidir}/%{name} +%dir %{_libdir}/%{name} +%dir %{_mavenpomdir}/%{name} +%{_libdir}/%{name}/lib%{name}.so + + +%changelog +* Fri Dec 6 2019 huyan - 1.1.30-13 +- Package Initialization