Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add script that creates panda state file
So after installing star panda will know what modules are installed.
When someone then will install a module that depends on a shipped module,
the shipped (and known working) dependency will be used by default.
  • Loading branch information
FROGGS committed Sep 25, 2014
1 parent f21eb1c commit 54b69eb
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tools/build/panda-state.p6
@@ -0,0 +1,57 @@

mkdir 'install';
mkdir 'install/languages';
mkdir 'install/languages/perl6';
mkdir 'install/languages/perl6/site';
mkdir 'install/languages/perl6/site/panda';

my $state-file = 'install/languages/perl6/site/panda/state';
my $projects-file = 'install/languages/perl6/site/panda/projects.json';

fetch-projects-json($projects-file);

my $projects = from-json $projects-file.IO.slurp;

# In case we ship a project that is just a fork of a project listed in the ecosystem, add
# the mapping here.
my %ex =
'git://github.com/FROGGS/perl6-digest-md5' => 'git://github.com/cosimo/perl6-digest-md5',
;

# Walk the submodules and put its project information in panda's state file.
my $fh = $state-file.IO.open(:w);
for '.gitmodules'.IO.lines.grep(/^\turl/).map({ /$<url>=[\S+]$/; ~$<url> }) -> $url {
my $p = $projects.first({$_.<source-url> ~~ /^ "{%ex{$url} // $url}" '.git'? $/});
$p<repo-type> = 'git';
$p<source-url> = $url;
$fh.say: $p<name> ~ ' installed ' ~ to-json($p).subst(/\n+/, '', :g);
}
$fh.close;

say $state-file;
say $projects-file;

sub fetch-projects-json($to) {
try unlink $to;
my $s;
if %*ENV<http_proxy> {
my ($host, $port) = %*ENV<http_proxy>.split('/').[2].split(':');
$s = IO::Socket::INET.new(host=>$host, port=>$port.Int);
$s.send("GET http://feather.perl6.nl:3000/projects.json HTTP/1.1\nHost: feather.perl6.nl\nAccept: */*\nConnection: Close\n\n");
}
else {
$s = IO::Socket::INET.new(:host<feather.perl6.nl>, :port(3000));
$s.send("GET /projects.json HTTP/1.0\n\n");
}
my ($buf, $g) = '';
$buf ~= $g while $g = $s.get;

if %*ENV<http_proxy> {
$buf.=subst(:g,/'git://'/,'http://');
}

given open($to, :w) {
.say: $buf.split(/\r?\n\r?\n/, 2)[1];
.close;
}
}
1 change: 1 addition & 0 deletions tools/star/Makefile
Expand Up @@ -72,6 +72,7 @@ manifest: modules/zavolaj/lib
git submodule foreach --quiet 'git ls-files | $(PREFIX) $$path/' >>MANIFEST
grep -v -f tools/star/MANIFEST.exclude MANIFEST >MANIFEST.1
$(PERL) -n -e 'chomp; -f && print "$$_\n"' MANIFEST.1 >MANIFEST
perl6 tools/build/panda-state.p6 >>MANIFEST
sort -o MANIFEST MANIFEST
rm MANIFEST.1

Expand Down

0 comments on commit 54b69eb

Please sign in to comment.