Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Dist-Zilla-Plugin-FatPacker CPAN distribution.

Report information
The Basics
Id: 112009
Status: new
Priority: 0/
Queue: Dist-Zilla-Plugin-FatPacker

People
Owner: Nobody in particular
Requestors: MAF [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: fatpacking doesn't play well with FileMunger plugins
In Dist-Zilla, FileMunger plugins usually work on InMemory versions of the files(depending on the FileGatherer), which means it does not change any of the original files in the dir dzil is run in. This means fatpacking is picking up unmunged copies of the files, which can be a problem if we need stuff like version numbers from fatpacked libs, that get added during file munging. I'm not sure what the best approach to fix this would be. The simplest and least efficient way might be to write all the gathered files to a tempdir, and run the fatpacking there. You might be able to make this smarter and only right out the files needed for fatpacking.
I've also attached an example patch, to show what the simple approach might look like.
Subject: Dist-Zilla-Plugin-FatPacker.patch
diff --git a/lib/Dist/Zilla/Plugin/FatPacker.pm b/lib/Dist/Zilla/Plugin/FatPacker.pm index c914e7f..4b748b1 100644 --- a/lib/Dist/Zilla/Plugin/FatPacker.pm +++ b/lib/Dist/Zilla/Plugin/FatPacker.pm @@ -5,10 +5,18 @@ use warnings; package Dist::Zilla::Plugin::FatPacker; # ABSTRACT: Pack your dependencies onto your script file -use File::Temp 'tempfile'; -use File::Path 'remove_tree'; +use Cwd qw(getcwd); +use File::Basename 'dirname'; +use File::Temp 'tempdir', 'tempfile'; +use File::Path 'make_path', 'remove_tree'; +use IO::File; use Moose; -with 'Dist::Zilla::Role::FileMunger'; +with( + 'Dist::Zilla::Role::FileMunger', + 'Dist::Zilla::Role::FileFinderUser' => { + default_finders => [ ':InstallModules', ':ExecFiles' ], + }, +); has script => (is => 'ro'); sub safe_system { @@ -31,6 +39,25 @@ sub safe_remove_tree { die "remove_tree had errors, aborting\n"; } +sub munge_files { + my ($self) = @_; + my $oldcwd = getcwd(); + my $tempdir = tempdir(CLEANUP => 1); + chdir $tempdir; + + for my $file (@{ $self->found_files }) { + my $name = $file->name; + make_path(dirname($name)); + IO::File->new("> $name")->print($file->content); + } + + for my $file (@{ $self->found_files }) { + $self->munge_file($file) + } + + chdir($oldcwd); +} + sub munge_file { my ($self, $file) = @_; unless (defined $self->script) {