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 my $build = Module
::Build
->new(
13 module_name
=> 'Bio::DB',
14 dist_name
=> 'BioPerl-DB',
15 dist_version
=> '1.006900',
16 dist_author
=> 'BioPerl Team <bioperl-l@bioperl.org>',
17 dist_abstract
=> 'BioPerl-DB - package for biological databases',
21 'Bio::Root::Version' => '1.006009',
28 create_makefile_pl
=> 'passthrough'
31 my $accept = $build->args->{accept};
33 # Ask questions for db configuration (Harness file)
36 # Optionally have script files installed.
37 if ($accept ?
0 : $build->y_n("Install scripts? y/n", 'n')) {
38 my $files = $build->_find_file_by_type('pl', 'scripts');
40 my $script_build = File
::Spec
->catdir($build->blib, 'script');
43 while (my ($file, $dest) = each %$files) {
44 $dest = 'bp_'.File
::Basename
::basename
($dest);
45 $dest = File
::Spec
->catfile($script_build, $dest);
46 $build->copy_if_modified(from
=> $file, to
=> $dest);
50 $build->script_files(\
@tobp);
53 # Create the build script and exit
54 $build->create_build_script;
58 # setup t/DBHarness.biosql.conf
60 my $continue = $accept || $build->y_n("Have you already installed BioSQL? y/n", 'y');
61 $continue || die "\nBioSQL must be installed prior to installation of bioperl-db; see the INSTALL file\n";
63 my $config_file = File
::Spec
->catfile('t', 'DBHarness.biosql.conf');
64 if (-e
$config_file) {
65 ($accept || $build->y_n("Do you want to use the existing '$config_file' config file? y/n", 'y')) && return;
69 open(my $out, ">", $config_file) or die "Error: could not write to config file '$config_file'\n";
71 my %config = (driver
=> 'mysql',
78 schema_sql
=> '../biosql-schema/sql/biosqldb-mysql.sql');
80 $config{driver
} = $build->prompt("DBD driver to use (mandatory)?", $config{driver
});
81 $config{host
} = $build->prompt("Machine to connect to (mandatory)?", $config{host
});
82 $config{user
} = $build->prompt("User to connect to server as (mandatory)?", $config{user
});
84 $config{port
} = $build->prompt("Port the server is running on (optional, '' for undef/none)?", $config{port
});
85 $config{port
} = undef if $config{port
} eq "''";
87 $config{password
} = $build->prompt("Password (optional)?", $config{password
} || 'undef');
88 $config{password
} = '' if $config{password
} eq 'undef';
91 # The next answer will be used to identify the database name in
92 # the connect string, e.g., using database=, dbname=, or sid=,
93 # depending on the driver.
94 # If this is not set the test scripts will build a temporary
95 # database from scratch at the beginning and destroy it at the
96 # end. Conversely, if you do set it then the database must exist,
97 # or else the tests will fail.
98 # Generally, it is preferred to pre-build the database, simply for
99 # efficiency reasons, and it will also enable debugging your
100 # schema content if some test acts up.
102 $config{dbname
} = $build->prompt("Name of your existing Biosql database, as it is known to your RDBMS (optional, '' for none)?", $config{dbname
});
103 $config{dbname
} = '' if $config{dbname
} eq "''";
105 unless ($config{dbname
}) {
106 $config{schema_sql
} = $build->prompt("Set schema_sql to use the version appropriate for your RDBMS (mandatory)", $config{schema_sql
});
108 $config{schema_sql
} = "['$config{schema_sql}']"; # don't know why it is stored as an array ref, is this correct?
111 # The next answer does not refer to the schema or RDBMS; it only
112 # identifies which of the databases supported in bioperl-db you
113 # want to be using. Since at present bioperl-db only supports biosql,
114 # this must be biosql.
116 $config{database
} = $build->prompt("The name of the database within bioperl-db?", $config{database
});
119 while (my ($key, $val) = each %config) {
120 # no empty strings, undefined conf setting should be undef (w/o quotes)
121 $val = "'$val'" unless $key eq 'schema_sql' || !defined($val);
122 if (!defined($val)) {
125 print $out "\t'$key' => $val,\n";
130 # we deliberately don't add the config file to cleanup, but it shouldn't
131 # cause problems because it is in MANIFEST.SKIP