9 bp_netinstall.pl -b|--build_param_str BUILD_STRING [options]
13 -h|--help Show this message
14 -d|--dev Use the development version of bioperl from git
15 --build_param_str=<args> Parameters that are passed in at 'perl Build.PL'
16 --install_param_str=<args>
17 Use this string to predefine './Build install'
18 parameters such as 'install_base' for
20 --bioperl_path Path to BioPerl tarball (will not download BioPerl)
21 --skip_start Don't wait for 'Enter' at program start
25 Net-based installer of BioPerl; this is based on the GBrowse netinstaller
26 and hopefully all references to GBrowse have been removed. Let me know if not.
28 Save this to disk as "bp_netinstall.pl" and run:
30 [sudo] perl bp_netinstall.pl
34 Scott Cain scain@cpan.org
38 2010. This script may be distributed under the same license as perl.
44 # Universal Net-based installer
45 # Save this to disk as "bp_netinstall.pl" and run:
46 # perl bp_netinstall.pl
54 use File
::Copy
qw( cp move );
55 use File
::Temp
qw(tempdir);
59 use constant NMAKE
=> 'http://download.microsoft.com/download/vc15/patch/1.52/w95/en-us/nmake15.exe';
61 my ( $show_help, $get_from_cvs, $build_param_string, $working_dir,
62 $get_bioperl_svn, $is_cygwin, $windows,
63 $binaries, $make, $tmpdir, $bioperl_path,
64 $skip_start, $install_param_string, $perl_path);
69 'h|help' => \
$show_help, # Show help and exit
70 'd|dev' => \
$get_from_cvs, # Use the dev svn
71 'build_param_str=s' => \
$build_param_string, # Build parameters
72 'bioperl_dev' => \
$get_bioperl_svn,
73 'bioperl_path=s' => \
$bioperl_path,
74 'install_param_str=s' => \
$install_param_string,
75 'skip_start' => \
$skip_start,
78 pod2usage
(2) if $show_help;
80 $perl_path = $Config{perlpath
};
82 print STDERR
"\nAbout to install BioPerl and all its prerequisites.\n";
83 print STDERR
"\nYou will be asked various questions during this process. You can almost always";
84 print STDERR
"\naccept the default answer.\n";
85 print STDERR
"The whole process will take several minutes and will generate lots of messages.\n";
86 print STDERR
"\nPress return when you are ready to start!\n";
87 my $h = <> unless $skip_start;
88 print STDERR
"*** Installing Perl files needed for a net-based install ***\n";
90 $windows = $Config{osname
} =~ /mswin/i;
93 # MAY not be necessary--we'll have to see.
94 # if ($windows and $] == 5.010) {
95 # print STDERR "\n\nActiveState Perl 5.10 is not compatible with GBrowse due to problems\n";
96 # print STDERR "with the AS implementation. Please remove it and install Perl 5.8 instead.\n\n\n";
100 # Also MAY not be necessary
102 # print STDERR "\n\nInstalling Win32 perl module\n\n";
103 # system("ppm install Win32");
106 eval "CPAN::Config->load";
107 eval "CPAN::Config->commit";
109 $working_dir = getcwd
;
111 $tmpdir = tempdir
(CLEANUP
=>1)
112 or die "Could not create temporary directory: $!";
114 $binaries = $Config{'binexp'};
115 $make = $Config{'make'};
118 system("ppm install YAML");
121 CPAN
::Shell
->install('YAML');
123 CPAN
::Shell
->install('Archive::Zip');
124 CPAN
::Shell
->install('HTML::Tagset');
125 CPAN
::Shell
->install('LWP::Simple');
126 eval "use Archive::Zip ':ERROR_CODES',':CONSTANTS'";
128 if ($windows && !-e
"$binaries/${make}.exe") {
130 print STDERR
"Installing make utility...\n";
131 -w
$binaries or die "$binaries directory is not writeable. Please re-login as Admin.\n";
134 my $rc = mirror
(NMAKE
,"nmake.zip");
135 die "Could not download nmake executable from Microsoft web site."
136 unless $rc == RC_OK
() or $rc == RC_NOT_MODIFIED
();
138 my $zip = Archive
::Zip
->new('nmake.zip') or die "Couldn't open nmake zip file for decompression: $!";
139 $zip->extractTree == AZ_OK
() or die "Couldn't unzip file: $!";
140 -e
'NMAKE.EXE' or die "Couldn't extract nmake.exe";
142 cp
('NMAKE.EXE',"$binaries/${make}.EXE") or die "Couldn't install nmake.exe: $!";
143 cp
('NMAKE.ERR',"$binaries/${make}.ERR"); # or die "Couldn't install nmake.err: $!"; # not fatal
146 CPAN
::Shell
->install('Archive::Tar');
148 #print STDERR "at end of BEGIN{}\n";
152 #print STDERR "here i am\n";
158 $is_cygwin = 1 if ( $^O
eq 'cygwin' );
161 $get_bioperl_svn = 1;
164 #if ($wincvs or ($windows and $get_from_cvs)) {
165 # die "\n\nGBrowse is now in svn and fetching from svn on Windows\nis not currently supported\n ";
168 #if ($windows and !$wincvs and $get_gbrowse_cvs ) {
169 # die "\n\nThe development/cvs tags are not supported on Windows when\n"
170 # ."WinCVS is not installed; exiting...\n";
173 $build_param_string ||="";
174 $install_param_string ||="";
176 use constant BIOPERL_VERSION
=> 'BioPerl-1.6.1';
177 use constant BIOPERL_REQUIRES
=> '1.006001'; # sorry for the redundancy
178 use constant BIOPERL_LIVE_URL
=> 'http://github.com/bioperl/bioperl-live/tarball/master';
179 use constant BIOPERL
=> 'http://bioperl.org/DIST/'.BIOPERL_VERSION
.'.tar.gz';
182 #'BioPerl-Release-Candidates' => 'http://bioperl.org/DIST/RC',
183 'BioPerl-Regular-Releases' => 'http://bioperl.org/DIST',
184 'Kobes' => 'http://theoryx5.uwinnipeg.ca/ppms',
185 'Bribes' => 'http://www.Bribes.org/perl/ppm',
186 'tcool' => 'http://ppm.tcool.org/archives/',
190 # this is so that ppm can be called in a pipe
191 $ENV{COLUMNS
} = 80; # why do we have to do this?
194 setup_ppm
() if $windows;
196 unless ( eval "use GD 2.31; 1" ) {
198 print STDERR
"Installing GD via ppm.\n";
199 print STDERR
"(This may take a while...\n";
200 system("ppm install GD");
203 print STDERR
"Installing GD via CPAN...\n";
204 CPAN
::Shell
->install('GD') unless eval "use GD 2.31; 1";
208 print STDERR
"\n*** Installing prerequisites for BioPerl ***\n";
210 if ($windows and !eval "use DB_File; 1") {
211 print STDERR
"Installing DB_File for BioPerl.\n";
213 # GBrowse doesn't like DB_File 1.820, so we explicitly get DB_File by url
214 system("ppm install http://ppm.tcool.org/archives/DB_File.ppd");
216 #system("ppm install SVG") if $windows;
217 #CPAN::Shell->install('GD::SVG');
220 CPAN
::Shell
->install('IO::String');
221 #CPAN::Shell->install('Text::Shellwords');
223 # #CGI::Session and Digest::MD5 both fail to install via cpan on windows
224 # system("ppm install CGI-Session");
225 # system("ppm install Digest-MD5");
228 # CPAN::Shell->install('CGI::Session');
229 # CPAN::Shell->install('Digest::MD5');
231 #CPAN::Shell->install('File::Temp');
232 #CPAN::Shell->install('Class::Base');
233 #CPAN::Shell->install('Statistics::Descriptive');
234 #CPAN::Shell->install('Data::Stag');
236 my $version = BIOPERL_REQUIRES
;
237 if (!(eval "use Bio::Perl $version; 1") or $get_bioperl_svn or $bioperl_path) {
238 print STDERR
"\n*** Installing BioPerl ***\n";
240 #would like to use ppm, but ppm won't install 1.6
241 #if ($windows and !$get_bioperl_svn and !$bioperl_path) {
242 # my $bioperl_index = find_bioperl_ppm();
243 # system("ppm install --force $bioperl_index");
245 # recent versions of Module::Build fail to install without force!
246 CPAN
::Shell
->force('Module::Build') unless eval "require Module::Build; 1";
251 $get_bioperl_svn ?
'svn' : '',
254 $install_param_string,
259 print STDERR
"BioPerl is up to date.\n";
262 print STDERR
"\n *** Installing Bio::Graphics ***\n";
265 #install biographics?
266 CPAN
::Shell
->install('Bio::Graphics');
271 my $null = ($^O
=~ m/mswin/i) ?
'NUL' : '/dev/null';
272 open STDERR
,">$null"; # windows has an annoying message when cleaning up temp file
276 my ($download,$local_name,$distribution,$method,
277 $from_cvs,$build_param_string,$file_path,$install_param_string,
280 $install_param_string ||= '';
283 do_get_distro
($download,$local_name,$distribution,$from_cvs,$file_path);
285 my $build_str = $windows ?
"Build" : "./Build";
287 if ($method eq 'make') {
288 system("$perl_path Makefile.PL $build_param_string") == 0
289 or die "Couldn't run perl Makefile.PL command\n";
290 system("$make install UNINST=1 $install_param_string") == 0 ;
292 elsif ($method eq 'Build') {
293 system("$perl_path $build_str.PL --yes=1 $build_param_string") == 0
294 or die "Couldn't run perl Build.PL command\n";
295 system("$build_str install --uninst 1 $install_param_string") == 0;
300 my ($download,$local_name,$distribution,$distribution_method,$file_path) = @_;
304 if (-e
$file_path) { #must be an absolute path
305 cp
($file_path, "$tmpdir/$local_name");
307 elsif (-e
"$working_dir/$file_path") { #assume it's a rel path from the original directory
308 cp
("$working_dir/$file_path", "$tmpdir/$local_name");
311 print "Couldn't find $file_path; nothing to do so quitting...\n";
314 $distribution = ($local_name =~ /gbrowse/)
315 ?
"Generic-Genome-Browser" : "bioperl-live";
317 extract_tarball
($local_name,$distribution);
319 elsif ($distribution_method) {
320 my $distribution_dir;
321 print STDERR
"Downloading bioperl-live...\n";
322 $distribution_dir = 'bioperl-live';
324 my $filename = 'bioperl-live.tar.gz'; # =determine_filename();
325 my $url = BIOPERL_LIVE_URL
."/$filename";
327 my $rc = mirror
($url, $filename);
328 unless ($rc == RC_OK
or $rc == RC_NOT_MODIFIED
){
329 print STDERR
"Failed to get nightly bioperl-live file: $rc\n";
332 extract_tarball
($filename,$distribution_dir);
334 chdir $distribution_dir
335 or die "Couldn't enter $distribution_dir directory: $@";
338 print STDERR
"Downloading $download...\n";
339 my $rc = mirror
($download,$local_name);
340 die "Could not download $distribution distribution from $download."
341 unless $rc == RC_OK
or $rc == RC_NOT_MODIFIED
;
343 extract_tarball
($local_name,$distribution);
348 #this is probably not going to be needed again, as the nightly
349 #bioperl build names have been simplified
350 sub determine_filename
{
351 my $listing = "dirlisting.html";
352 my $rc = mirror
(BIOPERL_LIVE_URL
, $listing);
353 die "Could not get directory listing of bioperl nightly build url: $rc\n"
354 unless ($rc == RC_OK
or $rc == RC_NOT_MODIFIED
);
357 open my $LIST, '<', $listing or die "Could not read file '$listing': $!\n";
358 while (my $line = <$LIST>) {
359 if ($line =~ /href="(bioperl-live.*?\.tar\.gz)"/) {
369 sub extract_tarball
{
370 my ($local_name,$distribution) = @_;
372 print STDERR
"Unpacking $local_name...\n";
373 my $z = Archive
::Tar
->new($local_name,1)
374 or die "Couldn't open $distribution archive: $@";
375 my @extracted = $z->extract()
376 or die "Couldn't extract $distribution archive: $@";
378 if ($extracted[0]->{'name'} =~ /^(bioperl.*?)\//) {
379 my $bioperl_dir = $1;
380 move
($bioperl_dir, $distribution) or die "couldn't move bioperl dir: $@";
384 or die "Couldn't enter $distribution directory: $@";
388 # make sure ppm repositories are correct!
390 open my $S, "ppm repo list --csv|" or die "Could not open ppm for listing: $!\n";
392 while (my $line = <$S>) {
394 my ($index, $package_count, $name) = split /,/, $line;
395 $repository{$name} = $index;
398 print STDERR
"Adding needed PPM repositories. This may take a while....\n";
399 for my $name (keys %REPOSITORIES) {
400 next if $repository{$name};
401 system("ppm rep add $name $REPOSITORIES{$name}");
405 sub find_bioperl_ppm
{
406 print STDERR
"Finding most recent bioperl...";
407 open my $S,"ppm search bioperl |" or die "Could not open ppm for listing: $!\n";
408 local $/ = ''; # paragraph mode
409 my ($blessed_one, $blessed_version);
411 while (my $line = <$S>) {
413 my ($number) = ($line =~ /^(\d+): bioperl/m);
414 my ($version) = ($line =~ /^\s+Version: (.+)/m);
415 my ($repository) = ($line =~ /^\s+Repo: (.+)/m);
416 my $multiplier = 10000000;
418 # this dumb thing converts 1.5.1 into a real number
419 foreach my $piece (split /[._]/, $version) {
420 $magnitude += $piece * ($multiplier/=10);
422 ($blessed_one,$best,$blessed_version) = ($number,$magnitude,$version) if $best < $magnitude;
425 print STDERR
$blessed_version ?
"found $blessed_version\n" : "not found\n";