removing MANIFEST.SKIP (yes, I know, changing a tag is bad, yada yada yada)
[bioperl-db.git] / Build.PL
blob24acc0a507c2fa5cfdae3dbbfc758a21f7bd2417
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 use strict;
7 use warnings;
8 use Module::Build;
9 use File::Spec;
10 use File::Basename;
12 my $build = Module::Build->new(
13 module_name => 'Bio::DB',
14 dist_name => 'BioPerl-DB',
15 dist_version => '1.006000_001',
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.006001',
22 'DBI' => 0
24 recommends => {
25 'Graph::Directed' => 0
27 get_options => {
28 accept => { }
30 dynamic_config => 1,
31 create_makefile_pl => 'passthrough'
34 my $accept = $build->args->{accept};
36 # Ask questions for db configuration (Harness file)
37 biosql_conf();
39 # Optionally have script files installed.
40 if ($accept ? 0 : $build->y_n("Install scripts? y/n", 'n')) {
41 my $files = $build->_find_file_by_type('pl', 'scripts');
43 my $script_build = File::Spec->catdir($build->blib, 'script');
45 my @tobp;
46 while (my ($file, $dest) = each %$files) {
47 $dest = 'bp_'.File::Basename::basename($dest);
48 $dest = File::Spec->catfile($script_build, $dest);
49 $build->copy_if_modified(from => $file, to => $dest);
50 push @tobp, $dest;
53 $build->script_files(\@tobp);
56 # Create the build script and exit
57 $build->create_build_script;
59 exit;
61 # setup t/DBHarness.biosql.conf
62 sub biosql_conf {
63 my $continue = $accept || $build->y_n("Have you already installed BioSQL? y/n", 'y');
64 $continue || die "\nBioSQL must be installed prior to installation of bioperl-db; see the INSTALL file\n";
66 my $config_file = File::Spec->catfile('t', 'DBHarness.biosql.conf');
67 if (-e $config_file) {
68 ($accept || $build->y_n("Do you want to use the existing '$config_file' config file? y/n", 'y')) && return;
69 unlink($config_file);
72 open(my $out, ">", $config_file) or die "Error: could not write to config file '$config_file'\n";
74 my %config = (driver => 'mysql',
75 host => '127.0.0.1',
76 user => 'root',
77 port => 3306,
78 password => '',
79 dbname => 'bioseqdb',
80 database => 'biosql',
81 schema_sql => '../biosql-schema/sql/biosqldb-mysql.sql');
83 $config{driver} = $build->prompt("DBD driver to use (mandatory)?", $config{driver});
84 $config{host} = $build->prompt("Machine to connect to (mandatory)?", $config{host});
85 $config{user} = $build->prompt("User to connect to server as (mandatory)?", $config{user});
87 $config{port} = $build->prompt("Port the server is running on (optional, '' for undef/none)?", $config{port});
88 $config{port} = undef if $config{port} eq "''";
90 $config{password} = $build->prompt("Password (optional)?", $config{password} || 'undef');
91 $config{password} = '' if $config{password} eq 'undef';
93 $build->log_info("
94 # The next answer will be used to identify the database name in
95 # the connect string, e.g., using database=, dbname=, or sid=,
96 # depending on the driver.
97 # If this is not set the test scripts will build a temporary
98 # database from scratch at the beginning and destroy it at the
99 # end. Conversely, if you do set it then the database must exist,
100 # or else the tests will fail.
101 # Generally, it is preferred to pre-build the database, simply for
102 # efficiency reasons, and it will also enable debugging your
103 # schema content if some test acts up.
104 \n");
105 $config{dbname} = $build->prompt("Name of your existing Biosql database, as it is known to your RDBMS (optional, '' for none)?", $config{dbname});
106 $config{dbname} = '' if $config{dbname} eq "''";
108 unless ($config{dbname}) {
109 $config{schema_sql} = $build->prompt("Set schema_sql to use the version appropriate for your RDBMS (mandatory)", $config{schema_sql});
111 $config{schema_sql} = "['$config{schema_sql}']"; # don't know why it is stored as an array ref, is this correct?
113 $build->log_info("
114 # The next answer does not refer to the schema or RDBMS; it only
115 # identifies which of the databases supported in bioperl-db you
116 # want to be using. Since at present bioperl-db only supports biosql,
117 # this must be biosql.
118 \n");
119 $config{database} = $build->prompt("The name of the database within bioperl-db?", $config{database});
121 print $out "{\n";
122 while (my ($key, $val) = each %config) {
123 # no empty strings, undefined conf setting should be undef (w/o quotes)
124 $val = "'$val'" unless $key eq 'schema_sql' || !defined($val);
125 if (!defined($val)) {
126 $val = 'undef';
128 print $out "\t'$key' => $val,\n";
130 print $out "}\n";
131 close($out);
133 # we deliberately don't add the config file to cleanup, but it shouldn't
134 # cause problems because it is in MANIFEST.SKIP