Skip to content
Browse files

Merge branch 'custom-lib'

  • Loading branch information...
2 parents c07f3bc + 109e54c commit 91b94a24d3153a4d1e2a509973c24b694ce47a39 @tadzik committed
Showing with 38 additions and 20 deletions.
  1. +12 −6 bin/panda
  2. +15 −8 bootstrap.pl
  3. +11 −6 rebootstrap.pl
View
18 bin/panda
@@ -87,12 +87,18 @@ if %*ENV<PANDA_DEFAULT_OPTS> {
# initialize the Panda object
my $panda;
{
- my $home = $*OS eq 'MSWin32' ?? %*ENV<HOMEDRIVE> ~ %*ENV<HOMEPATH> !! %*ENV<HOME>;
- my $pandadir = "$home/.panda";
- mkpath $pandadir unless $pandadir.IO ~~ :d;
-
- my $destdir = %*ENV<DESTDIR> || "$home/.perl6";
- $destdir = "{cwd}/$destdir" if $*OS ne 'MSWin32' && $destdir !~~ /^ '/' /;
+ my $pandadir;
+ 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;
+ $pandadir = "$prefix/panda";
+ try mkpath $pandadir unless $pandadir.IO ~~ :d;
+ last if $pandadir.path.w
+ }
+ unless $pandadir.path.w {
+ die "Found no writable directory into which panda could be installed";
+ }
$panda = Panda.new(
srcdir => "$pandadir/src",
View
23 bootstrap.pl
@@ -4,24 +4,31 @@
say '==> Bootstrapping Panda';
my $is_win = $*OS eq 'MSWin32';
-my $home = $is_win ?? %*ENV<HOMEDRIVE> ~ %*ENV<HOMEPATH> !! %*ENV<HOME>;
-mkdir $home unless $home.IO.d;
-mkdir "$home/.panda" unless "$home/.panda".IO.d;
+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 mkdir $panda-base unless $panda-base.IO ~~ :d;
+ last if $panda-base.path.w
+}
+unless $panda-base.path.w {
+ 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 "$home/.panda/projects.json", :w {
+given open "$panda-base/projects.json", :w {
.say: $projects;
.close;
}
my $env_sep = $is_win ?? ';' !! ':';
-my $destdir = %*ENV<DESTDIR> || "$home/.perl6";
- $destdir = "{cwd}/$destdir" unless $destdir ~~ /^ '/' /
- || $is_win && $destdir ~~ /^ [ '\\' | <[a..zA..Z]> ':' ] /;
%*ENV<PERL6LIB> ~= "{$env_sep}$destdir/lib";
%*ENV<PERL6LIB> ~= "{$env_sep}{cwd}/ext/File__Tools/lib";
@@ -31,4 +38,4 @@
shell "perl6 bin/panda install File::Tools JSON::Tiny Test::Mock {cwd}";
-unlink "$home/.panda/projects.json";
+unlink "$panda-base/projects.json";
View
17 rebootstrap.pl
@@ -4,10 +4,15 @@
use Shell::Command;
# Find old state file
-my $home = $*OS eq 'MSWin32' ?? %*ENV<HOMEDRIVE> ~ %*ENV<HOMEPATH> !! %*ENV<HOME>;
-my $state-file = "$home/.panda/state";
+my ($prefix, $state-file);
+for grep(*.defined, %*ENV<DESTDIR>, %*CUSTOM_LIB<site home>) {
+ if "$_/panda/state".path.e {
+ $prefix = $_;
+ $state-file = "$_/panda/state";
+ }
+}
-if not $state-file.IO.e {
+if not $state-file.defined {
say "No need to rebootstrap, running normal bootstrap";
shell 'perl6 bootstrap.pl';
exit 0;
@@ -32,11 +37,11 @@
# Clean old directories, boostrap a fresh panda,
# and reinstall all manually-installed modules
-rm_rf "$home/.perl6/lib";
-rm_rf "$home/.panda";
+rm_rf "$prefix/lib";
+rm_rf "$prefix/panda";
shell 'perl6 bootstrap.pl';
say "==> Reinstalling @modules[]";
shell "panda install @modules[]";
-# Save the backup state file back to ~/.panda/
+# Save the backup state file back to $prefix/panda/
spurt "$state-file.bak", $old-state if $old-state;

0 comments on commit 91b94a2

Please sign in to comment.
Something went wrong with that request. Please try again.