App-Bootstrap-Perl
view release on metacpan or search on metacpan
bin/bootstrap-perl view on Meta::CPAN
bootstrap_perl_cpan_mirrors='! .join(";", @CPANMIRRORS) .qq!'
bootstrap_perl_modules='! .join(";", @MODULES) .qq!'
bootstrap_perl_scripts='! .join(";", map { $_ ." ".join(" ", @RUNARGS) } @RUNSCRIPTS) .qq!'
EOUUCONFIG
!;
};
close $config_arch;
# ========== Configure ==========
print_and_system_out "cd $build_path_perl; sh Configure -der -Dusedevel $USETHREADS $BIT64 $TAINTSUPPORT $CONFARGS -Dprefix=$PREFIX";
# ========== make ==========
print_and_system "cd $build_path_perl; make $THREADS";
if ($test)
{
my $api_version = print_and_qx_chomp qq!cd $build_path_perl; . ./config.sh && echo \$api_version!;
my $TEST = $api_version >= 11 ? "test_harness" : "test"; # only Perl 5.11+
my $TEST_JOBS = $jobs ? "TEST_JOBS=$jobs" : "TEST_JOBS=$threadcount";
print_and_system "cd $build_path_perl; $TEST_JOBS make $TEST";
}
# ========== install ==========
print_and_system "cd $build_path_perl; make $DRY install";
} else {
print $USER "*** SKIP building perl - found $perl_exe\n";
}
# binaries
my $CPAN = print_and_qx_chomp qq!ls -drt1 $PREFIX/bin/cpan5.*.* | tail -1!;
my $PERL = print_and_qx_chomp qq!ls -drt1 $PREFIX/bin/perl5.*.* | tail -1!;
my $PERLDOC = print_and_qx_chomp qq!ls -drt1 $PREFIX/bin/perldoc5.*.* | tail -1!;
my $POD2TEXT = print_and_qx_chomp qq!ls -drt1 $PREFIX/bin/pod2text5.*.* | tail -1!;
# cpan config
my $CFG = print_and_qx_chomp qq!$PERLDOC -l CPAN | sed -e "s/CPAN\.pm/CPAN\\/Config.pm/"!;
my $MYCFG = print_and_qx_chomp qq!$PERLDOC -l CPAN | sed -e "s/CPAN\.pm/CPAN\\/MyConfig.pm/"!;
my $bin_perl = "$PREFIX/bin/perl";
my $bin_cpan = "$PREFIX/bin/cpan";
my $bin_perldoc = "$PREFIX/bin/perldoc";
my $bin_pod2text = "$PREFIX/bin/pod2text";
my $bin_mycpan = "$PREFIX/bin/mycpan";
# some dists don't find the versioned developer files
print_and_system "if [ ! -e $bin_perl ] ; then ln -sf $PERL $bin_perl ; echo Created symlink $bin_perl ; else echo Already exists: $bin_perl ; fi";
print_and_system "if [ ! -e $bin_cpan ] ; then ln -sf $CPAN $bin_cpan ; echo Created symlink $bin_cpan ; else echo Already exists: $bin_cpan ; fi";
print_and_system "if [ ! -e $bin_perldoc ] ; then ln -sf $PERLDOC $bin_perldoc ; echo Created symlink $bin_perldoc ; else echo Already exists: $bin_perldoc ; fi";
print_and_system "if [ ! -e $bin_pod2text ] ; then ln -sf $POD2TEXT $bin_pod2text ; echo Created symlink $bin_pod2text ; else echo Already exists: $bin_pod2text ; fi";
# our own cpan cmd with explicit config
if (not -e $bin_mycpan) {
open (my $MYCPAN, '>', $bin_mycpan) or die "Can not create $bin_mycpan";
print $MYCPAN qq{#! /bin/bash\n};
print $MYCPAN qq{$CPAN -j $CFG "\$\@"\n};
close $MYCPAN;
print_and_system qq!chmod +x $bin_mycpan!;
}
print $USER "# PERL: $PERL\n";
print $USER "# CPAN: $CPAN\n";
print $USER "# MYCPAN: $bin_mycpan\n";
print $USER "# PERLDOC: $PERLDOC\n";
print $USER "# POD2TEXT: $POD2TEXT\n";
print $USER "# CPANCFG: $CFG\n";
sub bin_cpan { $bin_cpan || "" }
# ========== cpan ==========
sub install_cpan_module {
my ($perl, $cpan, $cfg, $reinstall, $force, $module) = @_;
my $_f = ($force) ? "-f" : "";
# remember shell bool logic, exitcode!=0 means fail means we install
if (system "$perl -M$module -e1 2> /dev/null" || $reinstall) { # already exists or reinstall
print_and_system qq{$cpan -j $cfg $_f -i $module};
}
}
if ($cpan)
{
print $USER "*** PREPARE cpan\n";
# distroprefs: get all from git
print_and_system "mkdir -p $DISTROPREFSSRCBASE";
print_and_system "cd $DISTROPREFSSRCBASE && git clone $DISTROPREFSREPO" unless -d "$DISTROPREFSSRCBASE/cpanpm-distroprefs";
print_and_system "cd $DISTROPREFSSRCBASE/cpanpm-distroprefs && git pull";
print_and_system "cd $DISTROPREFSSRCBASE/cpanpm-distroprefs && git submodule update --init --recursive";
print_and_system "cd $DISTROPREFSSRCBASE/cpanpm-distroprefs && git pull";
# distroprefs: merge our flavour
print_and_system qq!mkdir -p $DISTROPREFSDIR!;
print_and_system qq!rsync -r $DISTROPREFSSRC1/ $DISTROPREFSDIR/!;
print_and_system qq!rsync -r $DISTROPREFSSRC2/ $DISTROPREFSDIR/!;
# Cleanup build dir
print_and_system qq!rm -fr $CPANBUILDDIR!;
# Configure CPAN initially
if ($forcecpancfg or ! -e $CFG) {
print $USER "*** CONFIGURE cpan\n";
my $CPANCFG = do { local $/; <DATA> };
my $MIRRORSLIST = join(" ", @CPANMIRRORS);
$CPANCFG =~ s/__DISTROPREFSDIR__/$DISTROPREFSDIR/g;
$CPANCFG =~ s/__MIRRORS__/$MIRRORSLIST/g;
$CPANCFG =~ s/__PREFIXBASE__/$prefixbase/g;
# the real cpan config
open my $CPANCFGFILE, ">", $CFG or die "Can not create $CFG";
print $CPANCFGFILE $CPANCFG;
close $CPANCFGFILE;
# empty MyConfig to suppress loading one from ~/.cpan/
open my $MYCPANCFGFILE, ">", $MYCFG or die "Can not create $MYCFG";
print $MYCPANCFGFILE "package CPAN::MyConfig;\n1;\n\n=head1 ABOUT\n\nEmpty CPAN::MyConfig to suppress loading one from C<~/.cpan/>.\n\n=cut\n\n";
close $MYCPANCFGFILE;
} else {
print $USER "*** SKIP configuring cpan".(-e $CFG ? " - found $CFG" : "")."\n";
}
# remove stale cpan lock
my $cpanlock = "$prefixbase/cpan/.lock";
if (-e $cpanlock) {
my ($pid, $host) = qx!cat $cpanlock!;
chomp $pid;
my $exists = kill 0, $pid;
if (not $exists) {
print $LOGFILE "# Remove stale CPAN.pm lock.\n";
print_and_system qq!rm -f $cpanlock!;
}
}
# optionally remove sources cache to avoid conflicts,
# like happening with hot-patched CPAN mirrors (via Pinto)
if ($cleancpansources) {
print $LOGFILE "# Remove $SOURCESDIR.\n";
print_and_system qq!rm -fr '$SOURCESDIR'!;
}
# force a CPAN.pm with all features we need, assume old-school CPAN.pm
print_and_system qq{if [ -L $bin_cpan -o ! -e $bin_cpan ] ; then echo Why?: /bin/rm -f $bin_cpan ; echo "force install CPAN" | $PERL -MCPAN -e shell ; fi};
# once upon a time the cpan exe missed the executable bit - set it to be sure
print_and_system qq!chmod +x $CPAN!;
print_and_system qq!chmod +x $bin_cpan!;
print $USER "*** INSTALL cpan dependencies\n";
# install extended cpan toolchain; contains some "force" where we know they are really required
install_cpan_module($PERL, $bin_cpan, $CFG, NO_REINSTALL, FORCE, "CPAN::DistnameInfo");
install_cpan_module($PERL, $bin_cpan, $CFG, NO_REINSTALL, FORCE, "HTTP::Date");
install_cpan_module($PERL, $bin_cpan, $CFG, NO_REINSTALL, FORCE, "ExtUtils::Config");
install_cpan_module($PERL, $bin_cpan, $CFG, NO_REINSTALL, FORCE, "YAML::XS");
install_cpan_module($PERL, $bin_cpan, $CFG, NO_REINSTALL, FORCE, "YAML");
# try really hard with some modules until we find a version
# that fits currrent Perl
my %mod_dists = (
"YAML" => [qw(TINITA/YAML-1.30.tar.gz
MSTROUT/YAML-0.84.tar.gz
MSTROUT/YAML-0.83.tar.gz
MSTROUT/YAML-0.82.tar.gz
INGY/YAML-0.81.tar.gz
INGY/YAML-0.80.tar.gz
INGY/YAML-0.79.tar.gz
INGY/YAML-0.78.tar.gz
INGY/YAML-0.77.tar.gz
INGY/YAML-0.76.tar.gz)],
# "Devel::Size" => [qw(NWCLARK/Devel-Size-0.78.tar.gz
# NWCLARK/Devel-Size-0.77.tar.gz
# NWCLARK/Devel-Size-0.76.tar.gz
# NWCLARK/Devel-Size-0.75.tar.gz
# BROWSERUK/Devel-Size-0.72.tar.gz
# TELS/devel/Devel-Size-0.71.tar.gz
# TELS/devel/Devel-Size-0.70.tar.gz)],
);
foreach my $mod (keys %mod_dists) {
foreach my $dist (@{$mod_dists{$mod}}) {
print_and_system qq{if ! $PERL -M$mod -e1 ; then $bin_cpan -j $CFG $dist ; fi };
}
install_cpan_module($PERL, $bin_cpan, $CFG, REINSTALL, NO_FORCE, $mod);
}
print_and_system qq{if ! $PERL -MIO::Compress::Base -e1 ; then $bin_cpan -j $CFG -f -i IO::Compress::Base ; fi };
if ($gitdescribe =~ /perl-5\.8\.0/) {
# ignore known failing tests
print_and_system qq!$bin_cpan -j $CFG -f -i Module::Build!;
}
if ($gitdescribe =~ /perl-5\.8\./) {
# test failure on some of my machines
print_and_system qq!$bin_cpan -j $CFG -f -i List::MoreUtils!;
}
if ($gitdescribe =~ /perl-5\.9\./) {
# ignore known hanging tests with utf8
print_and_system qq! echo "notest install Test::Simple" | $bin_cpan -j $CFG!;
}
# install dependencies needed for CPAN itself
foreach my $module (qw(version YAML::Syck IO::Tty Expect LWP Task::Bootstrap::Perl::CPAN)) {
install_cpan_module($PERL, $bin_cpan, $CFG, NO_REINSTALL, FORCE, $module);
}
if ($perlformance || $perlformance_report) {
print $USER "AAAA::Mail::SpamAssassin (for Benchmark::Perl::Formance)\n";
install_cpan_module($PERL, $bin_cpan, $CFG, REINSTALL, NO_FORCE, "AAAA::Mail::SpamAssassin");
( run in 2.299 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )