Alzabo

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

    $build->notes( test_config => $tests );

    $build->add_to_cleanup( File::Spec->catdir( 't', 'schemas' ),
                            File::Spec->catfile( 'lib', 'Alzabo', 'Config.pm' ),
                          );
}

sub config
{
    # try to see if there is an existing Alzabo installation
    eval { require Alzabo; };
    eval { require Alzabo::Config; };

    if ( ! $@ &&
         %Alzabo::Config::CONFIG &&
         defined Alzabo::Config::root_dir() &&
         length Alzabo::Config::root_dir() &&
         -d Alzabo::Config::root_dir() &&
         Alzabo::Config::available_schemas() && $Alzabo::VERSION < 0.55 )
    {
        print <<'EOF';

You appear to have schemas created with an older version of Alzabo.
If you want to continue to use these, you may need to run the
convert.pl script in the eg/ directory _before_ installing this
version of Alzabo.

For newer versions, starting with the transition from 0.64 to 0.65,
Alzabo automatically converts schemas as needed.

EOF

        exit unless Module::Build->y_n( '  Continue?', 'no' );
    }

    my %config;

    $config{root_dir} = root_dir();

    my ( $prereqs, $tests ) = features();

    my $test_config = test_config($tests);

    return \%config, $prereqs, $test_config;
}

sub root_dir
{
    my $root_dir =
        ( $opts{root}
          ? $opts{root}
          : %Alzabo::Config::CONFIG
          ? Alzabo::Config::root_dir()
          : find_possible_root()
        );

    return $root_dir if $opts{automated};

    print <<'EOF';

Please select a root directory for Alzabo (schema files will be stored
under this root.
EOF

    return Module::Build->prompt( '  Alzabo root?', $root_dir );
}

sub find_possible_root
{
    my @dirs;

    if ( $^O =~ /win/i )
    {
	# A bit too thorough?
	foreach ('C'..'Z')
	{
	    unshift @dirs, "$_:\\Program Files";
	}
    }
    else
    {
	@dirs = qw( /var/lib /usr/local );
    }

    unshift @dirs, '/opt' if $^O =~ /solaris/i;

    foreach (@dirs)
    {
	$_ .= '/alzabo';

	return $_ if -e $_;
    }

    return '';
}

sub features
{
    # These are always needed
    my %prereqs = default_prereqs();

    my ( %tests );

    # extra prereqs for certain features
    my %features =
        ( mysql => { phrase   => 'to use the MySQL driver',
                     requires => { 'DBD::mysql' => 2.1017 },
                     test     => 'mysql',
                   },

          pg    => { phrase     => 'to use the PostgreSQL driver',
                     requires   => { 'DBD::Pg' => 1.13,
                                     'Text::Balanced' => 0,
                                     'Digest::MD5' => 0,
                                   },
                     test   => 'pg',
                   },
        );

    if ( $opts{automated} )
    {



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