Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add --prefix to bootstrap.
Now panda and its dependencies are self-contained separately, so you
actually can update some panda dependencies without breaking panda
itself.

Awesome!
  • Loading branch information
Tadeusz Sośnierz committed Jun 2, 2013
1 parent 1b27a1d commit cdf0c1a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 39 deletions.
7 changes: 7 additions & 0 deletions bin/panda
@@ -1,4 +1,11 @@
#!/usr/bin/env perl6
BEGIN {
# we want to load those versions which were built along with panda
# so when there's site/lib and site/panda/lib, we load modules from the latter
# (because this file will end up in site/panda/bin)
my $pandalib = $?FILE.IO.path.parent.parent.child('lib').Str;
@*INC.unshift: $pandalib;
}
use Shell::Command;
use Panda;
use Panda::Ecosystem;
Expand Down
84 changes: 45 additions & 39 deletions bootstrap.pl
Expand Up @@ -7,49 +7,55 @@ BEGIN
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";
sub default-prefix {
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";
try mkpath $destdir;
last if $destdir.path.w
}
unless $destdir.path.w {
warn "destdir: { $destdir.perl }";
die "Found no writable directory into which panda could be installed";
}
return $destdir;
}

my $projects = slurp 'projects.json.bootstrap';
$projects ~~ s:g/_BASEDIR_/{cwd}\/ext/;
$projects .= subst('\\', '/', :g) if $is_win;
sub MAIN(:$prefix = default-prefix()) {
say "==> Bootstrapping Panda to $prefix";

given open "$panda-base/projects.json", :w {
.say: $projects;
.close;
}
my $is_win = $*OS eq 'MSWin32';

my $env_sep = $is_win ?? ';' !! ':';
my $projects = slurp 'projects.json.bootstrap';
$projects ~~ s:g/_BASEDIR_/{cwd}\/ext/;
$projects .= subst('\\', '/', :g) if $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";
mkpath $prefix;
given open "$prefix/projects.json", :w {
.say: $projects;
.close;
}

shell "perl6 bin/panda install File::Tools 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";
my $env_sep = $is_win ?? ';' !! ':';

%*ENV<PERL6LIB> ~= "{$env_sep}$prefix/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";
%*ENV<DESTDIR> = "$prefix";

unlink "$panda-base/projects.json";
my $pandapath;
{
my $pandabin = $prefix.IO.path.child('bin');
mkpath $pandabin.Str;
$pandapath = $pandabin.child('panda');
'bin/panda'.IO.copy($pandapath);
}

shell "perl6 $pandapath install File::Tools JSON::Tiny {cwd}" and exit;
say "==> Please make sure that $prefix/bin is in your PATH";

unlink "$prefix/projects.json";
}

0 comments on commit cdf0c1a

Please sign in to comment.