Patchwork [3/3] pi4j: new package

login
register
mail settings
Submitter Lucas De Marchi
Date Jan. 10, 2014, 7:50 p.m.
Message ID <1389383422-29665-3-git-send-email-lucas.de.marchi@gmail.com>
Download mbox | patch
Permalink /patch/309378/
State Rejected
Headers show

Comments

Lucas De Marchi - Jan. 10, 2014, 7:50 p.m.
Add pi4j using its released binaries. The java archives are a bit
different than other packages. Since they are coming already
pre-compiled put them in /opt with the same layout as in raspbian,
according to http://pi4j.com/install.html

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
---
 package/Config.in      |  1 +
 package/pi4j/Config.in | 10 ++++++++++
 package/pi4j/pi4j.mk   | 30 ++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+)
 create mode 100644 package/pi4j/Config.in
 create mode 100644 package/pi4j/pi4j.mk
Thomas Petazzoni - Jan. 11, 2014, 6:40 a.m.
Dear Lucas De Marchi,

On Fri, 10 Jan 2014 17:50:22 -0200, Lucas De Marchi wrote:

> Add pi4j using its released binaries. The java archives are a bit
> different than other packages. Since they are coming already
> pre-compiled put them in /opt with the same layout as in raspbian,
> according to http://pi4j.com/install.html

I think this is quite certainly the first Java library for which we
have a package. Which JVM are you using to run this on the target? The
official Oracle JDK?

I think this package, like Python/Lua/Perl packages, should depend on
the selection of a JVM, be it the official Oracle JDK (for which a
package would have to be created), or JamVM, if this package is
actually compatible with it.

Regarding the installation in /opt, I'm not sure. The fact that
Raspbian installs it here is not that much of an argument to me (quite
the opposite, actually!).

On Ubuntu, the Java libraries are apparently installed
in /usr/share/java/, which seems a bit more sensible to me. The JNI
parts are installed in /usr/lib/jni/. See:

$ dpkg -L librxtx-java
[... skip documentation ...]
/usr/share/java
/usr/share/java/RXTXcomm-2.2pre2.jar
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/librxtx-java
/usr/lib
/usr/lib/jni
/usr/lib/jni/librxtxRaw-2.2pre1.so
/usr/lib/jni/librxtxI2C-2.2pre1.so
/usr/lib/jni/librxtxRS485-2.2pre1.so
/usr/lib/jni/librxtxSerial-2.2pre1.so
/usr/lib/jni/librxtxParallel-2.2pre1.so
/usr/share/java/RXTXcomm.jar
/usr/lib/jni/librxtxSerial.so
/usr/lib/jni/librxtxRS485.so
/usr/lib/jni/librxtxI2C.so
/usr/lib/jni/librxtxParallel.so
/usr/lib/jni/librxtxRaw.so


> diff --git a/package/pi4j/Config.in b/package/pi4j/Config.in
> new file mode 100644
> index 0000000..99736bf
> --- /dev/null
> +++ b/package/pi4j/Config.in
> @@ -0,0 +1,10 @@
> +config BR2_PACKAGE_PI4J
> +	bool "pi4j"
> +	depends on BR2_PACKAGE_RPI_USERLAND

Why this dependency?

As stated above, we should ensure that a JVM is selected here.

> +define PI4J_INSTALL_TARGET_CMDS
> +	$(INSTALL) -D -m 0644 $(@D)/lib/pi4j-core.jar \
> +		$(TARGET_DIR)/opt/pi4j/lib/pi4j-core.jar
> +	$(INSTALL) -D -m 0644 $(@D)/lib/pi4j-device.jar \
> +		$(TARGET_DIR)/opt/pi4j/lib/pi4j-device.jar
> +	$(INSTALL) -D -m 0644 $(@D)/lib/pi4j-example.jar \
> +		$(TARGET_DIR)/opt/pi4j/lib/pi4j-example.jar
> +	$(INSTALL) -D -m 0644 $(@D)/lib/pi4j-gpio-extension.jar \
> +		$(TARGET_DIR)/opt/pi4j/lib/pi4j-extension.jar
> +	$(INSTALL) -D -m 0644 $(@D)/lib/pi4j-service.jar \
> +		$(TARGET_DIR)/opt/pi4j/lib/pi4j-service.jar
> +endef

This can probably be improved a little bit:

PI4J_LIBS = core device example extension service

define PI4J_INSTALL_TARGET_CMDS
	$(foreach lib,$(PI4J_LIBS),\
		$(INSTALL) -D -m 0644 $(@D)/lib/pi4j-$(lib).jar $(TARGET_DIR)/opt/pi4j/lib/pi4j-$(lib).jar)
endef

Thanks!

Thomas
Lucas De Marchi - Jan. 11, 2014, 12:27 p.m.
On Sat, Jan 11, 2014 at 4:40 AM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Lucas De Marchi,
>
> On Fri, 10 Jan 2014 17:50:22 -0200, Lucas De Marchi wrote:
>
>> Add pi4j using its released binaries. The java archives are a bit
>> different than other packages. Since they are coming already
>> pre-compiled put them in /opt with the same layout as in raspbian,
>> according to http://pi4j.com/install.html
>
> I think this is quite certainly the first Java library for which we
> have a package. Which JVM are you using to run this on the target? The
> official Oracle JDK?

I'm using the official Oracle JDK. However I think we are not allowed
to distribute it or make "recipes" to distribute it as part of
buildroot, are we? Its license looks really restrictive. My current
approach for the rootfs I'm building for a friend of mine is to
install the Oracle jdk by using a overlay directory in buildroot.  Do
you think it would be possible to add the oracle jdk to buildroot?

>
> I think this package, like Python/Lua/Perl packages, should depend on
> the selection of a JVM, be it the official Oracle JDK (for which a
> package would have to be created), or JamVM, if this package is
> actually compatible with it.
>
> Regarding the installation in /opt, I'm not sure. The fact that
> Raspbian installs it here is not that much of an argument to me (quite
> the opposite, actually!).

I put it there actually because it's a pre-compiled thing.

>
> On Ubuntu, the Java libraries are apparently installed
> in /usr/share/java/, which seems a bit more sensible to me. The JNI
> parts are installed in /usr/lib/jni/. See:
>
> $ dpkg -L librxtx-java
> [... skip documentation ...]
> /usr/share/java
> /usr/share/java/RXTXcomm-2.2pre2.jar
> /usr/share/lintian
> /usr/share/lintian/overrides
> /usr/share/lintian/overrides/librxtx-java
> /usr/lib
> /usr/lib/jni
> /usr/lib/jni/librxtxRaw-2.2pre1.so
> /usr/lib/jni/librxtxI2C-2.2pre1.so
> /usr/lib/jni/librxtxRS485-2.2pre1.so
> /usr/lib/jni/librxtxSerial-2.2pre1.so
> /usr/lib/jni/librxtxParallel-2.2pre1.so
> /usr/share/java/RXTXcomm.jar
> /usr/lib/jni/librxtxSerial.so
> /usr/lib/jni/librxtxRS485.so
> /usr/lib/jni/librxtxI2C.so
> /usr/lib/jni/librxtxParallel.so
> /usr/lib/jni/librxtxRaw.so
>
>
>> diff --git a/package/pi4j/Config.in b/package/pi4j/Config.in
>> new file mode 100644
>> index 0000000..99736bf
>> --- /dev/null
>> +++ b/package/pi4j/Config.in
>> @@ -0,0 +1,10 @@
>> +config BR2_PACKAGE_PI4J
>> +     bool "pi4j"
>> +     depends on BR2_PACKAGE_RPI_USERLAND
>
> Why this dependency?

the same as for wiringpi. This package is specific to rpi and doesn't
make sense on other platforms.

>
> As stated above, we should ensure that a JVM is selected here.
>
>> +define PI4J_INSTALL_TARGET_CMDS
>> +     $(INSTALL) -D -m 0644 $(@D)/lib/pi4j-core.jar \
>> +             $(TARGET_DIR)/opt/pi4j/lib/pi4j-core.jar
>> +     $(INSTALL) -D -m 0644 $(@D)/lib/pi4j-device.jar \
>> +             $(TARGET_DIR)/opt/pi4j/lib/pi4j-device.jar
>> +     $(INSTALL) -D -m 0644 $(@D)/lib/pi4j-example.jar \
>> +             $(TARGET_DIR)/opt/pi4j/lib/pi4j-example.jar
>> +     $(INSTALL) -D -m 0644 $(@D)/lib/pi4j-gpio-extension.jar \
>> +             $(TARGET_DIR)/opt/pi4j/lib/pi4j-extension.jar
>> +     $(INSTALL) -D -m 0644 $(@D)/lib/pi4j-service.jar \
>> +             $(TARGET_DIR)/opt/pi4j/lib/pi4j-service.jar
>> +endef
>
> This can probably be improved a little bit:
>
> PI4J_LIBS = core device example extension service
>
> define PI4J_INSTALL_TARGET_CMDS
>         $(foreach lib,$(PI4J_LIBS),\
>                 $(INSTALL) -D -m 0644 $(@D)/lib/pi4j-$(lib).jar $(TARGET_DIR)/opt/pi4j/lib/pi4j-$(lib).jar)
> endef
>
> Thanks!

ok, thanks.

Lucas De Marchi
Thomas Petazzoni - Jan. 13, 2014, 8:02 a.m.
Dear Lucas De Marchi,

On Sat, 11 Jan 2014 10:27:41 -0200, Lucas De Marchi wrote:

> > I think this is quite certainly the first Java library for which we
> > have a package. Which JVM are you using to run this on the target? The
> > official Oracle JDK?
> 
> I'm using the official Oracle JDK. However I think we are not allowed
> to distribute it or make "recipes" to distribute it as part of
> buildroot, are we? Its license looks really restrictive. My current
> approach for the rootfs I'm building for a friend of mine is to
> install the Oracle jdk by using a overlay directory in buildroot.  Do
> you think it would be possible to add the oracle jdk to buildroot?

I haven't looked at the licensing details, but it would be worth
checking this. I know that some time ago, Debian had a package for the
JVM, which was downloading it from Sun (back in the days).

> > Regarding the installation in /opt, I'm not sure. The fact that
> > Raspbian installs it here is not that much of an argument to me (quite
> > the opposite, actually!).
> 
> I put it there actually because it's a pre-compiled thing.

Still, my feeling is that /usr/share/java is a better location.

> >> diff --git a/package/pi4j/Config.in b/package/pi4j/Config.in
> >> new file mode 100644
> >> index 0000000..99736bf
> >> --- /dev/null
> >> +++ b/package/pi4j/Config.in
> >> @@ -0,0 +1,10 @@
> >> +config BR2_PACKAGE_PI4J
> >> +     bool "pi4j"
> >> +     depends on BR2_PACKAGE_RPI_USERLAND
> >
> > Why this dependency?
> 
> the same as for wiringpi. This package is specific to rpi and doesn't
> make sense on other platforms.

But you can perfectly use the Rasberry Pi without rpi-userland.
rpi-userland is just the binary blobs for OpenGL and al.

Just make this dependency a dependency on BR2_arm.

Best regards,

Thomas

Patch

diff --git a/package/Config.in b/package/Config.in
index 748ddbf..ea4556f 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -579,6 +579,7 @@  source "package/mtdev/Config.in"
 source "package/ne10/Config.in"
 source "package/neardal/Config.in"
 source "package/pcsc-lite/Config.in"
+source "package/pi4j/Config.in"
 source "package/tslib/Config.in"
 source "package/urg/Config.in"
 source "package/wiringpi/Config.in"
diff --git a/package/pi4j/Config.in b/package/pi4j/Config.in
new file mode 100644
index 0000000..99736bf
--- /dev/null
+++ b/package/pi4j/Config.in
@@ -0,0 +1,10 @@ 
+config BR2_PACKAGE_PI4J
+	bool "pi4j"
+	depends on BR2_PACKAGE_RPI_USERLAND
+	help
+	  This package is intended to provide a bridge between the native
+	  libraries and Java for full access to the Raspberry Pi.
+
+	  It installs the pre-compiled library from the released pi4j tarball.
+
+	  http://pi4j.com/
diff --git a/package/pi4j/pi4j.mk b/package/pi4j/pi4j.mk
new file mode 100644
index 0000000..38f2926
--- /dev/null
+++ b/package/pi4j/pi4j.mk
@@ -0,0 +1,30 @@ 
+################################################################################
+#
+# pi4j
+#
+################################################################################
+
+PI4J_VERSION = 0.0.5
+PI4J_SITE = http://pi4j.googlecode.com/files/
+PI4J_SOURCE = pi4j-$(PI4J_VERSION).zip
+PI4J_LICENSE = Apache-v2
+PI4J_LICENSE_FILES = LICENSE.txt
+
+define PI4J_EXTRACT_CMDS
+	unzip -q -d $(@D)/../ $(DL_DIR)/$(PI4J_SOURCE)
+endef
+
+define PI4J_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 0644 $(@D)/lib/pi4j-core.jar \
+		$(TARGET_DIR)/opt/pi4j/lib/pi4j-core.jar
+	$(INSTALL) -D -m 0644 $(@D)/lib/pi4j-device.jar \
+		$(TARGET_DIR)/opt/pi4j/lib/pi4j-device.jar
+	$(INSTALL) -D -m 0644 $(@D)/lib/pi4j-example.jar \
+		$(TARGET_DIR)/opt/pi4j/lib/pi4j-example.jar
+	$(INSTALL) -D -m 0644 $(@D)/lib/pi4j-gpio-extension.jar \
+		$(TARGET_DIR)/opt/pi4j/lib/pi4j-extension.jar
+	$(INSTALL) -D -m 0644 $(@D)/lib/pi4j-service.jar \
+		$(TARGET_DIR)/opt/pi4j/lib/pi4j-service.jar
+endef
+
+$(eval $(generic-package))