[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 7e5dd5faadffa2040f8f0e954d55ee29a24abe3b
Author: Vincent Fourmond <fourmond@debian.org>
Date:   Sun Apr 10 14:01:44 2011 +0200

    Setup collection for JAR files (and java packages in general)
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/collection/java-info b/collection/java-info
new file mode 100755
index 0000000..8f97e41
--- /dev/null
+++ b/collection/java-info
@@ -0,0 +1,72 @@
+#!/usr/bin/perl -w
+# java-info -- lintian collection script
+
+# 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.
+
+use strict;
+use warnings;
+
+# Sanity check
+unless (-d 'unpacked/') {
+    print STDERR 'error: collection script called in wrong directory!\n';
+    exit 2;
+}
+
+open (INDEX, '<', 'index')
+    or fail("cannot open index: $!\n");
+
+open (OUT, '>', 'java-info')
+    or fail("cannot open java-info: $!\n");
+
+chdir ('unpacked')
+    or fail ("unable to chdir to unpacked: $!\n");
+
+while (<INDEX>) {
+    chomp;
+    $_ = (split(' ', $_, 6))[5];
+    next if / -> .*/;		# We skip symlinks.
+    if (m#(\S+).jar$#i) {
+	my $file = $_;
+
+	# 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";
+	    }
+	}
+	close MANIFEST;
+	print OUT "\n" unless $first;
+    }
+}
+
+close INDEX;
+close OUT or fail("cannot write java-info: $!");
+
+exit 0
diff --git a/collection/java-info.desc b/collection/java-info.desc
new file mode 100644
index 0000000..b256fe9
--- /dev/null
+++ b/collection/java-info.desc
@@ -0,0 +1,6 @@
+Collector-Script: java-info
+Author: Vincent Fourmond <fourmond@debian.org>
+Info: This script extracts information from manifests of JAR files
+Type: binary
+Version: 1
+Needs-Info: unpacked
diff --git a/debian/changelog b/debian/changelog
index 50b6a2f..bc8b672 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -50,6 +50,9 @@ lintian (2.5.0~rc3) UNRELEASED; urgency=low
       collections where needed.
   * collection/{bin-pkg-control,fields,index}{,.desc}:
     + [NT] Added to replace various unpack scripts.
+  * collection/java-info{,.desc}:
+    + [NT] Accepted patch from Vincent Fourmond to implement
+      Java related data collection.
 
   * data/debhelper/alt-dh_commands:
     + [NT] New file; contains alternative dependencies for
diff --git a/debian/control b/debian/control
index 0b1b75d..d8a7a45 100644
--- a/debian/control
+++ b/debian/control
@@ -39,7 +39,8 @@ Build-Depends: binutils,
                perl (>= 5.12) | libtest-simple-perl (>= 0.93),
                python,
                quilt,
-               rsync
+               rsync,
+               unzip
 Standards-Version: 3.9.2
 Vcs-Git: git://git.debian.org/git/lintian/lintian.git
 Vcs-Browser: http://git.debian.org/?p=lintian/lintian.git
@@ -63,7 +64,8 @@ Depends: ${misc:Depends},
          liburi-perl,
          locales,
          man-db,
-         perl
+         perl,
+         unzip
 Suggests: binutils-multiarch, libtext-template-perl, man-db (>= 2.5.1-1)
 Description: Debian package checker
  Lintian dissects Debian packages and reports bugs and policy
diff --git a/lib/Lintian/Collect/Binary.pm b/lib/Lintian/Collect/Binary.pm
index a8f4d50..a655be0 100644
--- a/lib/Lintian/Collect/Binary.pm
+++ b/lib/Lintian/Collect/Binary.pm
@@ -288,6 +288,33 @@ sub objdump_info {
     return $self->{objdump_info};
 }
 
+
+# Returns the information from collect/objdump-info
+# sub java_info Needs-Info java-info
+sub java_info {
+    my ($self) = @_;
+    return $self->{java_info} if exists $self->{java_info};
+
+    my %java_info;
+    open(my $idx, '<', 'java-info')
+        or fail("cannot open java-info: $!");
+    my $file;
+    while (<$idx>) {
+        chomp;
+        next if m/^\s*$/o;
+
+        if (m#^-- \./(.+)$#o) {
+            $file = $1;
+            $java_info{$file} = {};
+        }
+        elsif (m#^  (\S+):\s(.*)$#o) {
+            $java_info{$file}->{$1} = $2;
+        }
+    }
+    $self->{java_info} = \%java_info;
+    return $self->{java_info};
+}
+
 # Return a Lintian::Relation object for the given relationship field.  In
 # addition to all the normal relationship fields, the following special
 # field names are supported: all (pre-depends, depends, recommends, and
@@ -374,6 +401,15 @@ object, or undef if the changelog doesn't exist.  The changelog-file
 collection script must have been run to create the changelog file, which
 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,
+to find the classpath of I<$file>, you could use:
+
+ my $cp = $info->java_info()->{$file}->{'Class-Path'};
+
 =item native()
 
 Returns true if the binary package is native and false otherwise.

-- 
Debian package checker


Reply to: