[Debian-med-packaging] Bug#960654: src:biojava4-live: Please add support to build against libjson-simple-java >= 3

Gilles Filippini pini at debian.org
Fri May 15 08:41:18 BST 2020


Package: src:biojava4-live
Version: 4.2.12+dfsg-2
Severity: normal
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi,

I'd like to transition json-simple 3.1.1 to unstable, but biojava4-live is a blocker since it builds against libjson-simple-java << 3 only.

The json-simple classes used by biojava4-live were deprecated in version 2.0.0 [1]. There were removed in versions 3.x [2].

[1] https://github.com/cliftonlabs/json-simple/blob/json-simple-2.0.0/README.txt
[2] https://github.com/cliftonlabs/json-simple/blob/json-simple-3.0.1/CHANGELOG

Please find attached a patch proposal to use the current json-simple classes. I've tested that the package builds correctly against libjson-simple-java version 2.3.0-1 from unstable and version 3.1.1-1~exp2 currently in experimental, and the build time test cases report no errors.

Thanks in advance for considering.

_g.

- -- System Information:
Debian Release: buster/sid
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.6.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEoJObzArDE05WtIyR7+hsbH/+z4MFAl6+R5UACgkQ7+hsbH/+
z4OOnQgApJ5lITTg7Gdl45fmVHMuVZ7EO8F30UQ8b11IjqC9Jvy5Smxe6QpBr1XO
eeSY1QI8GVFd5OHk31AijdMC/JZTkSwjHAV+R5YODf96D5nnNLb+Se5w3hrzf+hg
/sa/tgya1+1551eK+BJoJX6upyo8Eu1ZWcM4X/2gTqJMuV9yI0u6d2w5pUpfF3Dq
3oVPO+0ZdKuI26roUXLiZUyu7W5DVctqt+JHWYHAxxdiQ2DoxhStK40haZ6km6Ee
xJnSPX472CxArpHZWWeUFOl+9GPT7kN6WGfSgfgzVoAnq5kw0DwspegXykFlLSNT
7VQX8vBOKadHyKQ9QM8DJK+RWJNW5w==
=H6WS
-----END PGP SIGNATURE-----
-------------- next part --------------
diff -Nru biojava4-live-4.2.12+dfsg/debian/changelog biojava4-live-4.2.12+dfsg/debian/changelog
--- biojava4-live-4.2.12+dfsg/debian/changelog	2019-01-18 20:47:46.000000000 +0100
+++ biojava4-live-4.2.12+dfsg/debian/changelog	2020-05-15 08:50:46.000000000 +0200
@@ -1,3 +1,10 @@
+biojava4-live (4.2.12+dfsg-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Tentative fix to build against json-simple 3
+
+ -- Gilles Filippini <pini at debian.org>  Fri, 15 May 2020 08:50:46 +0200
+
 biojava4-live (4.2.12+dfsg-2) unstable; urgency=medium
 
   * Team upload.
diff -Nru biojava4-live-4.2.12+dfsg/debian/patches/use_simple_json biojava4-live-4.2.12+dfsg/debian/patches/use_simple_json
--- biojava4-live-4.2.12+dfsg/debian/patches/use_simple_json	2019-01-18 15:58:37.000000000 +0100
+++ biojava4-live-4.2.12+dfsg/debian/patches/use_simple_json	2020-05-15 08:50:46.000000000 +0200
@@ -2,24 +2,42 @@
 Author: Olivier Sallou <osallou at debian.org>
 Description: json.org library is not "free", use simple_json
  library and update according to API
-Last-Updated: 2012-12-02
-
---- a/biojava-ws/src/main/java/org/biojava/nbio/ws/hmmer/RemoteHmmerScan.java
-+++ b/biojava-ws/src/main/java/org/biojava/nbio/ws/hmmer/RemoteHmmerScan.java
+ .
+ [ Gilles Filippini <pini at debian.org> ]
+ Patche updated to migrate away from deprecated json-simple 1.x classes
+ See json-simple 2.0.0 changelog:
+ > * Deprecated JSONParse and JSONValue in favor of Jsoner.
+ > * Deprecated JSONStreamAware and JSONAware in favor of Jsonable.
+ > * Deprecated JSONObject in favor of JsonObject.
+ > * Deprecated JSONArray in favor of JsonArray.
+ .
+ This patch now uses the new json-simple Json* classes. It is compatible
+ with both 2.x and 3.x json-simple releases, with a few ajustments
+ regarding backward incompatible changes in json-simple 3.x:
+ - The package name, changed to com.github.cliftonlabs.json_simple
+ This change is handled using place-holders @JSON_SIMPLE_PACKAGE@ which
+ are substituted at build time by debian/rules.
+ .
+ With this trick the package is compatible with json-simple 2.x and 3.x.
+Last-Updated: 2020-05-15
+Index: biojava4-live-4.2.12+dfsg/biojava-ws/src/main/java/org/biojava/nbio/ws/hmmer/RemoteHmmerScan.java
+===================================================================
+--- biojava4-live-4.2.12+dfsg.orig/biojava-ws/src/main/java/org/biojava/nbio/ws/hmmer/RemoteHmmerScan.java
++++ biojava4-live-4.2.12+dfsg/biojava-ws/src/main/java/org/biojava/nbio/ws/hmmer/RemoteHmmerScan.java
 @@ -20,8 +20,10 @@
   */
  package org.biojava.nbio.ws.hmmer;
  
 -import net.sf.json.JSONArray;
 -import net.sf.json.JSONObject;
-+import org.json.simple.JSONArray;
-+import org.json.simple.JSONObject;
-+import org.json.simple.JSONValue;
++import @JSON_SIMPLE_PACKAGE at .JsonArray;
++import @JSON_SIMPLE_PACKAGE at .JsonObject;
++import @JSON_SIMPLE_PACKAGE at .Jsoner;
 +
  import org.biojava.nbio.core.sequence.ProteinSequence;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
-@@ -136,15 +138,13 @@
+@@ -136,15 +138,13 @@ public class RemoteHmmerScan implements
  
  		SortedSet<HmmerResult> results = new TreeSet<HmmerResult>();
  		try {
@@ -27,29 +45,29 @@
 -
 -			JSONObject hmresults = json.getJSONObject("results");
 -
-+			JSONObject json= (JSONObject) JSONValue.parse(result.toString());
-+			JSONObject hmresults = (JSONObject) json.get("results");
++			JsonObject json= Jsoner.deserialize(result.toString(), (JsonObject) null);
++			JsonObject hmresults = (JsonObject) json.get("results");
  
 -			JSONArray hits = hmresults.getJSONArray("hits");
-+			JSONArray hits = (JSONArray) hmresults.get("hits");
++			JsonArray hits = (JsonArray) hmresults.get("hits");
  
  			for(int i =0 ; i < hits.size() ; i++){
 -				JSONObject hit = hits.getJSONObject(i);
-+				JSONObject hit = (JSONObject) hits.get(i);
++				JsonObject hit = (JsonObject) hits.get(i);
  
  				HmmerResult hmmResult = new HmmerResult();
  
-@@ -168,11 +168,11 @@
+@@ -168,11 +168,11 @@ public class RemoteHmmerScan implements
  				hmmResult.setPvalue((Double)hit.get("pvalue"));
  				hmmResult.setScore(Float.parseFloat((String)hit.get("score")));
  
 -				JSONArray hmmdomains = hit.getJSONArray("domains");
-+				JSONArray hmmdomains = (JSONArray) hit.get("domains");
++				JsonArray hmmdomains = (JsonArray) hit.get("domains");
  
  				SortedSet<HmmerDomain> domains = new TreeSet<HmmerDomain>();
  				for ( int j= 0 ; j < hmmdomains.size() ; j++){
 -					JSONObject d = hmmdomains.getJSONObject(j);
-+					JSONObject d = (JSONObject) hmmdomains.get(j);
++					JsonObject d = (JsonObject) hmmdomains.get(j);
  					Integer is_included = getInteger(d.get("is_included"));
  					if ( is_included == 0) {
  						continue;
diff -Nru biojava4-live-4.2.12+dfsg/debian/rules biojava4-live-4.2.12+dfsg/debian/rules
--- biojava4-live-4.2.12+dfsg/debian/rules	2019-01-18 18:13:50.000000000 +0100
+++ biojava4-live-4.2.12+dfsg/debian/rules	2020-05-15 08:50:46.000000000 +0200
@@ -8,6 +8,14 @@
 
 JAVA_HOME=/usr/lib/jvm/default-java
 
+JSON_SIMPLE_VERSION = $(shell dpkg -l libjson-simple-java | grep '^ii' | awk '{print $$3}')
+JSON_SIMPLE_3 = $(shell dpkg --compare-versions '$(JSON_SIMPLE_VERSION)' '>' '3.1.1-1~' && echo yes || echo no)
+ifeq (yes,$(JSON_SIMPLE_3))
+JSON_SIMPLE_PACKAGE = com.github.cliftonlabs.json_simple
+else
+JSON_SIMPLE_PACKAGE = org.json.simple
+endif
+
 %:
 	dh $@  --with javahelper
 
@@ -31,6 +39,10 @@
 	sed -e 's/BJLIB/biojava4-jcolorbrewer/g' debian/build.xml > biojava-jcolorbrewer/build.xml
 
 override_dh_auto_build:
+	find . -type f -name \*.java -exec grep -q 'import @JSON_SIMPLE_PACKAGE@' {} \; \
+	  -exec sed -i.json-simple \
+		    -e 's, at JSON_SIMPLE_PACKAGE@,$(JSON_SIMPLE_PACKAGE),' \
+		    {} \; -print
 	cd biojava-jcolorbrewer && ant jar
 	cd biojava-forester && ant jar
 	cd biojava-core && ant jar
@@ -102,6 +114,8 @@
 	rm -rf doc
 	find . -name "*.class" -delete
 	rm -rf buildtest
+	find . -type f -name \*.java.json-simple \
+	  -exec sh -c 'file={} && mv $$file $${file%.json-simple}' \; -print
 
 get-orig-source:
 	debian/get-orig-source


More information about the Debian-med-packaging mailing list