* convert over to Module::Build
[bioperl-db.git] / Build.PL
blob20df9dec3da360be3da9dff49db1b1d401535d0b
1 #!/usr/bin/perl -w
3 # This is a Module::Build script for bioperl-db installation.
4 # See http://search.cpan.org/~kwilliams/Module-Build/lib/Module/Build.pm
6 # Uses a custom subclass of Module::Build called Bio::Root::Build
8 use strict;
9 use warnings;
10 use Module::Build;
12 # Set up the Bio::Root::Build object
13 my $build = Module::Build->new(
14 module_name => 'Bio',
15 dist_name => 'BioPerl-db',
16 dist_version => '1.006009',
17 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
18 dist_abstract => 'BioPerl-db - package for biological databases',
19 license => 'perl',
20 requires => {
21 'perl' => '5.6.1',
22 'Bio::Root::Version' => '1.006000', # checked above
23 'DBI' => 0
25 dynamic_config => 1,
26 create_makefile_pl => 'passthrough'
28 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
29 #script_files => [] # scripts in scripts directory are installed on-demand
32 # Ask questions
33 biosql_conf();
35 # no scripts
36 #$build->choose_scripts;
38 # Create the build script and exit
39 $build->create_build_script;
41 exit;
43 # setup t/DBHarness.biosql.conf
44 sub biosql_conf {
45 $build->y_n("Have you already installed BioSQL? y/n", 'n') || die "\nBioSQL must be installed prior to installation of bioperl-db; see the INSTALL file\n";
47 my $config_file = File::Spec->catfile('t', 'DBHarness.biosql.conf');
48 if (-e $config_file) {
49 $build->y_n("Do you want to use the existing '$config_file' config file? y/n", 'y') && return;
50 unlink($config_file);
53 open(my $out, ">", $config_file) or die "Error: could not write to config file '$config_file'\n";
55 my %config = (driver => 'mysql',
56 host => '127.0.0.1',
57 user => 'root',
58 port => 3306,
59 password => '',
60 dbname => 'bioseqdb',
61 database => 'biosql',
62 schema_sql => '../biosql-schema/sql/biosqldb-mysql.sql');
64 $config{driver} = $build->prompt("DBD driver to use (mandatory)?", $config{driver});
65 $config{host} = $build->prompt("Machine to connect to (mandatory)?", $config{host});
66 $config{user} = $build->prompt("User to connect to server as (mandatory)?", $config{user});
68 $config{port} = $build->prompt("Port the server is running on (optional, '' for undef/none)?", $config{port});
69 $config{port} = undef if $config{port} eq "''";
71 $config{password} = $build->prompt("Password (optional)?", $config{password} || 'undef');
72 $config{password} = '' if $config{password} eq 'undef';
74 $build->log_info("
75 # The next answer will be used to identify the database name in
76 # the connect string, e.g., using database=, dbname=, or sid=,
77 # depending on the driver.
78 # If this is not set the test scripts will build a temporary
79 # database from scratch at the beginning and destroy it at the
80 # end. Conversely, if you do set it then the database must exist,
81 # or else the tests will fail.
82 # Generally, it is preferred to pre-build the database, simply for
83 # efficiency reasons, and it will also enable debugging your
84 # schema content if some test acts up.
85 \n");
86 $config{dbname} = $build->prompt("Name of your existing Biosql database, as it is known to your RDBMS (optional, '' for none)?", $config{dbname});
87 $config{dbname} = '' if $config{dbname} eq "''";
89 unless ($config{dbname}) {
90 $config{schema_sql} = $build->prompt("Set schema_sql to use the version appropriate for your RDBMS (mandatory)", $config{schema_sql});
92 $config{schema_sql} = "['$config{schema_sql}']"; # don't know why it is stored as an array ref, is this correct?
94 $build->log_info("
95 # The next answer does not refer to the schema or RDBMS; it only
96 # identifies which of the databases supported in bioperl-db you
97 # want to be using. Since at present bioperl-db only supports biosql,
98 # this must be biosql.
99 \n");
100 $config{database} = $build->prompt("The name of the database within bioperl-db?", $config{database});
102 print $out "{\n";
103 while (my ($key, $val) = each %config) {
104 # no empty strings, undefined conf setting should be undef (w/o quotes)
105 $val = "'$val'" unless $key eq 'schema_sql' || !defined($val);
106 if (!defined($val)) {
107 $val = 'undef';
109 print $out "\t'$key' => $val,\n";
111 print $out "}\n";
112 close($out);
114 # we deliberately don't add the config file to cleanup, but it shouldn't
115 # cause problems because it is in MANIFEST.SKIP