This is an automated email from the git hooks/post-receive script.

agwa-guest pushed a commit to branch master
in repository strip-nondeterminism.

commit 0faf9c5a8d54936afe70772a880e308db4881fb8
Author: Andrew Ayer <a...@andrewayer.name>
Date:   Sat Sep 13 21:29:38 2014 -0700

    Normalize Javadoc files inside Jars
---
 TODO                                    |  2 +-
 lib/StripNondeterminism/handlers/jar.pm | 17 ++++++++++++++++-
 lib/StripNondeterminism/handlers/zip.pm |  5 +++--
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/TODO b/TODO
index d0b21a1..ade8392 100644
--- a/TODO
+++ b/TODO
@@ -4,7 +4,7 @@ Write handlers for:
        [DONE] ar
        [DONE] zip
        [DONE] jar
-       javadoc embedded inside jar file
+       [DONE] javadoc embedded inside jar file
        ...
 
 [DONE] Write main strip-nondeterminism command
diff --git a/lib/StripNondeterminism/handlers/jar.pm 
b/lib/StripNondeterminism/handlers/jar.pm
index f18d9fa..d795ec4 100644
--- a/lib/StripNondeterminism/handlers/jar.pm
+++ b/lib/StripNondeterminism/handlers/jar.pm
@@ -23,6 +23,7 @@ use warnings;
 
 use Archive::Zip;
 use StripNondeterminism::handlers::zip;
+use StripNondeterminism::handlers::javadoc;
 
 sub _jar_filename_cmp ($$) {
        my ($a, $b) = @_;
@@ -35,9 +36,23 @@ sub _jar_filename_cmp ($$) {
        return $a cmp $b;
 }
 
+sub _jar_normalize_member {
+       my ($member) = @_; # $member is a ref to an Archive::Zip::Member
+       return if $member->isDirectory();
+
+       if ($member->fileName() =~ /\.html$/ &&
+                       
StripNondeterminism::handlers::zip::peek_member($member, 1024) =~ /\<!-- 
Generated by javadoc/) {
+               # javadoc header should be within first 1kb of file
+               StripNondeterminism::handlers::zip::normalize_member($member,
+                               
\&StripNondeterminism::handlers::javadoc::normalize);
+       }
+}
+
 sub normalize {
        my ($jar_filename) = @_;
-       return StripNondeterminism::handlers::zip::normalize($jar_filename, 
\&_jar_filename_cmp);
+       return StripNondeterminism::handlers::zip::normalize($jar_filename,
+                                                       filename_cmp => 
\&_jar_filename_cmp,
+                                                       member_normalizer => 
\&_jar_normalize_member);
 }
 
 1;
diff --git a/lib/StripNondeterminism/handlers/zip.pm 
b/lib/StripNondeterminism/handlers/zip.pm
index faf5a94..4baa0d4 100644
--- a/lib/StripNondeterminism/handlers/zip.pm
+++ b/lib/StripNondeterminism/handlers/zip.pm
@@ -63,13 +63,14 @@ sub normalize_member {
 }
 
 sub normalize {
-       my ($zip_filename, $filename_cmp) = @_;
-       $filename_cmp ||= sub { $a cmp $b };
+       my ($zip_filename, %options) = @_;
+       my $filename_cmp = $options{filename_cmp} || sub { $a cmp $b };
        my $zip = Archive::Zip->new($zip_filename);
        my @filenames = sort $filename_cmp $zip->memberNames();
        for my $filename (@filenames) {
                my $member = $zip->removeMember($filename);
                $zip->addMember($member);
+               $options{member_normalizer}->($member) if exists 
$options{member_normalizer};
                $member->setLastModFileDateTimeFromUnix(SAFE_EPOCH);
        }
        $zip->overwrite();

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/reproducible/strip-nondeterminism.git

_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to