/
Installer.pm
44 lines (40 loc) · 1.42 KB
/
Installer.pm
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
use Pies;
use Panda::Common;
use File::Find;
use Shell::Command;
class Panda::Installer does Pies::Installer {
sub die (Pies::Project $p, $d) is hidden_from_backtrace {
X::Panda.new($p.name, 'install', $d).throw
}
has $.resources;
has $.destdir;
method install(Pies::Project $p) {
indir $!resources.workdir($p), {
if 'blib'.IO ~~ :d {
for find(dir => 'blib', name => /\.p[od|m6?]$/).list,
find(dir => 'blib', name => /\.pir$/).list
-> $i {
# .substr(5) to skip 'blib/'
mkpath "$!destdir/{$i.dir.substr(5)}";
$i.IO.copy("$!destdir/{$i.Str.substr(5)}");
}
}
if 'bin'.IO ~~ :d {
for find(dir => 'bin', type => 'file').list -> $bin {
mkpath "$!destdir/{$bin.dir}";
$bin.IO.copy("$!destdir/$bin");
"$!destdir/$bin".IO.chmod(0o755) unless $*OS eq 'MSWin32';
}
}
if 'doc'.IO ~~ :d {
for find(dir => 'doc', type => 'file').list -> $doc {
my $path = "$!destdir/{$p.name.subst(':', '/', :g)}"
~ "/{$doc.dir}";
mkpath $path;
$doc.IO.copy("$path/{$doc.name}");
}
}
};
}
}
# vim: ft=perl6