[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.5.0-rc2-137-g5284eba



The following commit has been merged in the master branch:
commit 4035a138619ec7932b7879a94c46624faab9aee9
Author: Vincent Fourmond <fourmond@debian.org>
Date:   Mon Apr 4 15:15:14 2011 +0200

    Added a new checks for java packages
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/java b/checks/java
new file mode 100644
index 0000000..dd96890
--- /dev/null
+++ b/checks/java
@@ -0,0 +1,121 @@
+# java -- lintian check script -*- perl -*-
+
+# Copyright (C) 2011 Vincent Fourmond
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, you can find it on the World Wide
+# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+package Lintian::java;
+use strict;
+use warnings;
+
+use lib "$ENV{'LINTIAN_ROOT'}/checks/";
+
+use Lintian::Tags qw(tag);
+use Util;
+
+
+sub run {
+
+my $pkg = shift;
+my $type = shift;
+my $info = shift;
+
+my $java_info = $info->java_info;
+my $missing_jarwrapper = 0;
+my $has_classpath = 0;
+my $has_public_jars = 0;
+
+my @java_lib_depends = ($info->relation('strong')->unparse() =~
+			/(lib[^\s,]+-java)/g);
+
+# We first loop over jar files to find problems
+
+for my $jar_file (keys %{$java_info}) {
+    my $manifest = $java_info->{$jar_file};
+
+    if($manifest->{'Manifest-Version'}) {
+	# We do have a real JAR with a real manifest.
+
+	my $operm = $info->{index}->{$jar_file}->{operm};
+	if(($operm & 01 or
+	    $operm & 010 or $operm & 0100)) {
+	    # Executable ?
+	    tag "executable-jar-without-main-class", "$jar_file" unless
+		$manifest->{'Main-Class'};
+
+	    # Here, we need to check that the package depends on
+	    # jarwrapper.
+	    if(! $info->relation('strong')->implies('jarwrapper')) {
+		$missing_jarwrapper = 1;
+	    }
+	}
+	elsif ($jar_file !~ m#^usr/share/#) {
+	    tag "jar-not-in-usr-share", "$jar_file";
+	}
+    }
+    if($jar_file =~ m#^usr/share/java#) {
+	$has_public_jars = 1;
+    }
+
+    my $cp = $manifest->{'Class-Path'};
+    # Only run the tests when a classpath is present
+    if($cp) {
+	my $relative = 0;
+	my $outside_usr_share = 0;
+	my @paths = split(/\s+/, $cp);
+	$has_classpath = 1;
+	for my $p (@paths) {
+	    if($p) {
+		if($p !~ m#^/#) {
+		    if($p =~ m#/#) {
+			# Relative path with subdirectories.
+			$relative++;
+		    }
+
+		    # @todo add an info tag for relative paths, to educate
+		    # maintainers ?
+		}
+		elsif($p !~ m#/usr/share/#) {
+		    $outside_usr_share++;
+		}
+	    }
+	}
+
+	if($relative) {
+	    tag "classpath-contains-relative-path", "$jar_file: $cp";
+	}
+
+	if($outside_usr_share) {
+	    tag "classpath-contains-files-not-in-usr-share", "$jar_file: $cp";
+	}
+    }
+}
+
+if($missing_jarwrapper) {
+    tag 'missing-dep-on-jarwrapper';
+}
+
+if(! $has_classpath && @java_lib_depends) {
+    tag "missing-classpath", join(", ", @java_lib_depends);
+}
+
+if(! $has_public_jars && $pkg =~ /^lib[^\s,]+-java$/) {
+    tag "javalib-but-no-public-jars";
+}
+
+}
+1;
diff --git a/checks/java.desc b/checks/java.desc
new file mode 100644
index 0000000..7dcbc23
--- /dev/null
+++ b/checks/java.desc
@@ -0,0 +1,68 @@
+Check-Script: java
+Author: Vincent Fourmond <fourmond@debian.org>
+Abbrev: java
+Type: binary
+Needs-Info: java-info
+Info: This script checks if the packages comply with various aspects of the
+ debian Java policy.
+
+Tag: classpath-contains-relative-path
+Severity: normal
+Certainty: possible
+Info: The classpath listed in some of the files references relative path
+ with subdirectories. This is probably the remnants of a build-time
+ classpath that are not relevant for a JAR bundled in a Debian package.
+
+Tag: classpath-contains-files-not-in-usr-share
+Severity: normal
+Certainty: certain
+Info: The classpath listed in some of the files references files outside
+ of /usr/share, while all installed JAR files must be within
+ /usr/share/java for libraries or /usr/share/<i>package</i> for JARs for
+ private use.
+
+Tag: jar-not-in-usr-share
+Severity: important
+Certainty: certain
+Ref: java-policy 2.2, java-policy 2.3
+Info: The classpath listed in some of the files references files outside
+ of /usr/share, while all installed JAR files must be within
+ /usr/share/java for libraries or /usr/share/<i>package</i> for JARs for
+ private use.
+
+Tag: executable-jar-without-main-class
+Severity: serious
+Certainty: certain
+Ref: java-policy 2.2
+Info: An executable JAR must have a Main-Class set in its manifest.
+
+Tag: missing-dep-on-jarwrapper
+Severity: serious
+Certainty: certain
+Ref: java-policy 2.2
+Info: Packages containing an executable JAR must depend on jarwrapper or
+ other packages providing similar functionalities.
+
+Tag: missing-classpath
+Severity: normal
+Certainty: possible
+Info: None of the jar files contained in the package declare a Class-Path
+ in their manifest, but the package depends on at least one java library.
+ That means that either the dependency is not needed or at least one of
+ the JARs should include a classpath.
+ .
+ It is important to keep the classpath up-to-date to allow the
+ automatic detection of dependencies at run time. Having a Class-Path
+ element in the manifest allows for painless transitions if the class
+ path of the dependencies of the library ever changes.
+ .
+ Failing to do that means that for every change in class path, all
+ rdepends must update their wrapper scripts, which is a lot of work
+ for nothing.
+
+Tag: javalib-but-no-public-jars
+Severity: minor
+Certainty: possible
+Info: The name of the package suggests that it contains a java library but
+ it does not contain any JAR file in /usr/share/java, while the java policy
+ mandates that JAR files outside /usr/share/java are for private use.
diff --git a/debian/changelog b/debian/changelog
index dba702a..575b76d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,13 @@ lintian (2.5.0~rc3) UNRELEASED; urgency=low
       - dir-or-file-in-run
       - intra-source-package-circular-dependency
       - package-contains-broken-symlink
+      - classpath-contains-relative-path
+      - classpath-contains-files-not-in-usr-share
+      - jar-not-in-usr-share
+      - executable-jar-without-main-class
+      - missing-dep-on-jarwrapper
+      - missing-classpath
+      - javalib-but-no-public-jars
 
   * checks/*.desc:
     + [NT] Updated the Needs-Info field to include the new
@@ -29,6 +36,8 @@ lintian (2.5.0~rc3) UNRELEASED; urgency=low
       (Closes: #622396)
   * checks/files{,.desc}:
     + [NT] Added dir-or-file-in-run tag.
+  * checks/java{,.desc}:
+    + [NT] Added file from patches submitted by Vicent Fourmond.
   * checks/manpages:
     + [NT] Fixed false-positive binary-without-manpage when the
       manpage is in a direct dependency of the package and the
diff --git a/t/tests/fields-java/tags b/t/tests/fields-java/tags
index 545a3aa..7080a0f 100644
--- a/t/tests/fields-java/tags
+++ b/t/tests/fields-java/tags
@@ -1,3 +1,4 @@
+I: libfields-java-java: javalib-but-no-public-jars
 W: fields-java source: build-depends-on-specific-java-doc-package openjdk-6-doc
 W: libfields-java-java-doc: depends-on-specific-java-doc-package recommends
 W: libfields-java-java: needless-dependency-on-jre
diff --git a/t/tests/fields-wrong-section/tags b/t/tests/fields-wrong-section/tags
index ffc6c40..99f207e 100644
--- a/t/tests/fields-wrong-section/tags
+++ b/t/tests/fields-wrong-section/tags
@@ -1,3 +1,4 @@
+I: libfields-wrong-section-java: javalib-but-no-public-jars
 W: fields-wrong-section-contrib-doc: wrong-section-according-to-package-name fields-wrong-section-contrib-doc => contrib/doc
 W: fields-wrong-section-dbg: wrong-section-according-to-package-name fields-wrong-section-dbg => debug
 W: fields-wrong-section-doc: wrong-section-according-to-package-name fields-wrong-section-doc => doc

-- 
Debian package checker


Reply to: