On Thu, Jul 11, 2019 at 06:25:56PM -0300, Chris Lamb wrote: > > > I guess in theory but if I recall the details correctly, I don't > > > /think/ this was going to be a trivial patch to Archive::Zip and my > > > Perl-fu is/was a bit weak. Would pkg-perl apply and upload a patch > > > anyway? > […] > > Obviously features would be best developed upstream. Archive-Zip seems > > to be alive if quiet. But a bug against libarchive-zip-perl would be a > > good start (with or without a patch). > > Nod. I'll work on a proper patch to libarchive-zip-perl over the next > few days.
Thanks. Meanwhile, please consider the attached patch which should solve the immediate concern by using Sub::Override (from libsub-override-perl) instead. -- Niko
>From 06cc575db2f6eb5336d00b93b9c8b2ceb4280867 Mon Sep 17 00:00:00 2001 From: Niko Tyni <nt...@debian.org> Date: Mon, 15 Jul 2019 09:30:11 +0300 Subject: [PATCH] Use Sub::Override for Archive::Zip workarounds 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. Closes: 931730 --- lib/File/StripNondeterminism/handlers/zip.pm | 23 +++++++++++--------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/File/StripNondeterminism/handlers/zip.pm b/lib/File/StripNondeterminism/handlers/zip.pm index a90a7e3..a15f5a8 100644 --- a/lib/File/StripNondeterminism/handlers/zip.pm +++ b/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; } -- 2.20.1