/usr/bin/bp_bioperl_application_installer.pl is in bioperl-run 1.6.9-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | #!/usr/bin/perl
# BioPerl script for Bio::Installer
#
# Cared for by Albert Vilella
#
# based on the CPAN::FirstTime module
#
# Copyright Albert Vilella
#
# You may distribute this module under the same terms as perl itself
# POD documentation - main docs before the code
=head1 NAME
bioperl_application_installer - downloads and installs runnables
=head1 SYNOPSIS
bioperl_application_installer
=head1 DESCRIPTION
This script will ask the user which programs wants to install and
where. It will download the packages, decompress them (if necessary)
and compile/install them in the specified directory.
=head1 AUTHOR
Albert Vilella, avilella-AT-gmail-DOT-com
=head1 TODO
Check if the programs are already installed in the computer and prompt
it so that the user is at least aware of it.
Check for the available installers, instead of hard-coding
$INSTALLERLIST in this script.
=cut
use strict;
use ExtUtils::MakeMaker;
use Data::Dumper;
use Bio::Factory::ObjectFactory;
use vars qw($DEFAULT $CONFIG $INSTALLERLIST);
BEGIN {
$DEFAULT = 'bioperl-runnables';
$INSTALLERLIST = [
'Clustalw',
'EMBOSS',
'TCoffee',
'PAML',
'Hyphy',
'SLR',
'Probcons',
];
}
my $dir = shift @ARGV || $DEFAULT;
init($dir);
1;
################################################################################
sub init {
my($configpm) = @_;
use Config;
local($/) = "\n";
local($\) = "";
local($|) = 1;
my($ans,$default);
#
# Files, directories
#
print qq[
This script will install the runnable programs associated with
bioperl-run.
Bioperl-run contain modules that provides a PERL interface to various
bioinformatics applications. This allows various applications to be
used with common bioperl objects.
If you do not want to enter a dialog now, you can answer 'no' to this
question.
];
my $manual_conf =
ExtUtils::MakeMaker::prompt("Are you ready for manual configuration?",
"yes");
my $fastread;
{
local $^W;
if ($manual_conf =~ /^\s*y/i) {
$fastread = 0;
*prompt = \&ExtUtils::MakeMaker::prompt;
} else {
print "Done.\n\n";
exit;
}
}
print qq{
The following questions are intended to help you with the
installation.
};
$default = File::Spec->catdir( $ENV{'HOME'}, $configpm);
while ($ans = prompt("Where do you want to install the runnables in your computer?",$default)) {
unless (File::Spec->file_name_is_absolute($ans)) {
require Cwd;
my $cwd = Cwd::cwd();
my $absans = File::Spec->catdir($cwd,$ans);
warn "The path '$ans' is not an absolute path. Please specify an absolute path\n";
$default = $absans;
next;
}
eval { File::Path::mkpath($ans); }; # dies if it can't
if ($@) {
warn "Couldn't create directory $ans.
Please retry.\n";
next;
}
if (-d $ans && -w _) {
print qq{
Directory $ans successfully created.
};
last;
} else {
warn "Couldn't find directory $ans
or directory is not writable. Please retry.\n";
}
}
print qq{
The script will need a few external programs to work properly.
Please correct me, if I guess the wrong path for a program. Don\'t
panic if you do not have some of them, just press ENTER for those.
};
my $old_warn = $^W;
local $^W if $^O eq 'MacOS';
my(@path) = split /$Config{'path_sep'}/, $ENV{'PATH'};
local $^W = $old_warn;
my $progname;
for $progname (qw/gzip tar unzip make links wget ncftpget ncftp ftp gpg/) {
if ($^O eq 'MacOS') {
$CONFIG->{$progname} = 'not_here';
next;
}
my $progcall = $progname;
# we don't need ncftp if we have ncftpget
next if $progname eq "ncftp" && $CONFIG->{ncftpget} gt " ";
my $path = $CONFIG->{$progname}
|| $Config::Config{$progname}
|| "";
if (File::Spec->file_name_is_absolute($path)) {
# testing existence is not good enough, some have these exe
# extensions
# warn "Warning: configured $path does not exist\n" unless -e $path;
# $path = "";
} else {
$path = '';
}
unless ($path) {
# e.g. make -> nmake
$progcall = $Config::Config{$progname} if $Config::Config{$progname};
}
$path ||= find_exe($progcall,[@path]);
warn "Warning: $progcall not found in PATH\n" unless
$path; # not -e $path, because find_exe already checked that
$ans = prompt("Where is your $progname program?",$path) || $path;
$CONFIG->{$progname} = $ans;
}
my $path = $CONFIG->{'pager'} ||
$ENV{PAGER} || find_exe("less",[@path]) ||
find_exe("more",[@path]) || ($^O eq 'MacOS' ? $ENV{EDITOR} : 0 )
|| "more";
$ans = prompt("What is your favorite pager program?",$path);
$CONFIG->{'pager'} = $ans;
$path = $CONFIG->{'shell'};
if (File::Spec->file_name_is_absolute($path)) {
warn "Warning: configured $path does not exist\n" unless -e $path;
$path = "";
}
$path ||= $ENV{SHELL};
if ($^O eq 'MacOS') {
$CONFIG->{'shell'} = 'not_here';
} else {
$path =~ s,\\,/,g if $^O eq 'os2'; # Cosmetic only
$ans = prompt("What is your favorite shell?",$path);
$CONFIG->{'shell'} = $ans;
}
print qq{
Which programs would you like to install?
};
my @selected_programs;
my $prompt = "Select the programs you would like to install (by number),
put them on one line, separated by blanks, e.g. '1 2 4'";
push (@selected_programs, @$INSTALLERLIST);
@selected_programs = picklist (\@selected_programs, $prompt);
push @{$CONFIG->{selected_programs_list}}, @selected_programs;
print qq{
The selected programs will now be installed
};
# TODO: Check for the available installers, instead of hard-coding
# $INSTALLERLIST in this script.
# my @l;
# for my $i (@INC) {
# next unless (-e $i."/My/Stuff/");
# opendir(X,$i."/My/Stuff")|| warn "$!";
# push @l,readdir(X);
# }
# find sub { push(@l, $File::Find::name) if -f && /\.pm$/ },
# map { "$_/My/Module" } @INC;
foreach my $program (@selected_programs) {
my $type = 'Bio::Installer::' . $program;
my $factory = new Bio::Factory::ObjectFactory(-type => $type);
my $instance = $factory->create_object();
$instance->destination_install_dir($default);
$instance->download();
$instance->install();
}
}
sub picklist {
my($items,$prompt,$default,$require_nonempty,$empty_warning)=@_;
$default ||= '';
my $pos = 0;
my @nums;
while (1) {
# display, at most, 15 items at a time
my $limit = $#{ $items } - $pos;
$limit = 15 if $limit > 15;
# show the next $limit items, get the new position
$pos = display_some($items, $limit, $pos);
$pos = 0 if $pos >= @$items;
my $num = prompt($prompt,$default);
@nums = split (' ', $num);
my $i = scalar @$items;
(warn "invalid items entered, try again\n"), next
if grep (/\D/ || $_ < 1 || $_ > $i, @nums);
if ($require_nonempty) {
(warn "$empty_warning\n");
}
print "\n";
# a blank line continues...
next unless @nums;
last;
}
for (@nums) { $_-- }
@{$items}[@nums];
}
sub display_some {
my ($items, $limit, $pos) = @_;
$pos ||= 0;
my @displayable = @$items[$pos .. ($pos + $limit)];
for my $item (@displayable) {
printf "(%d) %s\n", ++$pos, $item;
}
printf("%d more items, hit SPACE RETURN to show them\n",
(@$items - $pos)
)
if $pos < @$items;
return $pos;
}
sub find_exe {
my($exe,$path) = @_;
my($dir);
#warn "in find_exe exe[$exe] path[@$path]";
for $dir (@$path) {
my $abs = File::Spec->catfile($dir,$exe);
if (($abs = MM->maybe_command($abs))) {
return $abs;
}
}
}
|