[Reproducible-builds] [strip-nondeterminism] 03/06: Return 0 from normalizer if file was not modified, 1 otherwise
Andrew Ayer
agwa at andrewayer.name
Sun Sep 14 05:14:42 UTC 2014
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 3572e4ffc3d9661659c312583155396d78edc3ab
Author: Andrew Ayer <agwa at andrewayer.name>
Date: Sat Sep 13 20:27:53 2014 -0700
Return 0 from normalizer if file was not modified, 1 otherwise
---
lib/StripNondeterminism/handlers/ar.pm | 4 +++-
lib/StripNondeterminism/handlers/gzip.pm | 6 ++++--
lib/StripNondeterminism/handlers/jar.pm | 2 +-
lib/StripNondeterminism/handlers/javadoc.pm | 4 +++-
lib/StripNondeterminism/handlers/zip.pm | 1 +
5 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/StripNondeterminism/handlers/ar.pm b/lib/StripNondeterminism/handlers/ar.pm
index 02d1b99..dfb41ee 100644
--- a/lib/StripNondeterminism/handlers/ar.pm
+++ b/lib/StripNondeterminism/handlers/ar.pm
@@ -40,7 +40,7 @@ sub normalize {
or die("failed to open $file for read+write: $!");
read $fh, $buf, $GLOBAL_HEADER_LENGTH;
- return if $buf ne $GLOBAL_HEADER;
+ return 0 if $buf ne $GLOBAL_HEADER;
while (1) {
my $file_header_start = tell $fh;
@@ -81,6 +81,8 @@ sub normalize {
# move to next member
seek $fh, $file_header_start + $FILE_HEADER_LENGTH + $file_size, SEEK_SET;
}
+
+ return 1;
}
1;
diff --git a/lib/StripNondeterminism/handlers/gzip.pm b/lib/StripNondeterminism/handlers/gzip.pm
index daa82d2..aa905e4 100644
--- a/lib/StripNondeterminism/handlers/gzip.pm
+++ b/lib/StripNondeterminism/handlers/gzip.pm
@@ -48,9 +48,9 @@ sub normalize {
# Read the current header
my $hdr;
my $bytes_read = read($fh, $hdr, 10);
- return unless $bytes_read == 10;
+ return 0 unless $bytes_read == 10;
my ($id1, $id2, $cm, $flg, $mtime, $xfl, $os) = unpack('CCCCl<CC', $hdr);
- return unless $id1 == 31 and $id2 == 139;
+ return 0 unless $id1 == 31 and $id2 == 139;
my $new_flg = $flg;
$new_flg &= ~FNAME; # Don't include filename
@@ -117,6 +117,8 @@ sub normalize {
chmod((stat($fh))[2] & 07777, $out_filename);
rename($out_filename, $filename) or die "$filename: unable to overwrite: rename: $!";
+
+ return 1;
}
1;
diff --git a/lib/StripNondeterminism/handlers/jar.pm b/lib/StripNondeterminism/handlers/jar.pm
index 6be7071..f18d9fa 100644
--- a/lib/StripNondeterminism/handlers/jar.pm
+++ b/lib/StripNondeterminism/handlers/jar.pm
@@ -37,7 +37,7 @@ sub _jar_filename_cmp ($$) {
sub normalize {
my ($jar_filename) = @_;
- StripNondeterminism::handlers::zip::normalize($jar_filename, \&_jar_filename_cmp);
+ return StripNondeterminism::handlers::zip::normalize($jar_filename, \&_jar_filename_cmp);
}
1;
diff --git a/lib/StripNondeterminism/handlers/javadoc.pm b/lib/StripNondeterminism/handlers/javadoc.pm
index 94ad012..4805432 100644
--- a/lib/StripNondeterminism/handlers/javadoc.pm
+++ b/lib/StripNondeterminism/handlers/javadoc.pm
@@ -57,10 +57,12 @@ sub normalize {
# Rename temporary file over the file
chmod((stat($fh))[2] & 07777, $out_filename);
rename($out_filename, $filename) or die "$filename: unable to overwrite: rename: $!";
- last;
+ return 1;
}
print $out_fh $line;
}
+
+ return 0;
}
1;
diff --git a/lib/StripNondeterminism/handlers/zip.pm b/lib/StripNondeterminism/handlers/zip.pm
index e19c7fc..027c70c 100644
--- a/lib/StripNondeterminism/handlers/zip.pm
+++ b/lib/StripNondeterminism/handlers/zip.pm
@@ -40,6 +40,7 @@ sub normalize {
$member->setLastModFileDateTimeFromUnix(SAFE_EPOCH);
}
$zip->overwrite();
+ return 1;
}
1;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/strip-nondeterminism.git
More information about the Reproducible-builds
mailing list