Permalink
Browse files

Read from all state files we can find

Not just the first writable one we find. This (for example) allows a (root) install of
perl6+panda into /usr/local; along with some modules such as URI and
MIME::Base64. A user can then run 'panda install LWP::Simple' and will
not need to reinstall URI and MIME::Base64, because panda will now see
the modules installed in /usr/local
  • Loading branch information...
1 parent d37c017 commit 99da3b3a8298c61c49a0b3364c11a29923c8a5e0 @retupmoca retupmoca committed Apr 5, 2014
Showing with 19 additions and 8 deletions.
  1. +8 −0 bin/panda
  2. +11 −8 lib/Panda/Ecosystem.pm
View
@@ -25,9 +25,17 @@ my $panda;
die "Found no writable directory into which panda could be installed";
}
+ my @extra-statefiles;
+ for grep(*.defined, $destdir, %*CUSTOM_LIB<site home>) -> $prefix {
+ unless $destdir eq $prefix {
+ @extra-statefiles.push("$prefix/panda/state");
+ }
+ }
+
my $ecosystem = Panda::Ecosystem.new(
statefile => "$pandadir/state",
projectsfile => "$pandadir/projects.json",
+ extra-statefiles => @extra-statefiles
);
$panda = Panda.new(:$ecosystem);
View
@@ -4,6 +4,7 @@ class Panda::Ecosystem {
use Shell::Command;
has $.statefile;
+ has @.extra-statefiles;
has $.projectsfile;
has %!projects;
has %!states;
@@ -18,15 +19,17 @@ class Panda::Ecosystem {
$fh.close;
}
- submethod BUILD(:$!statefile, :$!projectsfile) {
- if $!statefile.IO ~~ :f {
- my $fh = open($!statefile);
- for $fh.lines -> $line {
- my ($mod, $state, $json) = split ' ', $line, 3;
- %!states{$mod} = ::("Panda::Project::State::$state");
- %!saved-meta{$mod} = from-json $json;
+ submethod BUILD(:$!statefile, :$!projectsfile, :@!extra-statefiles) {
+ for $!statefile, @!extra-statefiles -> $file {
+ if $file.IO ~~ :f {
+ my $fh = open($file);
+ for $fh.lines -> $line {
+ my ($mod, $state, $json) = split ' ', $line, 3;
+ %!states{$mod} = ::("Panda::Project::State::$state");
+ %!saved-meta{$mod} = from-json $json;
+ }
+ $fh.close;
}
- $fh.close;
}
self.update if $!projectsfile.IO !~~ :f || $!projectsfile.IO ~~ :z;

0 comments on commit 99da3b3

Please sign in to comment.