3 # This is a Module::Build script for BioPerl-DB installation.
4 # See http://search.cpan.org/~kwilliams/Module-Build/lib/Module/Build.pm
12 # add any supported drivers here
13 my @supported = qw(mysql Pg Oracle);
15 my $build = Module
::Build
->new(
16 module_name
=> 'Bio::DB::BioDB',
17 dist_name
=> 'BioPerl-DB',
18 dist_version
=> '1.006900',
19 dist_author
=> 'BioPerl Team <bioperl-l@bioperl.org>',
20 dist_abstract
=> 'BioPerl-DB - package for biological databases',
24 'Bio::Root::Version' => '1.006900',
28 'Graph::Directed' => 0
32 description
=> "Postgres databases",
33 requires
=> { 'DBD::Pg' => 0},
36 description
=> "MySQL databases",
37 requires
=> { 'DBD::mysql' => 0},
40 description
=> "Oracle databases",
41 requires
=> { 'DBD::Oracle' => 0},
45 create_makefile_pl
=> 'passthrough'
48 my $accept = $build->args->{accept};
50 # Ask questions for db configuration (Harness file)
53 # Optionally have script files installed.
54 if ($accept ?
0 : $build->y_n("Install scripts? y/n", 'n')) {
55 my $files = $build->_find_file_by_type('pl', 'scripts');
57 my $script_build = File
::Spec
->catdir($build->blib, 'script');
60 while (my ($file, $dest) = each %$files) {
61 $dest = 'bp_'.File
::Basename
::basename
($dest);
62 $dest = File
::Spec
->catfile($script_build, $dest);
63 $build->copy_if_modified(from
=> $file, to
=> $dest);
67 $build->script_files(\
@tobp);
70 # Create the build script and exit
71 $build->create_build_script;
75 # setup t/DBHarness.biosql.conf
77 my $continue = $accept ||
78 $build->y_n("Have you already installed BioSQL? y/n", 'y');
80 die "\nBioSQL must be installed prior to installation of bioperl-db; ".
81 "see the INSTALL file\n";
83 my @drivers = grep {$build->features($_.'_support')}
86 die "You must install a supported database driver\n" unless @drivers;
88 my $config_file = File
::Spec
->catfile('t', 'DBHarness.biosql.conf');
89 if (-e
$config_file) {
90 ($accept || $build->y_n(
91 "Do you want to use the existing '$config_file' config file? y/n",
96 open(my $out, ">", $config_file)
97 or die "Error: could not write to config file '$config_file'\n";
99 my %config = (driver
=> $drivers[0],
104 dbname
=> 'bioseqdb',
105 database
=> 'biosql',
106 schema_sql
=> '../biosql-schema/sql/biosqldb-mysql.sql');
108 $config{driver
} = $build->prompt("DBD driver to use (mandatory)?",
110 $config{host
} = $build->prompt("Machine to connect to (mandatory)?",
112 $config{user
} = $build->prompt("User to connect to server as (mandatory)?",
115 $config{port
} = $build->prompt("Port the server is running on (optional, ".
116 "'' for undef/none)?", $config{port
});
117 $config{port
} = undef if $config{port
} eq "''";
119 $config{password
} = $build->prompt("Password (optional)?",
120 $config{password
} || 'undef');
121 $config{password
} = '' if $config{password
} eq 'undef';
123 $build->log_info(<<COMMENT);
124 # The next answer will be used to identify the database name in
125 # the connect string, e.g., using database=, dbname=, or sid=,
126 # depending on the driver.
128 # If this is not set the test scripts will build a temporary
129 # database from scratch at the beginning and destroy it at the
130 # end. Conversely, if you do set it then the database must exist,
131 # or else the tests will fail.
133 # Generally, it is preferred to pre-build the database, simply for
134 # efficiency reasons, and it will also enable debugging your
135 # schema content if some test acts up.\n
137 $config{dbname
} = $build->prompt("Name of your existing Biosql database, ".
138 "as it is known to your RDBMS ".
139 "(optional, '' for none)?",
141 $config{dbname
} = '' if $config{dbname
} eq "''";
143 unless ($config{dbname
}) {
144 $config{schema_sql
} = $build->prompt("Set schema_sql to use the ".
145 "version appropriate for your ".
147 $config{schema_sql
});
149 # don't know why it is stored as an array ref, is this correct?
150 $config{schema_sql
} = "['$config{schema_sql}']";
152 $build->log_info(<<COMMENT);
153 # The next answer does not refer to the schema or RDBMS; it only
154 # identifies which of the databases supported in bioperl-db you
155 # want to be using. Since at present bioperl-db only supports biosql,
156 # this must be biosql.
158 $config{database
} = $build->prompt("The name of the database within ".
159 "bioperl-db?", $config{database
});
162 while (my ($key, $val) = each %config) {
163 # no empty strings, undefined conf setting should be undef (w/o quotes)
164 $val = "'$val'" unless $key eq 'schema_sql' || !defined($val);
165 if (!defined($val)) {
168 print $out "\t'$key' => $val,\n";
173 # maybe add the capability of using a temporary (test) database, and
174 # load the SQL on the fly? A little trickier (SQL is in a different
175 # repo and is driver-dependent)
177 # probably should add a database ping here and die gracefully otherwise.
179 # we deliberately don't add the config file to cleanup, but it shouldn't
180 # cause problems because it is in MANIFEST.SKIP