BioPerl-DB

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

# This is a Module::Build script for BioPerl-DB installation.
# See http://search.cpan.org/~kwilliams/Module-Build/lib/Module/Build.pm

use strict;
use warnings;
use Module::Build;
use File::Spec;
use File::Basename;

# add any supported drivers here
my @supported = qw(mysql Pg Oracle);

my $build = Module::Build->new(
    module_name         => 'Bio::DB::BioDB',
    dist_name           => 'BioPerl-DB',
    dist_version        => '1.006900',
    dist_author         => 'BioPerl Team <bioperl-l@bioperl.org>',
    dist_abstract       => 'BioPerl-DB - package for biological databases',
    license             => 'perl',
    requires            => {
                        'perl'               => '5.6.1',
                        'Bio::Root::Version' => '1.006900',
                        'DBI'                => 0
        },
    recommends          => {
                        'Graph::Directed'   => 0
        },
    auto_features => {
        Pg_support          => {
                          description => "Postgres databases",
                          requires    => { 'DBD::Pg' => 0},
                         },
        mysql_support       => {
                          description => "MySQL databases",
                          requires    => { 'DBD::mysql' => 0},
                         },
        Oracle_support      => {
                          description => "Oracle databases",
                          requires    => { 'DBD::Oracle' => 0},
                         },
    },
    dynamic_config      => 1,
    create_makefile_pl  => 'passthrough'
);

my $accept = $build->args->{accept};

# Ask questions for db configuration (Harness file)
biosql_conf();

# Optionally have script files installed.
if ($accept ? 0 : $build->y_n("Install scripts? y/n", 'n')) {
    my $files = $build->_find_file_by_type('pl', 'scripts');
    
    my $script_build = File::Spec->catdir($build->blib, 'script');
    
    my @tobp;
    while (my ($file, $dest) = each %$files) {
        $dest = 'bp_'.File::Basename::basename($dest);
        $dest = File::Spec->catfile($script_build, $dest);
        $build->copy_if_modified(from => $file, to => $dest);
        push @tobp, $dest;
    }
    
    $build->script_files(\@tobp);
}

# Create the build script and exit
$build->create_build_script;

exit;

# setup t/DBHarness.biosql.conf
sub biosql_conf {
    my $continue = $accept ||
        $build->y_n("Have you already installed BioSQL? y/n", 'y');
    $continue ||
        die "\nBioSQL must be installed prior to installation of bioperl-db; ".
        "see the INSTALL file\n";
    
    my @drivers = grep {$build->features($_.'_support')}
         qw(mysql Pg Oracle);
    
    die "You must install a supported database driver\n" unless @drivers;
    
    my $config_file = File::Spec->catfile('t', 'DBHarness.biosql.conf');
    if (-e $config_file) {
        ($accept || $build->y_n(
            "Do you want to use the existing '$config_file' config file? y/n",
            'y')) && return;
        unlink($config_file);
    }
    
    open(my $out, ">", $config_file)
        or die "Error: could not write to config file '$config_file'\n";
    
    my %config = (driver     => $drivers[0],
                  host       => '127.0.0.1',
                  user       => 'root',
                  port       => 3306,
                  password   => '',
                  dbname     => 'bioseqdb',
                  database   => 'biosql',
                  schema_sql => '../biosql-schema/sql/biosqldb-mysql.sql');
    
    $config{driver} = $build->prompt("DBD driver to use (mandatory)?",
                                     $config{driver});
    $config{host} = $build->prompt("Machine to connect to (mandatory)?",
                                   $config{host});
    $config{user} = $build->prompt("User to connect to server as (mandatory)?",
                                   $config{user});
    
    $config{port} = $build->prompt("Port the server is running on (optional, ".
                                   "'' for undef/none)?", $config{port});
    $config{port} = undef if $config{port} eq "''";
    
    $config{password} = $build->prompt("Password (optional)?",
                                       $config{password} || 'undef');
    $config{password} = '' if $config{password} eq 'undef';
    
    $build->log_info(<<COMMENT);



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