forked from tadzik/panda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.pl
executable file
·56 lines (47 loc) · 1.79 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
51
52
53
54
55
56
#!/usr/bin/env perl6
use v6;
BEGIN {
shell 'git submodule init';
shell 'git submodule update';
}
use lib 'ext/File__Find/lib/';
use lib 'ext/Shell__Command/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__Find/lib";
%*ENV<PERL6LIB> ~= "{$env_sep}{cwd}/ext/Shell__Command/lib";
%*ENV<PERL6LIB> ~= "{$env_sep}{cwd}/ext/JSON__Tiny/lib";
%*ENV<PERL6LIB> ~= "{$env_sep}{cwd}/lib";
shell "$*EXECUTABLE_NAME bin/panda install File::Find Shell::Command JSON::Tiny {cwd}";
if "$destdir/panda/src".IO ~~ :d {
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";