Here is an updated patch, using maven-repo-helper to do all the heavy
lifting, as typically done for java libraries :)

Please note that to build with the package you pointed me to, in a clean
schroot, I had to add "groff" to the Build-Depends.

Maybe that was fixed before you uploaded to Debian? Otherwise I fear you
might get a FTBFS from the buildd.

On 2020-12-19 17 h 32, Santiago Vila wrote:
>> Would it be possible to also install it in /usr/share/maven-repo? The
>> jar not being present there makes it very hard for me to use gettex in
>> Clojure packages that build using leiningen, as it only looks at
>> /usr/share/maven-repo.
> 
> This is a little bit strange. I guess the file is in /usr/share/java
> because Debian Policy says so. Has Policy changed lately?
> 
> Why would it need to be somewhere else?
> Alternatively: Why would we need to have it in two places at the same time?
> 
> Could it be that some package (not gettext) is not following policy?>
> I have read the maven url that you provided, but still do not
> fully understand this.
> 
>> I know other tools like Gradle also expect artifacts to be installed there.
> 
> Same question for those.
It's not really a question of policy, more of tooling. The Java world
uses a lot of different tools, and some of them only look at files in
/usr/share/maven-repo.

Leiningen, the build tool for Clojure packages, while not strictly
speaking a Java tool (Clojure runs on the JVM, but isn't Java), does
that too. I cannot tell leiningen "here are some jar files, please build
using those", as it requires them to be in a maven repository that
respects the proper hierarchy.

For example, since the complete namespace for libintl.jar is
org.gnu.gettext.libintl, it will look for the jar file in
$MAVEN_REPO/org/gnu/gettext/libintl/$VERSION/libintl-$VERSION.jar.

If you look at libraries in the Java Team [1][2][3][4][5], most of them
will publish jars both in /usr/share/java/ and in /usr/share/maven-repo,
to accommodate the needs of the various tools in the ecosystem.

> Could we have those questions answered before writing any patches,
> please? Before applying a patch, I'd like to be sure that it's the
> right thing to do, which in this case I'm not sure yet.
> 
> In either case, I prefer that the files are symlinks to the real files,
> (not copies) and also prefer that it's not versioned, since we are
> never going to provide more than one version at a time. If you absolutely
> need the version, we can parse debian/changelog for that or use some
> debhelper variable if it does exist (I bet this will not be the first
> package needing to know its own version number).

The version thing is needed, as that's part of the maven repository
specification. Often upstream specifies a precise version to use during
build, as typically jars are just fetched online at mvnrepository.com
during build.

Since that's not the way we do thing in Debian, most packages also
provide a generic version that symlinks to the right one, in this case
the "debian" version. This means we don't have to change anything when a
new version of a dependency is uploaded, as the "debian" version always
points to the right one.

In the case of the patch I made, that's all taken care of by
maven-repo-helper, which reads debian/gettext-base.poms to know what to do.

The "--java-lib" option in there tells it to also install the jar in
/usr/share/java/, so it's not needed in the debian/gettext-base.install
file anymore. I did it this way, since it prevents the jar from being
installed twice (everything is symlinked instead).

Sadly, I had to write the debian/libintl.pom.xml file by hand. I think
this often happens in Java (I'm not part of the Java Team), but in
Clojure we have a tool that takes care of generating them for us
dynamically.

Maybe you could ask upstream to publish a pom file? That way we could
reuse it instead and not have to update the version number manually for
new versions. I guess I could write some glue in d/rules to fetch the
current version and replace it in debian/libintl.pom.xml using sed, but
that feels icky.

Happy to answer more questions if needed.

[1]: libbcpkix-java
[2]: libini4j-java
[3]: libicu4j-java
[4]: libjackson2-core-java
[5]: libhttpcore-java

-- 
  ⢀⣴⠾⠻⢶⣦⠀
  ⣾⠁⢠⠒⠀⣿⡁  Louis-Philippe Véronneau
  ⢿⡄⠘⠷⠚⠋   po...@debian.org / veronneau.org
  ⠈⠳⣄
diff --git a/debian/control b/debian/control
index a940de9..ed29ec6 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: devel
 Priority: optional
 Maintainer: Santiago Vila <sanv...@debian.org>
 Standards-Version: 4.5.0
-Build-Depends: debhelper-compat (= 13), dh-exec (>= 0.13), dh-elpa, g++ (>= 4:7), bison, file, help2man, xz-utils, default-jdk <!nojava>, fastjar <!nojava>, libglib2.0-dev, libncurses5-dev, libunistring-dev, libxml2-dev
+Build-Depends: debhelper-compat (= 13), dh-exec (>= 0.13), dh-elpa, g++ (>= 4:7), bison, file, help2man, xz-utils, default-jdk <!nojava>, maven-repo-helper <!nojava>, fastjar <!nojava>, libglib2.0-dev, libncurses5-dev, libunistring-dev, libxml2-dev
 Homepage: https://www.gnu.org/software/gettext/
 Rules-Requires-Root: no
 
diff --git a/debian/gettext-base.install b/debian/gettext-base.install
index 364a84a..a5cc5b7 100755
--- a/debian/gettext-base.install
+++ b/debian/gettext-base.install
@@ -5,7 +5,6 @@ usr/bin/ngettext
 usr/bin/envsubst
 usr/bin/gettext.sh
 usr/share/locale/*/*/gettext-runtime.mo
-<!nojava> usr/share/gettext/libintl.jar  usr/share/java
 
 # C# support is currently turned off altogether
 # debian/tmp/usr/lib/GNU.Gettext.dll
diff --git a/debian/gettext-base.poms b/debian/gettext-base.poms
new file mode 100644
index 0000000..41fedc7
--- /dev/null
+++ b/debian/gettext-base.poms
@@ -0,0 +1 @@
+debian/libintl.pom.xml --artifact=debian/tmp/usr/share/gettext/libintl.jar --java-lib --usj-name=libintl
diff --git a/debian/libintl.pom.xml b/debian/libintl.pom.xml
new file mode 100644
index 0000000..8c16ad7
--- /dev/null
+++ b/debian/libintl.pom.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.gnu.gettext</groupId>
+  <artifactId>libintl</artifactId>
+  <version>0.21</version>
+  <packaging>jar</packaging>
+  <properties>
+    <debian.hasPackageVersion/>
+    <debian.originalVersion>0.21</debian.originalVersion>
+    <debian.package>gettext-base</debian.package>
+  </properties>
+</project>
diff --git a/debian/not-installed b/debian/not-installed
index 32526ec..2b87084 100755
--- a/debian/not-installed
+++ b/debian/not-installed
@@ -18,7 +18,9 @@ usr/share/gettext/styles/
 # not wanted by doc-base
 usr/share/doc/gettext/javadoc2/package-list
 
+# installed via maven-repo-helper to have proper symlinks
+usr/share/gettext/libintl.jar
+
 # not installed under nojava profile
 <nojava> usr/share/gettext/gettext.jar
-<nojava> usr/share/gettext/libintl.jar
 <nojava> usr/share/gettext/javaversion.class
diff --git a/debian/rules b/debian/rules
index c2da7bb..efe8627 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,7 +1,7 @@
 #!/usr/bin/make -f
 
 %:
-	dh $@ --with elpa
+	dh $@ --with elpa --with maven-repo-helper
 
 
 #

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to