-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathbootstrap.pl
executable file
·75 lines (63 loc) · 2.32 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env perl6
use v6;
use v6.c;
use lib 'ext/File__Find/lib/';
use lib 'ext/File__Which/lib/';
use lib 'ext/Shell__Command/lib/';
use Shell::Command;
sub MAIN(Str :$prefix is copy) {
say '==> Bootstrapping Panda';
# prevent a lot of expensive dynamic lookups
my $CWD := $*CWD;
my $DISTRO := $*DISTRO;
my %ENV := %*ENV;
%ENV<PANDA_SUBMIT_TESTREPORTS>:delete;
my $is_win = $DISTRO.is-win;
my $panda-base;
my $repo;
$prefix = "$CWD/$prefix" if defined($prefix) && $is_win && $prefix !~~ /^ '/' /;
my @repos = $*REPO.repo-chain.grep(CompUnit::Repository::Installable).grep(*.can-install);
my @custom-lib = <site home>.map({CompUnit::RepositoryRegistry.repository-for-name($_)});
for grep(*.defined, flat $prefix, @custom-lib, @repos) -> $target {
if $target ~~ CompUnit::Repository {
$prefix = $target.path-spec;
$repo = $prefix;
$panda-base = "{$target.prefix}/panda";
try mkdir $panda-base unless $panda-base.IO.d;
}
else {
$prefix = $target;
$repo = "$target/lib";
$panda-base = "$target/panda";
try mkdir $prefix;
try mkpath $panda-base unless $panda-base.IO ~~ :d;
}
last if $panda-base.IO.w
}
unless $panda-base.IO.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 = $DISTRO.?cur-sep // $DISTRO.path-sep;
%ENV<PERL6LIB> = join( $env_sep,
"file#$CWD/ext/File__Find/lib",
"file#$CWD/ext/File__Which/lib",
"file#$CWD/ext/Shell__Command/lib",
"file#$CWD/ext/JSON__Fast/lib",
"file#$CWD/lib",
$repo,
);
my $prefix_str = $prefix ?? "--prefix=$prefix" !! '';
run $*EXECUTABLE, '--ll-exception', 'bin/panda', '--force', $prefix_str, 'install', $*CWD;
$prefix = $prefix.substr(5) if $prefix.starts-with("inst#");
say "==> Please make sure that $prefix/bin is in your PATH";
unlink "$panda-base/projects.json";
}
# vim: ft=perl6