blob: c1554cd37a8a3b2908606e6ccd226152cc15b050 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package Carton::Packer;
use strict;
use App::FatPacker;
use File::pushd ();
use Path::Tiny ();
use Moo;
sub fatpack_carton {
my($self, $dir) = @_;
my $temp = Path::Tiny->tempdir;
my $pushd = File::pushd::pushd $temp;
my $file = $temp->child('carton.pre.pl');
$file->spew(<<'EOF');
#!/usr/bin/env perl
use strict;
use 5.008001;
use Carton::CLI;
$Carton::Fatpacked = 1;
exit Carton::CLI->new->run(@ARGV);
EOF
my $packer = App::FatPacker->new;
my @modules = split /\r?\n/, $packer->trace(args => [$file], use => ['App::cpanminus']);
my @packlists = $packer->packlists_containing(\@modules);
$packer->packlists_to_tree(Path::Tiny->new('fatlib')->absolute, \@packlists);
my $fatpacked = do {
local $SIG{__WARN__} = sub {};
$packer->fatpack_file($file);
};
my $executable = $dir->child('carton');
warn "Bundling $executable\n";
$dir->mkpath;
$executable->spew($fatpacked);
chmod 0755, $executable;
}
1;
|