[Reproducible-commits] [strip-nondeterminism] 03/03: Normalize Unix permissions in Zip archives

Andrew Ayer agwa at andrewayer.name
Sun Dec 14 23:00:45 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 295c53d4de66541bc6b08058c421b4cfdbf8cb68
Author: Andrew Ayer <agwa at andrewayer.name>
Date:   Sun Dec 14 14:56:32 2014 -0800

    Normalize Unix permissions in Zip archives
    
    Closes: #765304
---
 lib/File/StripNondeterminism/handlers/zip.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lib/File/StripNondeterminism/handlers/zip.pm b/lib/File/StripNondeterminism/handlers/zip.pm
index b57368a..11722f6 100644
--- a/lib/File/StripNondeterminism/handlers/zip.pm
+++ b/lib/File/StripNondeterminism/handlers/zip.pm
@@ -80,6 +80,20 @@ sub normalize_extra_fields {
 			for (my $i = 1; $i < $len; $i += 4) {
 				$result .= pack("V", $File::StripNondeterminism::canonical_time // SAFE_EPOCH);
 			}
+		} elsif ($id == 0x7875) { # Info-ZIP New Unix Extra Field
+			$result .= substr($field, $pos, 4);
+			#  Version       1 byte      version of this extra field, currently 1
+			#  UIDSize       1 byte      Size of UID field
+			#  UID           Variable    UID for this entry
+			#  GIDSize       1 byte      Size of GID field
+			#  GID           Variable    GID for this entry
+			if (ord(substr($field, $pos + 4, 1)) == 1) {
+				my $uid_len = ord(substr($field, $pos + 5, 1));
+				my $gid_len = ord(substr($field, $pos + 6 + $uid_len, 1));
+				$result .= pack("CCx${uid_len}Cx${gid_len}", 1, $uid_len, $gid_len);
+			} else {
+				$result .= substr($field, $pos + 4, $len);
+			}
 		} else {
 			# use the current extra field unmodified.
 			$result .= substr($field, $pos, $len+4);
@@ -100,6 +114,7 @@ sub normalize {
 		$zip->addMember($member);
 		$options{member_normalizer}->($member) if exists $options{member_normalizer};
 		$member->setLastModFileDateTimeFromUnix($File::StripNondeterminism::canonical_time // SAFE_EPOCH);
+		$member->unixFileAttributes(0644) if $member->fileAttributeFormat() == FA_UNIX;
 		$member->cdExtraField(normalize_extra_fields($member->cdExtraField()));
 	}
 	$zip->overwrite();

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



More information about the Reproducible-commits mailing list