aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Leich <email@froggs.de>2014-09-25 21:41:32 +0200
committerTobias Leich <email@froggs.de>2014-09-25 21:41:32 +0200
commit54b69eba8141785d1839ade4e161e7d06fb6a800 (patch)
treeec10ecf784837276920eb40bdbd2204e4d0685e8
parentf21eb1c7c13444c264cd3cd8cae172aa85b564fd (diff)
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.
-rw-r--r--tools/build/panda-state.p657
-rw-r--r--tools/star/Makefile1
2 files changed, 58 insertions, 0 deletions
diff --git a/tools/build/panda-state.p6 b/tools/build/panda-state.p6
new file mode 100644
index 0000000..300514d
--- /dev/null
+++ b/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;
+ }
+}
diff --git a/tools/star/Makefile b/tools/star/Makefile
index 04d6de5..e89a97c 100644
--- a/tools/star/Makefile
+++ b/tools/star/Makefile
@@ -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