[SCM] UNNAMED PROJECT branch, master, updated. 0.30-39-ga8b6a73

Niels Thykier nthykier-guest at alioth.debian.org
Mon Jul 5 13:50:45 UTC 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "UNNAMED PROJECT".

The branch, master has been updated
       via  a8b6a73ffbf454f5a95ea61f8509216785749c7f (commit)
       via  bfc9f15b98695aab299d6b5c3052e17ff4a30fb3 (commit)
      from  abf1d0b293c2ace1495de0f1cbb277853c366fe6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a8b6a73ffbf454f5a95ea61f8509216785749c7f
Author: Niels Thykier <niels at thykier.net>
Date:   Mon Jul 5 15:50:02 2010 +0200

    Updated d/changelog and documentation.

commit bfc9f15b98695aab299d6b5c3052e17ff4a30fb3
Author: Niels Thykier <niels at thykier.net>
Date:   Mon Jul 5 15:43:00 2010 +0200

    Allowed read and write of Name attributes longer than 72 by letting
    them span multiple lines - other tools do this as well.
    Corrected jh_manifest's parsing of debian/manifest file.
    Made jh_manifest warn if a manifest is defined in debian/manifest and
    no matching jar file was found (unless it would have been ignored).
    Allowed comments in debian/manifest.

-----------------------------------------------------------------------

Summary of changes:
 Java.pm            |   22 ++++++---
 ManifestSection.pm |    3 -
 debian/changelog   |    3 +
 jh_manifest        |  137 ++++++++++++++++++++++++++++++++++++++++++++++------
 4 files changed, 139 insertions(+), 26 deletions(-)

diff --git a/Java.pm b/Java.pm
index a77eccb..3651c87 100644
--- a/Java.pm
+++ b/Java.pm
@@ -181,18 +181,28 @@ sub parse_manifest_fd{
 	    next;
 	}
 	if($line ne ''){
-	    $sec->set_value($atname, $atval) if($atname);
+            if($atname){
+                if(!defined($sec)){
+                    $sec = $manifest->get_section($atval, 1);
+                } else {
+                    $sec->set_value($atname, $atval);
+                }
+            }
 	    ($atname, $atval) = split(/ :\s /ox, $line);
 	    die("Expected <attr>: <val> pair in $name,") unless($atval);
 	    if(!defined($sec)){
 		die("A section must start with the Name attribute in $name,")
 		    unless(lc($atname) eq 'name');
-		$sec = $manifest->get_section($atval, 1);
-		$atname = '';
 	    }
 	    next;
 	}
-	$sec->set_value($atname, $atval) if($atname);
+        if($atname) {
+            if(!defined($sec)){
+                $sec = $manifest->get_section($atval, 1);
+            } else {
+                $sec->set_value($atname, $atval);
+            }
+        }
 	$atname = '';
 	$sec = undef;
     }
@@ -207,11 +217,9 @@ sub write_manifest_section_fd{
     my $name = shift;
     # return manifest-version and name first
     foreach my $entry ($sec->get_values()) {
-	my $atname = lc($entry->[0]);
 	my $line = join(": ", @$entry);
+	# Extend long lines.
 	# Technically this is incorrect since the rules says "bytes" and not "characters"
-	die("Value for Name attribute in $name is too long,") if($atname eq 'name' && length($line) > 72);
-	# extend long lines.
 	$line =~ s/(.{72})/$1\n /go;
 	$line =~ s/^ \n(\w)/$1/go;
 	print $fd "$line\n";
diff --git a/ManifestSection.pm b/ManifestSection.pm
index c7dda4e..35416af 100644
--- a/ManifestSection.pm
+++ b/ManifestSection.pm
@@ -72,9 +72,6 @@ case of the two. When B<$attr> is created, the original case will be
 stored for later (for writing). Later updates to B<$attr> will not
 affect the original case.
 
-Warning: "Name" attributes cannot span over multiple lines, it will give
-an error during write if it is too long.
-
 =item $section->get_value($attr[, $empty])
 
 Returns the value of B<$attr>, long values are merged into a single
diff --git a/debian/changelog b/debian/changelog
index cfb5ab3..d50609b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -30,6 +30,9 @@ javatools (0.32) UNRELEASED; urgency=low
   * Rewrote jh_manifest using debhelper as backend.
     - it now produces deterministic output (Closes: #574029)
     - removed all depends on python.
+    - comments are now allowed in d/manifest files.
+    - it will now produce a warning if a jar file listed in a d/manifest-
+      file cannot be found (unless the jar was excluded).
 
   [ Matthew Johnson ]
   * If jars aren't specified by absolute path try finding them under
diff --git a/jh_manifest b/jh_manifest
index 9b7f20c..dcf4ab1 100755
--- a/jh_manifest
+++ b/jh_manifest
@@ -9,7 +9,7 @@ jh_manifest - Adds or/and modifies manifests for jars
 use strict;
 use warnings;
 
-use File::Find;
+use Cwd();
 use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
 use Debian::Debhelper::Dh_Lib;
 use Debian::Javahelper::Java;
@@ -36,13 +36,20 @@ make B<jh_manifest> ignore matching jar files.
 
 =item debian/I<package>.manifest (or debian/manifest)
 
-All the entries in this manifest will be merged into every jar file
-processed in the given package. If an attribute exists in the same
-section of this manifest and the original in the jar file, then the
-attribute in this manifest will be used.
+This file consist of a list of jar files and values to add to their
+manifests. Values in this file will take precedence over values in the
+original manifest (and command line arguments over values in this
+file).
 
-Note: attributes set via command line options will overrule attributes
-in either manifest.
+It is allowed to list a link in this file instead of an actual jar
+file, provided that the link can be resolved when B<jh_manifest>
+processes it.
+
+If a jar file is listed here cannot be found, B<jh_manifest> will
+print a warning, unless the jar file has been excluded.
+
+As of javahelper >= 0.32, you may add comments in this file. If the
+line starts with a "#" it is completely ignored.
 
 This file is ignored if B<jh_manifest> is passed jar files via command
 line.
@@ -114,37 +121,123 @@ if(@ARGV){
 foreach my $package (@{$dh{DOPACKAGES}}) {
     my $man = pkgfile($package, "manifest");
     my $dir = tmpdir($package);
-    my $manifest = undef;
+    my $manifests = {};
+    my $files = {};
+    my @links = ();
     my $find_cmd="find $dir ";
     my $err;
+    my $fulldir = Cwd::abs_path($dir);
     # skip if it does not exist.
     if( ! -d $dir ){
         verbose_print("Skipping $package - $dir does not exist (or is not a dir).");
         next;
     }
-    if($man){
-        open(my $mfd, "<", $man) or die("$man: $!");
-        $manifest = parse_manifest_fd($mfd, $man);
-        close($mfd);
-    }
+    $manifests = parse_package_file($man) if($man);
     if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne ''){
         $find_cmd.=" '!' \\( $dh{EXCLUDE_FIND} \\) -a ";
     }
-    $find_cmd .= " '!' -type l -a -name '*.jar'";
+    $find_cmd .= " -name '*.jar'";
     verbose_print("$find_cmd");
     open(my $jarfiles, "-|", "$find_cmd") or error("$find_cmd: $!");
     while( my $jar = <$jarfiles> ) {
-        chomp($jar);
-        update_jar($jar, $manifest);
+         chomp($jar);
+         if( -l $jar ) {
+             $jar =~ s@^$dir/*@@;
+             verbose_print("Found symlink $jar");
+             push(@links, $jar);
+         } else {
+             $jar = Cwd::abs_path($jar);
+             $jar =~ s@^$fulldir/*@@;
+             verbose_print("Found $jar");
+             $files->{$jar} = 1;
+         }
     }
     close($jarfiles);
     # Shame on me - using internal subs from Dh_Lib - but it works.
     #   It will error out if invoked.
     Debian::Debhelper::Dh_Lib::_error_exitcode($find_cmd) if($?);
+    # check the links first.
+    foreach my $link (@links) {
+        my $path = Cwd::abs_path("$dir/$link");
+        my $manifest = $manifests->{$link};
+        my $lp = $path;
+        next unless(defined($manifest));
+        error("Cannot modify $link - it is a broken symlink or not possible to resolve,") unless( defined($path) && -e $path );
+        $lp =~ s@^$fulldir/*@@;
+        error("Conflicting manifests for $link (link) and $path,") if(exists($manifests->{$lp}));
+        delete($files->{$lp});
+        delete($manifest->{$link});
+        verbose_print("Updating symlinked $path (using manifest for $link)");
+        update_jar($path, $manifest);
+    }
+    foreach my $jar (keys(%$files)){
+        my $manifest = $manifests->{$jar};
+        delete($manifest->{$jar});
+        update_jar("$dir/$jar", $manifest);
+    }
+    foreach my $unused (keys(%$manifests)){
+        # complain - unless it has been ignored of course.
+        warning("No jar in $package matching $unused") unless(excludefile($unused));
+    }
 }
 
 exit(0);
 
+sub parse_package_file{
+    my $pkgfile = shift;
+    my $manifests = {};
+    my @jars;
+    my @man;
+    my $inlen = 0;
+    open(my $file, "<", $pkgfile) or error("$pkgfile: $!");
+    while( my $line = <$file> ){
+        chomp($line);
+        next if($line =~ m/^#/o);
+        if($line =~ m/^ \s(\s*) /ox){
+            error("Manifest data not attached to a jar in $pkgfile") unless(@jars);
+            $inlen = length($1) unless($inlen);
+            $line = substr($line, 1 + $inlen);
+            push(@man, $line);
+            next;
+        }
+        if(@man){
+            my $mlines = join("\n", @man);
+            my $manifest;
+            open(my $mfd, "<", \$mlines) or error("Reading scalar: $!");
+            $manifest = parse_manifest_fd($mfd, $pkgfile);
+            close($mfd);
+            foreach my $j (@jars){
+                error("Two manifests for $j in $pkgfile,") if(exists($manifests->{$j}));
+                $manifests->{$j} = $manifest;
+            }
+            @man = ();
+            @jars = ();
+        }
+        next if($line eq '');
+        if($line =~ m/\.jar:$/o){
+            $line =~ s@^/*@@o;
+            $line =~ s@//+@/@og;
+            $line =~ s/:$//o;
+            push(@jars, $line);
+            next;
+        }
+        print STDERR "Syntax error in $pkgfile ($line) - perhaps you are missing a \":\"?\n" if($line !~ m/:$/o);
+        error("Unknown line in $pkgfile ($line),");
+    }
+    if(@man){
+        my $mlines = join("\n", @man);
+        my $manifest;
+        open(my $mfd, "<", \$mlines) or error("Reading scalar: $!");
+        $manifest = parse_manifest_fd($mfd, $pkgfile);
+        close($mfd);
+        foreach my $j (@jars){
+            $manifests->{$j} = $manifest;
+        }
+    }
+    close($file);
+    return $manifests;
+}
+
 sub update_jar{
     my $jar = shift;
     my $merge = shift;
@@ -208,6 +301,18 @@ sub update_jar{
     1;
 }
 
+=head1 EXAMPLES
+
+An example debian/manifest file:
+
+ # use the symlink so we do not have to update with the next upstream release.
+ usr/share/java/my.jar:
+  Class-Path: dep1.jar dep2.jar
+  Main-Class: some.awesome.Class
+ usr/share/java/dep2.jar:
+  Class-Path: dep1.jar
+
+
 
 =head1 SEE ALSO
 


hooks/post-receive
-- 
UNNAMED PROJECT



More information about the pkg-java-commits mailing list