Package Init

Signed-off-by: eulerstorage <eulerstorage@huawei.com>
This commit is contained in:
eulerstorage 2019-12-17 17:20:36 +08:00
parent 45bdb2369c
commit 8bebfc7b77
5 changed files with 190 additions and 0 deletions

8
CheckLibrary.java Normal file
View File

@ -0,0 +1,8 @@
import org.apache.tomcat.jni.Library;
public class CheckLibrary {
public static void main(String[] a) throws Exception{
Library.initialize(null);
}
}

40
fixLibNames.patch.in Normal file
View File

@ -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<paths.length; j++) {
- java.io.File fd = new java.io.File(paths[j] , name);
+ java.io.File fd = new java.io.File(name);
if (fd.exists()) {
t.printStackTrace();
}
- }
if ( i > 0)
err.append(", ");
err.append(t.getMessage());

12
i388aprFix.patch Normal file
View File

@ -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)

Binary file not shown.

130
netty-tcnative.spec Normal file
View File

@ -0,0 +1,130 @@
%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}
%%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 <hu.huyan@huawei.com> - 1.1.30-13
- Package Initialization