blob: 96716f9a15168208656efdf7b3c2f23cf1d69ddd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
try mkdir 'install';
try mkdir 'install/languages';
try mkdir 'install/languages/perl6';
try mkdir 'install/languages/perl6/site';
try 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',
Nil;
# 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;
}
}
|