bump version
[bioperl-db.git] / Build.PL
blobb0960c45d63d87e99cad294afca8281e244ac5b4
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 my $v = '1.006000';
10 eval "use Bio::Root::Build $v";
11 if ($@) {
12 # using die so wrappers can catch the error message
13 die "BioPerl minimal core version $v is required for BioPerl-db\n";
16 # Set up the Bio::Root::Build object
17 my $build = Bio::Root::Build->new(
18 module_name => 'Bio',
19 dist_name => 'BioPerl-db',
20 dist_version => $v,
21 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
22 dist_abstract => 'BioPerl-db - package for biological databases',
23 license => 'perl',
24 requires => {
25 'perl' => '5.6.1',
26 #'Bio::Root::Version' => '1.007000', # checked above
27 'DBI' => 0
29 dynamic_config => 1,
30 create_makefile_pl => 'passthrough'
32 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
33 #script_files => [] # scripts in scripts directory are installed on-demand
36 # Ask questions
37 biosql_conf();
38 $build->choose_scripts;
40 # Add extra things to MANIFEST.SKIP
41 $build->add_to_manifest_skip('t/DBHarness.biosql.conf');
43 # Create the build script and exit
44 $build->create_build_script;
46 exit;
49 # setup t/DBHarness.biosql.conf
50 sub biosql_conf {
51 $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";
53 my $config_file = File::Spec->catfile('t', 'DBHarness.biosql.conf');
54 if (-e $config_file) {
55 $build->y_n("Do you want to use the existing '$config_file' config file? y/n", 'y') && return;
56 unlink($config_file);
59 open(my $out, ">", $config_file) or die "Error: could not write to config file '$config_file'\n";
61 my %config = (driver => 'mysql',
62 host => '127.0.0.1',
63 user => 'root',
64 port => 3306,
65 password => '',
66 dbname => 'bioseqdb',
67 database => 'biosql',
68 schema_sql => '../biosql-schema/sql/biosqldb-mysql.sql');
70 $config{driver} = $build->prompt("DBD driver to use (mandatory)?", $config{driver});
71 $config{host} = $build->prompt("Machine to connect to (mandatory)?", $config{host});
72 $config{user} = $build->prompt("User to connect to server as (mandatory)?", $config{user});
74 $config{port} = $build->prompt("Port the server is running on (optional, '' for undef/none)?", $config{port});
75 $config{port} = undef if $config{port} eq "''";
77 $config{password} = $build->prompt("Password (optional)?", $config{password} || 'undef');
78 $config{password} = '' if $config{password} eq 'undef';
80 $build->log_info("
81 # The next answer will be used to identify the database name in
82 # the connect string, e.g., using database=, dbname=, or sid=,
83 # depending on the driver.
84 # If this is not set the test scripts will build a temporary
85 # database from scratch at the beginning and destroy it at the
86 # end. Conversely, if you do set it then the database must exist,
87 # or else the tests will fail.
88 # Generally, it is preferred to pre-build the database, simply for
89 # efficiency reasons, and it will also enable debugging your
90 # schema content if some test acts up.
91 \n");
92 $config{dbname} = $build->prompt("Name of your existing Biosql database, as it is known to your RDBMS (optional, '' for none)?", $config{dbname});
93 $config{dbname} = '' if $config{dbname} eq "''";
95 unless ($config{dbname}) {
96 $config{schema_sql} = $build->prompt("Set schema_sql to use the version appropriate for your RDBMS (mandatory)", $config{schema_sql});
98 $config{schema_sql} = "['$config{schema_sql}']"; # don't know why it is stored as an array ref, is this correct?
100 $build->log_info("
101 # The next answer does not refer to the schema or RDBMS; it only
102 # identifies which of the databases supported in bioperl-db you
103 # want to be using. Since at present bioperl-db only supports biosql,
104 # this must be biosql.
105 \n");
106 $config{database} = $build->prompt("The name of the database within bioperl-db?", $config{database});
108 print $out "{\n";
109 while (my ($key, $val) = each %config) {
110 # no empty strings, undefined conf setting should be undef (w/o quotes)
111 $val = "'$val'" unless $key eq 'schema_sql' || !defined($val);
112 if (!defined($val)) {
113 $val = 'undef';
115 print $out "\t'$key' => $val,\n";
117 print $out "}\n";
118 close($out);
120 # we deliberately don't add the config file to cleanup, but it shouldn't
121 # cause problems because it is in MANIFEST.SKIP