/
gen-docbook-make-helpers.pl
executable file
·160 lines (132 loc) · 3.47 KB
/
gen-docbook-make-helpers.pl
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env perl
use strict;
use warnings;
use autodie;
use utf8;
use Path::Tiny qw/ cwd path /;
use Parallel::ForkManager ();
use lib './lib';
use HTML::Latemp::GenWmlHSects ();
use HTML::Latemp::DocBook::GenMake ();
use Shlomif::Homepage::GenQuadPresMak ();
use Shlomif::Homepage::GenFictionsMak ();
use Shlomif::Homepage::GenScreenplaysMak ();
my $global_username = $ENV{LOGNAME} || $ENV{USER} || getpwuid($<);
my $cwd = cwd();
my $upper_dir = $cwd->parent;
my $git_clones_dir = $upper_dir->child( $cwd->basename . "--clones" );
$git_clones_dir->mkpath;
sub _github_clone
{
my $args = shift;
my $type = $args->{'type'} // 'github_git';
my $gh_username = $args->{'username'};
my $repo = $args->{'repo'};
my $into_dir = $args->{'into_dir'};
my $url;
if ( $type eq 'bitbucket_hg' )
{
$url = qq#https://$gh_username\@bitbucket.org/$gh_username/$repo#;
}
else
{
$url = "https://github.com/$gh_username/$repo.git";
}
my $clone_into = $git_clones_dir->child($repo);
my $link = "$into_dir/$repo";
my @prefix =
(
( $type eq 'bitbucket_hg' ) ? ( 'hg', 'clone' ) : ( 'git', 'clone' ) );
my @cmd = ( @prefix, $url, $clone_into );
if ( !-e $clone_into )
{
print "@cmd\n";
if ( system(@cmd) )
{
die "git clone [@cmd] failed!";
}
}
if ( !-e $link )
{
symlink( $clone_into, $link );
}
return;
}
sub _github_shlomif_clone
{
my ( $into_dir, $repo ) = @_;
return _github_clone(
{
username => 'shlomif',
into_dir => $into_dir,
repo => $repo,
}
);
}
my $pm = Parallel::ForkManager->new(20);
sub _task(&)
{
my $cb = shift;
if ( not $pm->start )
{
$cb->();
$pm->finish;
}
return;
}
sub _sys_task
{
my @x = @_;
return _task { system(@x); };
}
sub _git_task
{
my ( $d, $bn ) = @_;
if ( not -e "$d/$bn" )
{
return _task { _github_shlomif_clone( $d, $bn ); };
}
return;
}
if ( not -e 'lib/js/MathJax/README.md' )
{
_sys_task(
'cd lib/js && git clone git://github.com/mathjax/MathJax.git MathJax && cd MathJax && git checkout 2.7.5'
);
}
if ( not -e 'lib/js/jquery-expander' )
{
_sys_task(
'cd lib/js && git clone https://github.com/kswedberg/jquery-expander');
}
if ( not -e 'lib/ebookmaker/README.md' )
{
# Broken due to the bug in this pull-request:
# - https://github.com/setanta/ebookmaker/pull/7
#
# I switched to my fork for now.
#
# system('cd lib && git clone https://github.com/setanta/ebookmaker.git');
_sys_task('cd lib && git clone https://github.com/shlomif/ebookmaker');
}
if ( not -e 'lib/c-begin/README.md' )
{
_sys_task('cd lib && git clone https://github.com/shlomif/c-begin.git');
}
foreach my $repo (
'validate-your-html', 'how-to-share-code-online',
'shlomif-tech-diary', 'Shlomi-Fish-Back-to-my-Homepage-Logo',
'XML-Grammar-Vered',
)
{
_git_task( 'lib/repos', $repo );
}
Shlomif::Homepage::GenScreenplaysMak->new->generate(
{ git_task => \&_git_task } );
Shlomif::Homepage::GenFictionsMak->new->generate( { git_task => \&_git_task } );
HTML::Latemp::DocBook::GenMake->new(
{ dest_var => '$(T2_DEST)', post_dest_var => '$(T2_POST_DEST)' } )
->generate;
Shlomif::Homepage::GenQuadPresMak->new->generate;
HTML::Latemp::GenWmlHSects->new->run;
$pm->wait_all_children;