Apache-Test

 view release on metacpan or  search on metacpan

lib/Apache/TestBuild.pm  view on Meta::CPAN


sub system {
    my $cmd = "@_";

    info $cmd;
    return if DRYRUN;

    unless (CORE::system($cmd) == 0) {
        my $status = $? >> 8;
        die "system $cmd failed (exit status=$status)";
    }
}

sub chdir {
    my $dir = shift;
    info "chdir $dir";
    CORE::chdir $dir;
}

sub mkpath {
    my $dir = shift;

    return if -d $dir;
    info "mkpath $dir";

    return if DRYRUN;
    File::Path::mkpath([$dir], 1, 0755);
}

sub rmtree {
    my $dir = shift;

    return unless -d $dir;
    info "rmtree $dir";

    return if DRYRUN;
    File::Path::rmtree([$dir], 1, 1);
}

sub generate_script {
    my($class, $file) = @_;

    $file ||= catfile 't', 'BUILD';

    my $content = join '', <DATA>;

    Apache::Test::basic_config()->write_perlscript($file, $content);
}

unless (caller) {
    $INC{'Apache/TestBuild.pm'} = __FILE__;
    eval join '', <DATA>;
    die $@ if $@;
}

1;
__DATA__
use strict;
use warnings FATAL => 'all';

use lib qw(Apache-Test/lib);
use Apache::TestBuild ();
use Getopt::Long qw(GetOptions);
use Cwd ();

my %options = (
    prefix  => "checkout/build/install prefix",
    ssldir  => "enable ssl with given directory",
    cvstag  => "checkout with given cvs tag",
    cvsroot => "use 'anon' for anonymous cvs",
    version => "apache version (e.g. '2.0')",
    mpms    => "MPMs to build (e.g. 'prefork')",
    flavor  => "build flavor (e.g. 'debug shared')",
    modules => "enable modules (e.g. 'all exp')",
    name    => "change name of the build/install directory",
);

my %opts;

Getopt::Long::Configure(qw(pass_through));
#XXX: could be smarter here, being lazy for the moment
GetOptions(\%opts, map "$_=s", sort keys %options);

if (@ARGV) {
    print "passing extra args to configure: @ARGV\n";
}

my $home = $ENV{HOME};

$opts{prefix}  ||= join '/', Cwd::cwd(), 'farm';
#$opts{ssldir}  ||= '';
#$opts{cvstag}  ||= '';
#$opts{cvsroot} ||= '';
$opts{version} ||= '2.0';
$opts{mpms}    ||= 'prefork';
$opts{flavor}  ||= 'debug-shared';
$opts{modules} ||= 'all-exp';

#my @versions = qw(2.0);

#my @mpms = qw(prefork worker perchild);

#my @flavors  = ([qw(debug shared)], [qw(prof shared)],
#                [qw(debug static)], [qw(prof static)]);

#my @modules = ([qw(all exp)]);

my $split = sub { split '-', delete $opts{ $_[0] } };

my @versions = $opts{version};

my @mpms = $split->('mpms');

my @flavors  = ([ $split->('flavor') ]);

my @modules  = ([ $split->('modules') ]);

my $tb = Apache::TestBuild->new(fresh => 1,
                                %opts,
                                extra_config => {
                                    $opts{version} => \@ARGV,



( run in 1.014 second using v1.01-cache-2.11-cpan-39bf76dae61 )