[Git][reproducible-builds/strip-nondeterminism][master] Use Sub::Override for Archive::Zip workarounds instead of Monkey::Patch (see...
Chris Lamb
gitlab at salsa.debian.org
Mon Jul 15 13:16:37 UTC 2019
Chris Lamb pushed to branch master at Reproducible Builds / strip-nondeterminism
Commits:
88a6cd7c by Niko Tyni at 2019-07-15T13:14:47Z
Use Sub::Override for Archive::Zip workarounds instead of Monkey::Patch (see reproducible-builds/strip-nondeterminism#8 for more information). (Closes: #931730)
Monkey::Patch recursively depends on an XS binary Perl module which creates
build cycle issues for Perl transitions.
Use Sub::Override instead as it has no dependencies outside Perl core.
Signed-off-by: Chris Lamb <lamby at debian.org>
- - - - -
2 changed files:
- Makefile.PL
- lib/File/StripNondeterminism/handlers/zip.pm
Changes:
=====================================
Makefile.PL
=====================================
@@ -17,7 +17,7 @@ WriteMakefile(
'Archive::Cpio' => 0, # required to pass tests
'Archive::Zip' => 0,
'Getopt::Long' => 0,
- 'Monkey::Patch' => 0,
+ 'Sub::Override' => 0,
},
LICENSE => "gpl",
dist => { COMPRESS => 'gzip -9nf', SUFFIX => 'gz', },
=====================================
lib/File/StripNondeterminism/handlers/zip.pm
=====================================
@@ -24,7 +24,7 @@ use warnings;
use File::Temp;
use File::StripNondeterminism;
use Archive::Zip qw/:CONSTANTS :ERROR_CODES/;
-use Monkey::Patch qw/patch_class/;
+use Sub::Override;
# A magic number from Archive::Zip for the earliest timestamp that
# can be represented by a Zip file. From the Archive::Zip source:
@@ -231,21 +231,24 @@ sub normalize {
# stored value of localExtraField (!) and reload it again from the existing
# file handle in/around rewindData.
#
- # We therefore monkey-patch the accessor methods of the Member class to
+ # We therefore override the accessor methods of the Member class to
# ensure that normalised values are used in this final save.
#
# <https://salsa.debian.org/reproducible-builds/strip-nondeterminism/issues/4>
- my @patches = map {
- patch_class('Archive::Zip::Member', $_, sub {
- my $fn = shift;
- my $result = $fn->(@_);
- return defined($result) ?
- normalize_extra_fields($canonical_time, $result) : $result;
- });
+ my @overrides = map {
+ my $full_name = "Archive::Zip::Member::$_";
+ my $orig_sub = \&$full_name;
+ Sub::Override->new(
+ $full_name => sub {
+ my $result = $orig_sub->(@_);
+ return defined($result) ?
+ normalize_extra_fields($canonical_time, $result) : $result;
+ }
+ );
} qw(cdExtraField localExtraField);
return 0 unless $zip->overwrite() == AZ_OK;
- undef @patches; # Remove our monkey patches
+ $_->restore for @overrides;
chmod($old_perms, $zip_filename);
return 1;
}
View it on GitLab: https://salsa.debian.org/reproducible-builds/strip-nondeterminism/commit/88a6cd7cd26cae608d9db32616241c82c0b11990
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/strip-nondeterminism/commit/88a6cd7cd26cae608d9db32616241c82c0b11990
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20190715/52b753f3/attachment.html>
More information about the rb-commits
mailing list