/
buildperl
executable file
·507 lines (444 loc) · 12.6 KB
/
buildperl
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
#!/usr/bin/perl -w
# Copyright 2001-2009, Paul Johnson (pjcj@cpan.org)
# This software is free. It is licensed under the same terms as Perl itself.
# The latest version of this software should be available from my homepage:
# http://www.pjcj.net
use strict;
require 5.004;
use lib <~pjcj/g/tools/perl/local>;
use lib <~pjcj/wesley/g/tools/perl/local>;
use System "sys:dsys: command, error";
my $Usage =
"Usage: $0 /perl/source/code /installation [perl|modules|manual|apache|mod_perl|cpancover]";
my $Perl_src = shift || die "$Usage\n";
my $Installation = shift || die "$Usage\n";
my $Options = "@ARGV" || "perl modules manual cpancover";
my $Src_dir = <~pjcj/wesley/g/perl>;
$Src_dir = <~pjcj/g/perl> unless -d $Src_dir;
my $Perl_src_dir = "$Src_dir/src";
my $Mod_src_dir = "$Src_dir/modules";
my $Perl_installation;
my $Perl;
my $Perl_dir;
my $top = `pwd`;
chomp $top;
my $Build = "$top/build";
sub get_src
{
my ($package, $dir) = @_;
$dir ||= $Src_dir;
my $src = $package;
$src = "$package.tar.gz" unless -f $src;
$src = "$package.tar.bz2" unless -f $src;
$src = "$dir/$package" unless -f $src;
$src = "$dir/$package.tar.gz" unless -f $src;
$src = "$dir/$package.tar.bz2" unless -f $src;
$src = $package unless -f $src;
# die "Can't find $package in $dir ($Src_dir)\n" unless -f $src;
return $src;
}
sub building ($)
{
my ($option) = @_;
return $Options =~ /\b$option\b/i;
}
sub uncompress
{
$_[0] =~ /2$/ ? "bzcat" : "zcat"
}
sub build ($$$)
{
my ($module, $src_dir, $opts) = @_;
chdir $Build or die "Can't chdir $Build: $!";
my $src = get_src($module, $src_dir);
$opts =
{
"unpack" => sub { dsys uncompress($src) . " $src | tar xf -" },
dir => sub { $src =~ m|.*/(.*)\.tar\.gz$|; $1 },
config => sub { dsys "$Perl Makefile.PL" },
make => sub { dsys "make" },
test => sub { sys "make test" }, # some modules fail their tests...
install => sub { dsys "make install" },
%$opts
};
print "build $module\n";
$opts->{"unpack"}->();
my $dir = $opts->{dir}->();
chdir $dir or die "Can't chdir $dir: $!";
$opts->{config}->();
$opts->{make}->();
$opts->{test}->();
$opts->{install}->();
print "built $module\n";
}
sub feed ($$)
{
my ($command, $input) = @_;
open COMMAND, "| $command" or die "Cannot run $command:$!\n";
print COMMAND $input;
close COMMAND or die "Cannot run $command:$!\n";
}
sub main ()
{
print "Building $Options\n";
dsys "rm -rf $Build";
mkdir $Build, 0750 or die "Can't mkdir $Build: $!";
$ENV{HOME} = $Perl_installation;
if (building "perl")
{
chdir $Build or die "Can't chdir $Build: $!";
dsys "rm -rf $Perl_installation";
dsys uncompress($Perl_src) . " $Perl_src | tar xf -";
chdir $Perl_dir or die "Can't chdir $Perl_dir: $!";
my @opts =
(
"-Dperladmin='paul\@pjcj.net'",
"-Dcc=gcc",
"-Dprefix=$Perl_installation",
);
dsys "sh ./Configure -des @opts";
dsys "make";
sys "make test";
dsys "make install";
$Options =~ s/\bperl\b//;
}
$ENV{PATH} .= ":$Perl_installation/bin"; # dodgy stuff that just calls perl
exec "yes '' | $Perl $0 $Perl_src $Installation $Options" if $^X ne $Perl;
if (building "modules")
{
my @first =
qw(
HTML::Tagset
);
my @manual =
qw(
HTML::Parser
Term::ReadKey
Term::ReadLine::Perl
);
my @modules =
qw(
Bundle::LWP
ExtUtils::ParseXS
Archive::Tar
URI
Module::Build
Pod::Coverage
Bundle::CPAN
Module::Signature
Digest::base
Digest::MD5
AppConfig
Template
YAML
GD
Mail::SpamAssassin
Net::DNS
Compress::Zlib
Mime::Base64
LWP
Test::Reporter
DBI
DBD::mysql
Mail::Mailer
Bit::Vector
Date::Calc
DBD::Oracle
Digest::HMAC
Digest::SHA1
Net::SSLeay
IO::Socket::SSL
IO::Stringy
MIME::Lite
MIME::Tools
Net::Telnet
Parse::RecDescent
Spreadsheet::WriteExcel
XML::Parser
GD::Text
GD::Graph
Image::Info
Image::Size
XML::Parser::PerlSAX
XML::DOM
XML::XPath
XML::Simple
Apache::DBI
Apache::Session
Archive::Zip
SOAP::Lite
XML::Writer
Bundle::BioPerl
Bio::Perl
Error
Cache::Cache
HTML::Template
CGI::Application
CGI::Kwiki
CGI::Session
List::Util
Class::DBI
Class::Date
Config::IniFiles
Convert::ASN1
Crypt::Blowfish
Crypt::CBC
Crypt::DES
Crypt::SSLeay
Data::ShowTable
Date::Manip
Text::CSV_XS
DBD::CSV
DBD::ODBC
DBD::Pg
DBIx::SearchBuilder
IO::Tty
Expect
Params::Validate
HTML::Mason
HTML::Tree
Inline
Apache::Request
Mac::Carbon
Mac::Glue
Mail::Box
Mail::Sendmail
MD5
MP3::Info
Msql
Net::Daemon
Net::SNMP
Net::SSH::Perl
PAR
PDF::API2
PDL
Net::LDAP
Image::Magick
Pod::Simple
POE
Regexp::Common
SPOPS
Spreadsheet::ParseExcel
Text::Iconv
Text::Template
Time::ParseDate
Time::Zone
WWW::Mechanize
XML::DOM
XML::NamespaceSupport
XML::SAX
XML::LibXML
Maypole
Test::Memory::Cycle
Test::Pod::Coverage
Data/Grove.pm
Tie::IxHash
Bundle::HTML::Mason
Bundle::XML
Bundle::BricolagePlus
Bundle::Perl6
Bundle::Slash
Bundle::DateTime
Bundle::Tk
Bundle::SSH
Bundle::Test
);
# @modules = @modules[0 .. 11];
my @not_so_hot =
qw(
Bundle::Apache
);
my $config =
{
"Term::ReadLine::Perl" =>
{
test => sub
{
# interactive test - just skip it
},
},
"HTML::Parser" =>
{
config => sub
{
my $input = <<EOF;
n
EOF
feed "$Perl Makefile.PL", $input;
},
},
"Msql-Mysql-modules-1.2215" =>
{
config => sub
{
dsys "$Perl Makefile.PL" .
" --noprompt" .
" --debug" .
" --verbose" .
" --mysql-install" .
" --nomsql-install" .
" --mysql-incdir=/usr/local/pkg/mysql/include/mysql" .
" --mysql-libdir=/usr/local/pkg/mysql/lib/mysql" .
" --mysql-test-db test" .
" --mysql-test-user root" .
" --mysql-test-pass" .
" --mysql-test-host ride"
},
},
};
my $f = "$Perl_installation/.cpan";
-d $f or mkdir $f, 0750 or die "Can't mkdir $f: $!";
$f.= "/CPAN";
-d $f or mkdir $f, 0750 or die "Can't mkdir $f: $!";
$f.= "/MyConfig.pm";
open F, ">", $f or die "Can't open $f: $!";
print F <<EOF;
\$CPAN::Config = {
'build_cache' => q[100000],
'build_dir' => q[$Perl_installation/.cpan/build],
'cache_metadata' => q[1],
'cpan_home' => q[$Perl_installation/.cpan],
'dontload_hash' => { },
'ftp' => q[/usr/bin/ftp],
'ftp_proxy' => q[],
'getcwd' => q[cwd],
'gpg' => q[/usr/bin/gpg],
'gzip' => q[/bin/gzip],
'histfile' => q[$Perl_installation/.cpan/histfile],
'histsize' => q[100],
'http_proxy' => q[],
'inactivity_timeout' => q[0],
'index_expire' => q[1],
'inhibit_startup_message' => q[0],
'keep_source_where' => q[$Perl_installation/.cpan_sources],
'lynx' => q[/usr/bin/lynx],
'make' => q[/usr/bin/make],
'make_arg' => q[],
'make_install_arg' => q[],
'makepl_arg' => q[],
'ncftp' => q[],
'ncftpget' => q[],
'no_proxy' => q[],
'pager' => q[less],
'prerequisites_policy' => q[follow],
'scan_cache' => q[atstart],
'shell' => q[/bin/zsh],
'tar' => q[/bin/tar],
'term_is_latin' => q[1],
'unzip' => q[/usr/bin/unzip],
'urllist' => [q[ftp://sunsite.cnlab-switch.ch/mirror/CPAN/], q[ftp://ftp.k-informatik.ch/pub/CPAN/]],
'wget' => q[/usr/bin/wget],
};
1;
EOF
close F or die "Can't close $f: $!";
eval "use CPAN";
my $install = sub
{
my ($m) = @_;
print "Installing $m via CPAN\n";
# I wish I knew how to do this properly. I just want to
# force install the thing.
my $mod = CPAN::Shell->expandany($m);
if ($mod)
{
return if $mod->uptodate;
# $mod->force("install");
CPAN::Shell->install($_);
}
else
{
CPAN::Shell->install($_);
}
# CPAN::Shell->expandany($_)->install;
};
$install->($_) for @first;
for my $mod (@manual)
{
# my @mods = CPAN::Complete::cpl_any($mod);
# print "Mods for $mod are: @mods\n";
# next;
print "Installing $mod \n";
next unless building "manual";
my $m = CPAN::Shell->expandany($mod);
print "Getting version ", $m->cpan_version, "\n";
$m->get;
my $b = $m->cpan_file;
$b =~ s|.*/||;
$b =~ s|\.tar.gz||;
$b = "$Perl_installation/.cpan/build/$b";
die "Can't find build dir $b" unless -d $b;
# use Data::Dumper; print Dumper $m;
print "Building in $b\n";
my $c =
{
%{$config->{$mod} || {}},
unpack => sub {},
dir => sub { $b },
# make => sub {},
# test => sub {},
# install => sub { $m->install },
# install => sub { $m->install; dsys "make test install" },
};
build $mod, $b, $c;
}
$install->($_) for @modules;
}
my $apache = "apache_1.3.31";
my $mod_perl = "mod_perl-1.29";
build $apache,
$Perl_src_dir,
{
config => sub {},
make => sub {},
test => sub {},
install => sub {},
}
if building "apache";
build $mod_perl,
$Perl_src_dir,
{
config => sub
{
dsys "$Perl Makefile.PL" .
" APACHE_SRC=../$apache/src" .
" DO_HTTPD=1 USE_APACI=1 PREP_HTTPD=1 EVERYTHING=1";
},
}
if building "mod_perl";
build $apache,
$Perl_src_dir,
{
"unpack" => sub {},
config => sub
{
dsys "./configure" .
" --prefix=$Installation/$apache" .
" --enable-module=rewrite" .
" --activate-module=src/modules/perl/libperl.a";
},
}
if building "apache";
if (building "cpancover")
{
(my $dc = $0) =~ s|/[^/]+$||;
chdir $dc or die "Can't chdir $dc";
system "$Perl Makefile.PL";
system "make clean";
system "$Perl Makefile.PL";
system "make test";
system "make install";
my $od = "$Perl_installation/cpancover." . time;
my $c = "cpancover -outputdir $od" .
" -dir $Perl_installation/.cpan/build";
print "Running $c\n";
exec "yes '' | $c";
}
}
$Perl_src = get_src($Perl_src, $Perl_src_dir);
($Perl_dir) = $Perl_src =~ m!.*/(.*)\.tar\.(gz|bz2)$!;
print "perl src is $Perl_src\n";
print "perl dir is $Perl_dir\n";
$Perl_installation .= "$Installation/$Perl_dir";
$Perl = "$Perl_installation/bin/perl";
main