-
Notifications
You must be signed in to change notification settings - Fork 56
/
bootstrap.pl
executable file
·50 lines (40 loc) · 1.63 KB
/
bootstrap.pl
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
47
48
49
50
#!/usr/bin/env perl6
use v6;
use lib 'ext/File__Tools/lib/';
use Shell::Command;
say '==> Bootstrapping Panda';
my $is_win = $*OS eq 'MSWin32';
my $panda-base;
my $destdir = %*ENV<DESTDIR>;
$destdir = "{cwd}/$destdir" if defined($destdir) && $*OS ne 'MSWin32' && $destdir !~~ /^ '/' /;
for grep(*.defined, $destdir, %*CUSTOM_LIB<site home>) -> $prefix {
$destdir = $prefix;
$panda-base = "$prefix/panda";
try mkdir $destdir;
try mkpath $panda-base unless $panda-base.IO ~~ :d;
last if $panda-base.path.w
}
unless $panda-base.path.w {
warn "panda-base: { $panda-base.perl }";
die "Found no writable directory into which panda could be installed";
}
my $projects = slurp 'projects.json.bootstrap';
$projects ~~ s:g/_BASEDIR_/{cwd}\/ext/;
$projects .= subst('\\', '/', :g) if $is_win;
given open "$panda-base/projects.json", :w {
.say: $projects;
.close;
}
my $env_sep = $is_win ?? ';' !! ':';
%*ENV<PERL6LIB> ~= "{$env_sep}$destdir/lib";
%*ENV<PERL6LIB> ~= "{$env_sep}{cwd}/ext/File__Tools/lib";
%*ENV<PERL6LIB> ~= "{$env_sep}{cwd}/ext/JSON__Tiny/lib";
%*ENV<PERL6LIB> ~= "{$env_sep}{cwd}/ext/Test__Mock/lib";
%*ENV<PERL6LIB> ~= "{$env_sep}{cwd}/lib";
shell "perl6 bin/panda install --notests Test::Harness File::Tools JSON::Tiny Test::Mock {cwd}";
rm_rf "$destdir/panda/src"; # XXX This shouldn't be necessary, I think
# that src should not be kept at all, but
# I figure out how to do that nicely, let's
# at least free boostrap from it
say "==> Please make sure that $destdir/bin is in your PATH";
unlink "$panda-base/projects.json";