[SCM] Debian package checker branch, master, updated. 2.5.0-rc2-137-g5284eba
The following commit has been merged in the master branch:
commit 462597e46393a88ff0527bbddb32f5147776d3a0
Author: Vincent Fourmond <fourmond@debian.org>
Date: Fri Apr 8 22:10:29 2011 +0200
Extended collection/java-info and checks/java
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/checks/java b/checks/java
index dd96890..8003426 100644
--- a/checks/java
+++ b/checks/java
@@ -27,7 +27,6 @@ use lib "$ENV{'LINTIAN_ROOT'}/checks/";
use Lintian::Tags qw(tag);
use Util;
-
sub run {
my $pkg = shift;
@@ -45,43 +44,48 @@ my @java_lib_depends = ($info->relation('strong')->unparse() =~
# 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#) {
+ my $file_list = $java_info->{$jar_file}->{files};
+ my $manifest = $java_info->{$jar_file}->{manifest};
+ my $operm = $info->{index}->{$jar_file}->{operm};
+
+ if($jar_file =~ m#^usr/share/java#o) {
$has_public_jars = 1;
}
- my $cp = $manifest->{'Class-Path'};
+ if(! grep(/\.class$/, @{$file_list})) {
+ tag "codeless-jar", $jar_file;
+ } elsif (! $manifest) {
+ tag "missing-manifest", $jar_file;
+ }
+
+ if($operm & 0111) {
+ # Executable ?
+ tag "executable-jar-without-main-class", "$jar_file" unless
+ $manifest && $manifest->{'Main-Class'};
+
+ # Here, we need to check that the package depends on
+ # jarwrapper.
+ $missing_jarwrapper = 1
+ unless $info->relation('strong')->implies('jarwrapper');
+ }
+ elsif ($jar_file !~ m#^usr/share/#) {
+ tag "jar-not-in-usr-share", "$jar_file";
+ }
+
+ my $cp = '';
+ $cp = $manifest->{'Class-Path'} if $manifest;
# Only run the tests when a classpath is present
if($cp) {
my $relative = 0;
my $outside_usr_share = 0;
- my @paths = split(/\s+/, $cp);
+ my @paths = split(m/\s++/o, $cp);
$has_classpath = 1;
for my $p (@paths) {
if($p) {
- if($p !~ m#^/#) {
- if($p =~ m#/#) {
+ # Strip leading ./
+ $p =~ s@^\./++@@og;
+ if($p !~ m#^/#o) {
+ if($p =~ m#/#o) {
# Relative path with subdirectories.
$relative++;
}
@@ -89,7 +93,7 @@ for my $jar_file (keys %{$java_info}) {
# @todo add an info tag for relative paths, to educate
# maintainers ?
}
- elsif($p !~ m#/usr/share/#) {
+ elsif($p !~ m#/usr/share/#o) {
$outside_usr_share++;
}
}
@@ -105,9 +109,9 @@ for my $jar_file (keys %{$java_info}) {
}
}
-if($missing_jarwrapper) {
- tag 'missing-dep-on-jarwrapper';
-}
+
+tag 'missing-dep-on-jarwrapper' if $missing_jarwrapper;
+
if(! $has_classpath && @java_lib_depends) {
tag "missing-classpath", join(", ", @java_lib_depends);
diff --git a/checks/java.desc b/checks/java.desc
index 7dcbc23..b27914e 100644
--- a/checks/java.desc
+++ b/checks/java.desc
@@ -66,3 +66,15 @@ 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.
+
+Tag: missing-manifest
+Severity: minor
+Certainty: possible
+Info: The jar file contains .class files but no manifest. This may
+ indicates a build misconfiguration.
+
+Tag: codeless-jar
+Severity: normal
+Certainty: certain
+Info: The jar file contains a manifest but no code. This probably indicates
+ that something went wrong at build-time.
diff --git a/collection/java-info b/collection/java-info
index 8f97e41..e648ce8 100755
--- a/collection/java-info
+++ b/collection/java-info
@@ -43,26 +43,41 @@ while (<INDEX>) {
next if / -> .*/; # We skip symlinks.
if (m#(\S+).jar$#i) {
my $file = $_;
+ my $has_manifest = 0;
# This script needs unzip, there's no way around.
print OUT "-- $file\n";
- open MANIFEST, '-|', 'unzip', '-p', $file, 'META-INF/MANIFEST.MF';
- my $first = 1;
- while(my $line = <MANIFEST>) {
- chomp $line;
- $line =~ s/\r//g;
- if($line =~ m/^(\S+:)\s*(.*)/o) {
- print OUT "\n" unless $first;
- $first = 0;
- print OUT " $1 $2";
- }
- if($line =~ m/^ (.*)/o) {
- print OUT "$1";
+ # First, the file list:
+ open FILE_LIST, '-|', 'zipinfo', '-1', $file;
+ while(<FILE_LIST>) {
+ $has_manifest = 1 if $_ =~ m@^META-INF/MANIFEST.MF$@oi;
+ next if( m#/$#o); # Skip directories
+ print OUT;
+ }
+ close FILE_LIST;
+
+ if($has_manifest) {
+ print OUT "-- MANIFEST: $file\n";
+
+ open MANIFEST, '-|', 'unzip', '-p', $file, 'META-INF/MANIFEST.MF';
+ my $first = 1;
+ while(my $line = <MANIFEST>) {
+ chomp $line;
+ $line =~ s/\r//go;
+ if($line =~ m/^(\S+:)\s*(.*)/o) {
+ print OUT "\n" unless $first;
+ $first = 0;
+ print OUT " $1 $2";
+ }
+ if($line =~ m/^ /o) {
+ print OUT substr $line, 1;
+ }
}
+ close MANIFEST;
+ print OUT "\n" unless $first;
+
}
- close MANIFEST;
- print OUT "\n" unless $first;
}
}
diff --git a/debian/changelog b/debian/changelog
index 575b76d..ae6e974 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,8 @@ lintian (2.5.0~rc3) UNRELEASED; urgency=low
- missing-dep-on-jarwrapper
- missing-classpath
- javalib-but-no-public-jars
+ - missing-manifest
+ - codeless-jar
* checks/*.desc:
+ [NT] Updated the Needs-Info field to include the new
diff --git a/lib/Lintian/Collect/Binary.pm b/lib/Lintian/Collect/Binary.pm
index a655be0..985e7b5 100644
--- a/lib/Lintian/Collect/Binary.pm
+++ b/lib/Lintian/Collect/Binary.pm
@@ -299,16 +299,32 @@ sub java_info {
open(my $idx, '<', 'java-info')
or fail("cannot open java-info: $!");
my $file;
+ my $file_list = 0;
+ my $manifest = 0;
while (<$idx>) {
chomp;
next if m/^\s*$/o;
if (m#^-- \./(.+)$#o) {
$file = $1;
- $java_info{$file} = {};
+ $java_info{$file}->{files} = [];
+ $file_list = $java_info{$file}->{files};
+ $manifest = 0;
}
- elsif (m#^ (\S+):\s(.*)$#o) {
- $java_info{$file}->{$1} = $2;
+ elsif (m#^-- MANIFEST: \./(.+)$#o) {
+ # TODO: check $file == $1 ?
+ $java_info{$file}->{manifest} = {};
+ $manifest = $java_info{$file}->{manifest};
+ $file_list = 0;
+ }
+ else {
+ if($manifest && m#^ (\S+):\s(.*)$#o) {
+ $manifest->{$1} = $2;
+ }
+ elsif($file_list) {
+ push @{$file_list}, $_;
+ }
+
}
}
$self->{java_info} = \%java_info;
@@ -404,12 +420,24 @@ this method expects to find in F<changelog>.
=item java_info()
Returns a hash containing information about JAR files found in binary
-packages, in the form I<file name> -> I<manifest>, where manifest is a
-hash containing the contents of the JAR file manifest. For instance,
+packages, in the form I<file name> -> I<info>, where I<info> is a hash
+containing the following keys:
+
+=over 4
+
+=item manifest
+
+A hash containing the contents of the JAR file manifest. For instance,
to find the classpath of I<$file>, you could use:
my $cp = $info->java_info()->{$file}->{'Class-Path'};
+=item files
+
+the list of the files contained in the archive.
+
+=back
+
=item native()
Returns true if the binary package is native and false otherwise.
--
Debian package checker
Reply to: