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