[SCM] Debian package checker branch, master, updated. 2.5.11-155-g4aa6e42
The following commit has been merged in the master branch:
commit 4aa6e421c789a9a32cb9eb9cb62525faa392b748
Author: Niels Thykier <niels@thykier.net>
Date: Thu Feb 14 23:46:53 2013 +0100
coll/java: Handle broken jar files more gracefully
Instead of erroring out, record the error and let check/java emit a
tag for (possibly) broken jar files.
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/checks/java b/checks/java
index e192916..c2dd394 100644
--- a/checks/java
+++ b/checks/java
@@ -58,6 +58,11 @@ for my $jar_file (sort keys %{$java_info}) {
my $cp = '';
my $bsname = '';
+ if (exists $java_info->{$jar_file}->{error}) {
+ tag 'zip-parse-error', "$jar_file:", $java_info->{$jar_file}->{error};
+ next;
+ }
+
# The Java Policy says very little about requires for (jars in) JVMs
next if $jar_file =~ m#usr/lib/jvm(?:-exports)?/[^/]++/#o;
# Ignore Mozilla's jar files, see #635495
diff --git a/checks/java.desc b/checks/java.desc
index 6c12ac8..43c3a1b 100644
--- a/checks/java.desc
+++ b/checks/java.desc
@@ -104,3 +104,8 @@ Info: The package contains a Jar file with Java class files compiled for an
.
Lastest class version known by Lintian is Java7 (Major version 51).
+Tag: zip-parse-error
+Severity: normal
+Certainty: certain
+Info: The package contains a Jar file, but Lintian is unable to parse it.
+ It is possible that the Jar file is corrupt.
diff --git a/collection/java-info b/collection/java-info
index f25eac4..14b78d9 100755
--- a/collection/java-info
+++ b/collection/java-info
@@ -58,11 +58,23 @@ my $open_java_info = sub {
spawn(\%opts, ['gzip', '-9c'] );
$opts{pipe_in}->blocking(1);
};
-
+my $errorhandler = sub {
+ my ($err) = @_;
+ $err =~ s/\r?\n/ /g;
+ $err =~ s/\s++$//;
+ print {$opts{pipe_in}} "-- ERROR: $err\n";
+};
chdir ("$dir/unpacked")
or fail "unable to chdir to unpacked: $!";
+# Without this Archive::Zip will emit errors to standard error for
+# faulty zip files - but that is not what we want. AFAICT, it is
+# the only way to get a textual error as well, so (ab)use it for
+# this purpose while we are at it.
+my $oldhandler = Archive::Zip::setErrorHandler ($errorhandler);
+
+FILE:
foreach my $file ($info->sorted_index) {
my $ftype = $info->index ($file);
next unless $ftype->is_file;
@@ -77,7 +89,7 @@ foreach my $file ($info->sorted_index) {
print {$opts{pipe_in}} "-- $file\n";
# stringify or $azip will make a call back that fails.
- $azip->read ("$file") == AZ_OK or fail "Could not read $file: $!";
+ $azip->read ("$file") == AZ_OK or next FILE;
# First, the file list:
foreach my $member ($azip->members) {
@@ -88,8 +100,8 @@ foreach my $file ($info->sorted_index) {
if ($name =~ m/\.class$/o) {
# Collect the Major version of the class file.
my ($contents, $zerr) = $member->contents;
- fail "Failed to decompress $name of $file: $zerr"
- unless $zerr == AZ_OK;
+ next FILE unless $zerr == AZ_OK;
+
# translation of the unpack
# NN NN NN NN, nn nn, nn nn - bytes read (in hex, network order)
# $magic , __ __, $major - variables
@@ -104,8 +116,7 @@ foreach my $file ($info->sorted_index) {
print {$opts{pipe_in}} "-- MANIFEST: $file\n";
my ($contents, $zerr) = $manifest->contents;
- fail "Failed to decompress Manifest of $file: $zerr"
- unless $zerr == AZ_OK;
+ next FILE unless $zerr == AZ_OK;
my $first = 1;
foreach my $line (split m/\n/, $contents) {
$line =~ s/\r//go;
@@ -123,6 +134,8 @@ foreach my $file ($info->sorted_index) {
}
}
+Archive::Zip::setErrorHandler ($oldhandler);
+
if (%opts) {
close $opts{pipe_in} or fail "cannot write java-info.gz: $!";
reap (\%opts);
diff --git a/debian/changelog b/debian/changelog
index c8335ef..ccf0e36 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -26,6 +26,7 @@ lintian (2.5.12) UNRELEASED; urgency=low
- unknown-testsuite
- vcs-field-bitrotted
- vcs-git-uses-invalid-user-uri
+ - zip-parse-error
+ Removed:
- unneeded-build-dep-on-quilt
@@ -76,6 +77,8 @@ lintian (2.5.12) UNRELEASED; urgency=low
+ [NT] Fix regression where Lintian would not properly match
init.d passed to update-rc.d. Thanks to Michael Meskes for
reporting. (Closes: #698602)
+ * checks/java{,.desc}:
+ + [NT] Report possibly broken jar files.
* checks/menu-format{,.desc}:
+ [NT] Apply patch from Bastien Roucariès to detect missing
"Keywords" in desktop files. Thanks to Jeremy Bicha for
@@ -114,6 +117,9 @@ lintian (2.5.12) UNRELEASED; urgency=low
+ [NT] Fix missing trailing slash on dirnames and bump index
version accordingly. Thanks to Nicolas Boulenguez for
noticing.
+ * collection/java-info:
+ + [NT] Gracefully handle broken Jar files. Thanks to Paul
+ Tagliamonte for the report. (Closes: #700543)
* collection/strings:
+ [NT] Fix a regression in filtering out "debug" ELF binaries.
diff --git a/lib/Lintian/Collect/Binary.pm b/lib/Lintian/Collect/Binary.pm
index 95aec33..f808679 100644
--- a/lib/Lintian/Collect/Binary.pm
+++ b/lib/Lintian/Collect/Binary.pm
@@ -462,6 +462,12 @@ check for it.
A table of the files in the JAR. Each key is a file name and its value
is its "Major class version" for Java or "-" if it is not a class file.
+=item error
+
+If it exists, this is an error that occured during reading of the zip
+file. If it exists, it is unlikely that the other fields will be
+present.
+
=back
Needs-Info requirements for using I<java_info>: java-info
@@ -489,7 +495,9 @@ sub java_info {
chomp;
next if m/^\s*$/o;
- if (m#^-- MANIFEST: (?:\./)?(?:.+)$#o) {
+ if (m#^-- ERROR:\s*(\S.++)$#o) {
+ $java_info{$file}->{error} = $1;
+ } elsif (m#^-- MANIFEST: (?:\./)?(?:.+)$#o) {
# TODO: check $file == $1 ?
$java_info{$file}->{manifest} = {};
$manifest = $java_info{$file}->{manifest};
@@ -506,7 +514,7 @@ sub java_info {
$manifest->{$1} = $2;
}
elsif ($file_list) {
- my ($fname, $clmajor) = (m#^(.*):\s*([-\d]+)$#);
+ my ($fname, $clmajor) = (m#^([^-].*):\s*([-\d]+)$#);
$file_list->{$fname} = $clmajor;
}
diff --git a/t/tests/java-jars/debian/debian/control.in b/t/tests/java-jars/debian/debian/control.in
index 2af6a8d..9225c5a 100644
--- a/t/tests/java-jars/debian/debian/control.in
+++ b/t/tests/java-jars/debian/debian/control.in
@@ -42,3 +42,12 @@ Description: {$description} - part C
java-related QA code in lintian. Third part.
.
This package should not be installed.
+
+Package: unparsable
+Architecture: {$architecture}
+Depends: $\{misc:Depends\}
+Description: {$description} - unparable
+ This is a test package designed to test various aspects of the
+ java-related QA code in lintian. The unparsable part.
+ .
+ This package should not be installed.
diff --git a/t/tests/java-jars/debian/debian/rules b/t/tests/java-jars/debian/debian/rules
index 5af8965..a1224c2 100755
--- a/t/tests/java-jars/debian/debian/rules
+++ b/t/tests/java-jars/debian/debian/rules
@@ -7,6 +7,10 @@ override_jh_build:
unzip testa.jar
zip -r codeless.jar META-INF/
zip -r manifestless.jar org/
+ printf "PK\003\004Watch the fireworks begin :>" > unparsable.jar
+
+override_jh_manifest override_jh_depends:
+ # Skip - it chokes on "unparsable.jar" and we don't need it
override_dh_auto_clean:
rm -fr META-INF/ org/
diff --git a/t/tests/java-jars/debian/debian/unparsable.install b/t/tests/java-jars/debian/debian/unparsable.install
new file mode 100644
index 0000000..a734cf7
--- /dev/null
+++ b/t/tests/java-jars/debian/debian/unparsable.install
@@ -0,0 +1 @@
+unparsable.jar usr/share/unparsable
diff --git a/t/tests/java-jars/desc b/t/tests/java-jars/desc
index 83d2ed3..2a82577 100644
--- a/t/tests/java-jars/desc
+++ b/t/tests/java-jars/desc
@@ -12,3 +12,4 @@ Test-For:
javalib-but-no-public-jars
missing-dep-on-jarwrapper
missing-manifest
+ zip-parse-error
diff --git a/t/tests/java-jars/tags b/t/tests/java-jars/tags
index e1d4bc2..d5db4f1 100644
--- a/t/tests/java-jars/tags
+++ b/t/tests/java-jars/tags
@@ -6,3 +6,4 @@ W: libcodeless-java: codeless-jar usr/share/java/codeless-1.0.jar
W: libtesta-java: binary-without-manpage usr/bin/testc.jar
W: libtesta-java: executable-not-elf-or-script usr/bin/testc.jar
W: libtesta-java: jar-not-in-usr-share usr/lib/testb.jar
+W: unparsable: zip-parse-error usr/share/unparsable/unparsable.jar: format error: can't find EOCD signature
--
Debian package checker
Reply to: