App-FatPacker
view release on metacpan or search on metacpan
lib/App/FatPacker.pm view on Meta::CPAN
return 0 if $pos == $last;
my $next = (1 + index $fat, "\n", $pos) || $last;
$_ .= substr $fat, $pos, $next - $pos;
$pos = $next;
return 1;
});
}
};
}
else {
*{"${class}::INC"} = sub {
if (my $fat = $_[0]{$_[1]}) {
open my $fh, '<', \$fat
or die "FatPacker error loading $_[1] (could be a perl installation issue?)";
return $fh;
}
return;
};
}
unshift @INC, bless \%fatpacked, $class;
} # END OF FATPACK CODE
END_END
}
sub fatpack_code {
my ($self, $files) = @_;
my @segments = map {
(my $stub = $_) =~ s/\.pm$//;
my $name = uc join '_', split '/', $stub;
my $data = $files->{$_}; $data =~ s/^/ /mg; $data =~ s/(?<!\n)\z/\n/;
'$fatpacked{'.perlstring($_).qq!} = '#line '.(1+__LINE__).' "'.__FILE__."\\"\\n".<<'${name}';\n!
.qq!${data}${name}\n!;
} sort keys %$files;
return join "\n", $self->fatpack_start, @segments, $self->fatpack_end;
}
=encoding UTF-8
=head1 NAME
App::FatPacker - pack your dependencies onto your script file
=head1 SYNOPSIS
$ fatpack pack myscript.pl >myscript.packed.pl
Or, with more step-by-step control:
$ fatpack trace myscript.pl
$ fatpack packlists-for `cat fatpacker.trace` >packlists
$ fatpack tree `cat packlists`
$ fatpack file myscript.pl >myscript.packed.pl
Each command is designed to be simple and self-contained so that you can modify
the input/output of each step as needed. See the documentation for the
L<fatpack> script itself for more information.
The programmatic API for this code is not yet fully decided, hence the 0.x
release version. Expect that to be cleaned up for 1.0.
=head1 CAVEATS
As dependency module code is copied into the resulting file as text, only
pure-perl dependencies can be packed, not compiled XS code.
The currently-installed dependencies to pack are found via F<.packlist> files,
which are generally only included in non-core distributions that were installed
by a CPAN installer. This is a feature; see L<fatpack/packlists-for> for
details. (a notable exception to this is FreeBSD, which, since its packaging
system is designed to work equivalently to a source install, does preserve
the packlist files)
=head1 SEE ALSO
L<article for Perl Advent 2012|http://www.perladvent.org/2012/2012-12-14.html>
L<pp> - PAR Packager, a much more complex architecture-dependent packer that
can pack compiled code and even a Perl interpreter
=head1 SUPPORT
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=App-FatPacker>
(or L<bug-App-FatPacker@rt.cpan.org|mailto:bug-App-FatPacker@rt.cpan.org>).
You can normally also obtain assistance on irc, in #toolchain on irc.perl.org.
=head1 AUTHOR
Matt S. Trout (mst) <mst@shadowcat.co.uk>
=head2 CONTRIBUTORS
miyagawa - Tatsuhiko Miyagawa (cpan:MIYAGAWA) <miyagawa@bulknews.net>
tokuhirom - MATSUNOâ
Tokuhiro (cpan:TOKUHIROM) <tokuhirom@gmail.com>
dg - David Leadbeater (cpan:DGL) <dgl@dgl.cx>
gugod - ååº·æ° (cpan:GUGOD) <gugod@cpan.org>
t0m - Tomas Doran (cpan:BOBTFISH) <bobtfish@bobtfish.net>
sawyer - Sawyer X (cpan:XSAWYERX) <xsawyerx@cpan.org>
ether - Karen Etheridge (cpan:ETHER) <ether@cpan.org>
Mithaldu - Christian Walde (cpan:MITHALDU) <walde.christian@googlemail.com>
dolmen - Olivier Mengué (cpan:DOLMEN) <dolmen@cpan.org>
djerius - Diab Jerius (cpan:DJERIUS) <djerius@cpan.org>
haarg - Graham Knop (cpan:HAARG) <haarg@haarg.org>
grinnz - Dan Book (cpan:DBOOK) <dbook@cpan.org>
Many more people are probably owed thanks for ideas. Yet
another doc nit to fix.
( run in 0.530 second using v1.01-cache-2.11-cpan-e1769b4cff6 )