[libnative-platform-java] 01/01: Import work from gil <puntogil at libero.it>. Thanks!

Damien Raude-Morvan drazzib at moszumanska.debian.org
Sun Jan 19 13:53:02 UTC 2014


This is an automated email from the git hooks/post-receive script.

drazzib pushed a commit to branch master
in repository libnative-platform-java.

commit 36cf0d9dc5df96d2138de30f9066134816002515
Author: Damien Raude-Morvan <drazzib at debian.org>
Date:   Sat Jan 18 16:38:00 2014 +0100

    Import work from gil <puntogil at libero.it>. Thanks!
---
 debian/changelog                                  | 13 +++++
 debian/control                                    |  2 +-
 debian/libnative-platform-java-doc.doc-base       |  9 ++++
 debian/patches/libname.diff                       | 59 ++++++++++++++++++-----
 debian/patches/make_buildsystem.diff              | 42 ++++++++++------
 debian/patches/native_locator_usr_lib_first.patch | 23 +++++----
 debian/rules                                      |  3 ++
 7 files changed, 114 insertions(+), 37 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 98924b5..dcd9a4c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,16 @@
+libnative-platform-java (0.3~rc2-3) unstable; urgency=medium
+
+  * d/patches/native_locator_usr_lib_first.patch: Use java.library.path
+    to scan for library path instead of hardcoded /usr/lib/jni/
+    It should support Multi-Arch paths.
+  * d/patches/libname.diff: Drop Linux32Bit / Linux64Bit because system
+    libraries are always named same under Linux.
+  * Makefile: Import work from gil cattaneo <puntogil at libero.it> which
+    provide better support for Linux-*. Thanks!
+  * d/control: Update Standards-Version to 3.9.5 (no changes needed)
+
+ -- Damien Raude-Morvan <drazzib at debian.org>  Sun, 19 Jan 2014 11:00:24 +0100
+
 libnative-platform-java (0.3~rc2-2) unstable; urgency=low
 
   * Upload to unstable.
diff --git a/debian/control b/debian/control
index b6fa374..c1a7150 100644
--- a/debian/control
+++ b/debian/control
@@ -9,7 +9,7 @@ Build-Depends: ant,
                libjoptsimple-java,
                libncurses5-dev,
                maven-repo-helper (>= 1.5~)
-Standards-Version: 3.9.4
+Standards-Version: 3.9.5
 Homepage: https://github.com/adammurdoch/native-platform
 Vcs-Git: git://anonscm.debian.org/pkg-java/libnative-platform-java.git
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-java/libnative-platform-java.git
diff --git a/debian/libnative-platform-java-doc.doc-base b/debian/libnative-platform-java-doc.doc-base
new file mode 100644
index 0000000..e70ff27
--- /dev/null
+++ b/debian/libnative-platform-java-doc.doc-base
@@ -0,0 +1,9 @@
+Document: libnative-platform-java-doc
+Title: API Javadoc for Native Platform
+Author: Adam Murdock
+Abstract: This is the API Javadoc provided by the Native Platform library.
+Section: Programming
+
+Format: HTML
+Index: /usr/share/doc/libnative-platform-java/api/index.html
+Files: /usr/share/doc/libnative-platform-java/api/*.html
\ No newline at end of file
diff --git a/debian/patches/libname.diff b/debian/patches/libname.diff
index 4de02c8..6cea2da 100644
--- a/debian/patches/libname.diff
+++ b/debian/patches/libname.diff
@@ -1,21 +1,54 @@
+Description: Library name is always stable under Debian GNU/Linux
+ when shared object is installed into /usr/lib/jni/
+ So remove Linux32Bit / Linux64Bit handling.
+Author: Damien Raude-Morvan <drazzib at debian.org>
+Last-Update: 2014-01-19
+Forwarded: not-needed
 --- a/src/main/java/net/rubygrapefruit/platform/internal/Platform.java
 +++ b/src/main/java/net/rubygrapefruit/platform/internal/Platform.java
-@@ -168,24 +168,24 @@
-     private static class Linux32Bit extends Linux {
-         @Override
-         public String getLibraryName() {
--            return "libnative-platform-linux-i386.so";
-+            return "libnative-platform.so";
-         }
+@@ -37,12 +37,7 @@
+                         platform = new Window64Bit();
+                     }
+                 } else if (osName.contains("linux")) {
+-                    if (arch.equals("amd64")) {
+-                        platform = new Linux64Bit();
+-                    }
+-                    else if (arch.equals("i386") || arch.equals("x86")) {
+-                        platform = new Linux32Bit();
+-                    }
++                        platform = new Linux();
+                 } else if (osName.contains("os x")) {
+                     if (arch.equals("i386") || arch.equals("x86_64") || arch.equals("amd64")) {
+                         platform = new OsX();
+@@ -155,7 +150,7 @@
+     private abstract static class Unix extends Posix {
+     }
  
+-    private abstract static class Linux extends Unix {
++    private static class Linux extends Unix {
          @Override
-         String getCursesLibraryName() {
--            return "libnative-platform-curses-linux-i386.so";
-+            return "libnative-platform.so";
+         public <T extends NativeIntegration> T get(Class<T> type, NativeLibraryLoader nativeLibraryLoader) {
+             if (type.equals(FileSystems.class)) {
+@@ -163,29 +158,15 @@
+             }
+             return super.get(type, nativeLibraryLoader);
          }
-     }
- 
-     private static class Linux64Bit extends Linux {
+-    }
+-
+-    private static class Linux32Bit extends Linux {
+-        @Override
+-        public String getLibraryName() {
+-            return "libnative-platform-linux-i386.so";
+-        }
+-
+-        @Override
+-        String getCursesLibraryName() {
+-            return "libnative-platform-curses-linux-i386.so";
+-        }
+-    }
+-
+-    private static class Linux64Bit extends Linux {
++        
          @Override
          public String getLibraryName() {
 -            return "libnative-platform-linux-amd64.so";
diff --git a/debian/patches/make_buildsystem.diff b/debian/patches/make_buildsystem.diff
index a50b9d3..5b89301 100644
--- a/debian/patches/make_buildsystem.diff
+++ b/debian/patches/make_buildsystem.diff
@@ -1,13 +1,25 @@
 Description: Use make as buildsystem instead of Gradle to
  avoid a circular dependencies between gradle and native-platform.
- This is very minimalistic Makefile so it will only work for
- Debian use case for now.
 Author: Damien Raude-Morvan <drazzib at debian.org>
-Last-Update: 2013-01-12
+Author: gil cattaneo <puntogil at libero.it>
+Last-Update: 2014-01-19
 Forwarded: no
 --- /dev/null
 +++ b/Makefile
-@@ -0,0 +1,66 @@
+@@ -0,0 +1,81 @@
++#  Description: Use make as buildsystem instead of Gradle to
++#  avoid a circular dependencies between gradle and native-platform.
++#  This is very minimalistic Makefile so it will only work for
++#  Debian use case for now.
++#  Author: Damien Raude-Morvan <drazzib at debian.org>
++#  Adapted for Fedora by: gil cattaneo <puntogil at libero.it>
++CXX ?= g++
++STRIP ?= strip
++JAVA_HOME ?= /usr/lib/default-java
++JOPT_JAR ?= $(shell locate jopt-simple.jar)
++JTARGET ?= 1.5
++JSOURCE ?= 1.5
++
 +IDIR=src/main/headers
 +SRCDIR=src/main/cpp
 +JSRCDIR=src/main/java
@@ -17,12 +29,9 @@ Forwarded: no
 +JDOCDIR=$(BUILD)/docs/javadoc
 +ODIR=$(BUILD)/binaries
 +JAR=$(BUILD)/native-platform.jar
++JAR_ARCH=$(BUILD)/native-platform-linux.jar
 +
-+JTARGET=1.5
-+JSOURCE=1.5
-+
-+INCLUDE=-I$(IDIR) -I$(IGEN) -I/usr/include -I/usr/lib/jvm/default-java/include
-+#LDLIBS=-lncurses
++INCLUDE=-I$(IDIR) -I$(IGEN) -I/usr/include -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
 +
 +_OBJ_STD = generic.o generic_posix.o linux.o osx.o posix.o win.o
 +_OBJ_CURSES = generic.o generic_posix.o curses.o
@@ -32,29 +41,34 @@ Forwarded: no
 +
 +.PHONY: clean jar javadoc
 +
-+build: $(ODIR)/libnative-platform.so $(ODIR)/libnative-platform-curses.so jar javadoc
++build: $(ODIR)/libnative-platform.so $(ODIR)/libnative-platform-curses.so jar javadoc arch-jar
 +
 +$(ODIR)/libnative-platform.so: $(OBJ_STD)
-+	$(CXX) $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -o $@ $^
++	$(CXX) -shared -fPIC $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^
++	$(STRIP) $@
 +
 +$(ODIR)/libnative-platform-curses.so: $(OBJ_CURSES)
-+	$(CXX) $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -lcurses -shared -o $@ $^
++	$(CXX) $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -lcurses -shared -fPIC -o $@ $^
++	$(STRIP) $@
 +
 +$(JCLASSESDIR)/%.class: javafiles-list
 +	mkdir -p $(JCLASSESDIR)
-+	$(JAVA_HOME)/bin/javac -source $(JTARGET) -target $(JSOURCE) -d $(JCLASSESDIR) -classpath /usr/share/java/joptsimple.jar @javafiles-list
++	$(JAVA_HOME)/bin/javac -source $(JTARGET) -target $(JSOURCE) -d $(JCLASSESDIR) -classpath $(JOPT_JAR) @javafiles-list
 +
 +javafiles-list: $(_JAVA)
 +	echo $^ > javafiles-list
 +
 +javadoc: javafiles-list
 +	mkdir -p $(JDOCDIR)
-+	$(JAVA_HOME)/bin/javadoc -d $(JDOCDIR) -classpath /usr/share/java/joptsimple.jar @javafiles-list
++	$(JAVA_HOME)/bin/javadoc -d $(JDOCDIR) -classpath $(JOPT_JAR) @javafiles-list
 +
 +jar: $(JCLASSESDIR)/%.class
 +	mkdir -p $(JDOCDIR)
 +	(cd $(JCLASSESDIR) ; $(JAVA_HOME)/bin/jar cf ../../$(JAR) .)
 +
++arch-jar: $(ODIR)/libnative-platform.so $(ODIR)/libnative-platform-curses.so
++	(cd $(ODIR) ; $(JAVA_HOME)/bin/jar cf ../../$(JAR_ARCH) *.so)
++
 +$(ODIR)/%.o: $(SRCDIR)/%.cpp $(IGEN)/native.h
 +	mkdir -p $(ODIR)
 +	$(CXX) $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(INCLUDE) -fPIC -c -o $@ $<
diff --git a/debian/patches/native_locator_usr_lib_first.patch b/debian/patches/native_locator_usr_lib_first.patch
index c1c4d7d..8200ba6 100644
--- a/debian/patches/native_locator_usr_lib_first.patch
+++ b/debian/patches/native_locator_usr_lib_first.patch
@@ -1,20 +1,25 @@
-Description: Try to load native library first from /usr/lib/jni
+Description: Try to load native library [java.library.path]/libnative-platform.so first
  instead of extractDir or classpath.
+ It will load first file matching expected name for paths listed in java.library.path
 Author: Damien Raude-Morvan <drazzib at debian.org>
-Last-Update: 2013-01-12
+Last-Update: 2014-01-19
 Forwarded: no
 --- a/src/main/java/net/rubygrapefruit/platform/internal/NativeLibraryLocator.java
 +++ b/src/main/java/net/rubygrapefruit/platform/internal/NativeLibraryLocator.java
-@@ -31,6 +31,13 @@
+@@ -31,6 +31,17 @@
      }
  
      public File find(String libraryFileName) throws IOException {
-+        // Try to load /usr/lib/jni/libnative-platform.so first
-+        // before extractDir or classpath
-+        File usrLibFile = new File("/usr/lib/jni/" + libraryFileName);
-+        if (usrLibFile.isFile()) {
-+            return usrLibFile;
-+        }
++	// Try to load from [java.library.path]/libnative-platform.so first
++	// before extractDir or classpath
++	String[] libPaths = System.getProperty("java.library.path").split(java.io.File.pathSeparator);
++	for (String libPath : libPaths) {
++	  // For each JNI path, try to load lib
++	  File libFile = new File(libPath, libraryFileName);
++	  if (libFile.isFile()) {
++	      return libFile;
++	  }
++	}
 +
          if (extractDir != null) {
              File libFile = new File(extractDir, String.format("%s/%s", NativeLibraryFunctions.VERSION, libraryFileName));
diff --git a/debian/rules b/debian/rules
index 7993f83..445c388 100755
--- a/debian/rules
+++ b/debian/rules
@@ -10,6 +10,9 @@ INDEP_DIR := net/rubygrapefruit/native-platform
 %:
 	dh $@ --with maven_repo_helper
 
+override_dh_auto_build:
+	dh_auto_build -- JAVA_HOME=$(JAVA_HOME) JOPT_JAR=/usr/share/java/joptsimple.jar
+
 override_dh_auto_install:
 	dh_install -plibnative-platform-jni build/binaries/libnative-platform*.so /usr/lib/jni/
 	dh_install -plibnative-platform-java-doc build/docs/javadoc/* /usr/share/doc/libnative-platform-java/api/

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libnative-platform-java.git



More information about the pkg-java-commits mailing list