[lintian] 03/03: Check for .jar files that embed Foo.java alongside a Foo.class file. (Closes: #762113)
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository lintian.
commit f3d4ccd9208493876c44ce9a1d90576aec8548d0
Author: Chris Lamb <lamby@debian.org>
Date: Wed Feb 7 20:44:54 2018 +0000
Check for .jar files that embed Foo.java alongside a Foo.class file. (Closes: #762113)
---
checks/java.desc | 13 +++++++++++++
checks/java.pm | 2 ++
debian/changelog | 2 ++
t/tests/java-jars/debian/debian/control.in | 10 ++++++++++
.../java-jars/debian/debian/libcontains-source-java.jlibs | 1 +
t/tests/java-jars/debian/debian/rules | 2 ++
t/tests/java-jars/desc | 1 +
t/tests/java-jars/tags | 1 +
8 files changed, 32 insertions(+)
diff --git a/checks/java.desc b/checks/java.desc
index 16e0e97..7a8af22 100644
--- a/checks/java.desc
+++ b/checks/java.desc
@@ -106,3 +106,16 @@ Info: The package ships the specified "public" Jar file under
<tt>/usr/share/java/</tt>, but the name does not correspond to Java policy
guidelines. This can cause tools in the Debian Java toolchain to fail.
Ref: java-policy 2.4
+
+Tag: jar-contains-source
+Severity: normal
+Certainty: certain
+Info: The package ships the specified Jar file containing a
+ <tt>.java</tt> file alongside a corresponding <tt>.class</tt> file.
+ .
+ This wastes disk space as the source is always available via <tt>apt
+ source</tt>.
+ .
+ Please ensure that the specified <tt>.java</tt> files are not shipped in
+ the Jar file.
+Ref: java-policy 2.4
diff --git a/checks/java.pm b/checks/java.pm
index 32c4c8a..59c7d35 100644
--- a/checks/java.pm
+++ b/checks/java.pm
@@ -79,6 +79,8 @@ sub run {
foreach
my $class (grep { m/\.(?:class|cljc?)$/oi } sort keys %{$files}){
my $mver = $files->{$class};
+ (my $src = $class) =~ s/\.[^.]+$/\.java/;
+ tag 'jar-contains-source', $jar_file, $src if %{$files}{$src};
$classes = 1;
next if $class =~ m/\.cljc?$/;
# .class but no major version?
diff --git a/debian/changelog b/debian/changelog
index 33ac904..7964015 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -29,6 +29,8 @@ lintian (2.5.74) UNRELEASED; urgency=medium
* checks/java.{desc,pm}:
+ [CL] Only warn about bad-jar-name for "public" .jar files.
(Closes: #889628)
+ + [CL] Check for .jar files that embed Foo.java alongside a Foo.class
+ file. (Closes: #762113)
* checks/init.d.{desc,pm}:
+ [CL] Warn about packages that use ENABLED="true" (etc.) in
/etc/default files.
diff --git a/t/tests/java-jars/debian/debian/control.in b/t/tests/java-jars/debian/debian/control.in
index 1ee27a6..9b72712 100644
--- a/t/tests/java-jars/debian/debian/control.in
+++ b/t/tests/java-jars/debian/debian/control.in
@@ -61,3 +61,13 @@ Description: {$description} - unparsable
java-related QA code in lintian. The unparsable part.
.
This package should not be installed.
+
+Package: libcontains-source-java
+Architecture: {$architecture}
+Depends: $\{misc:Depends\}
+Description: {$description} - contains .java source
+ This is a test package designed to test various aspects of the
+ java-related QA code in lintian. This package should not be
+ installed.
+ .
+ This package tests for .java files inside jars.
diff --git a/t/tests/java-jars/debian/debian/libcontains-source-java.jlibs b/t/tests/java-jars/debian/debian/libcontains-source-java.jlibs
new file mode 100644
index 0000000..db68d0e
--- /dev/null
+++ b/t/tests/java-jars/debian/debian/libcontains-source-java.jlibs
@@ -0,0 +1 @@
+contains-source.jar
diff --git a/t/tests/java-jars/debian/debian/rules b/t/tests/java-jars/debian/debian/rules
index fd11dcc..8ca4444 100755
--- a/t/tests/java-jars/debian/debian/rules
+++ b/t/tests/java-jars/debian/debian/rules
@@ -9,6 +9,8 @@ override_jh_build:
unzip testa.jar
zip -r codeless.jar META-INF/
zip -r manifestless.jar org/
+ touch org/debian/lintian/TestA.java
+ zip -r contains-source.jar META-INF/ org/
perl generate-unparsable.pl
# Skip - it chokes on "unparsable.jar" and we don't need it
diff --git a/t/tests/java-jars/desc b/t/tests/java-jars/desc
index 21123a8..3f95962 100644
--- a/t/tests/java-jars/desc
+++ b/t/tests/java-jars/desc
@@ -9,6 +9,7 @@ Test-For:
bad-jar-name
codeless-jar
executable-jar-without-main-class
+ jar-contains-source
jar-not-in-usr-share
javalib-but-no-public-jars
maven-plugin-in-usr-share-java
diff --git a/t/tests/java-jars/tags b/t/tests/java-jars/tags
index 670c04e..448124d 100644
--- a/t/tests/java-jars/tags
+++ b/t/tests/java-jars/tags
@@ -3,6 +3,7 @@ E: libtesta-java: missing-dep-on-jarwrapper
I: libmanifestless-java: missing-manifest usr/share/java/manifestless-1.0.jar
I: libtestc-java: javalib-but-no-public-jars
W: libcodeless-java: codeless-jar usr/share/java/codeless-1.0.jar
+W: libcontains-source-java: jar-contains-source usr/share/java/contains-source-1.0.jar org/debian/lintian/TestA.java
W: libtest-maven-plugin-java: maven-plugin-in-usr-share-java usr/share/java/testb.jar
W: libtesta-java: bad-jar-name usr/share/java/0.jar
W: libtesta-java: binary-without-manpage usr/bin/testc.jar
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: