use strict ; use warnings ;
use 5.10.0 ;
use ExtUtils::Installed;
# quick and dirty check for prerequisites perl modules:
# courtesy of:http://stackoverflow.com/a/9340304/65706
# if you have a calling bash script call by :
# perl "/path/to/isg_pub_preq_cheker.pl"
# export ret=$?
# test $ret -ne 0 && doExit 1 "[FATAL] perl modules not found!!!"
# check that all the required modules are installed
my ( $ret , $msg ) = doCheckRequiredModules();
unless ( $ret == 0 ) {
print "$msg" ;
# give some time for the user to react
print "printing all installed modules :" ;
my $c = 9 ;
for ( my $i=0;$i<=$c;$i++){
print ( ( $c-$i) . '.') ;
sleep 1 ;
}
print "\n" ;
doListAllInstalledModules();
print "\n" ;
}
exit(0);
sub doListAllInstalledModules {
my $instmod = ExtUtils::Installed->new();
foreach my $module ($instmod->modules()) {
my $version = $instmod->version($module) || "???";
print "found module:$module -- v$version\n";
}
}
#eof sub
sub doCheckRequiredModules {
my @modules = qw(
Test::More
Test::Deep
CPAN::SQLite
File::Copy::Recursive
HTML::TreeBuilder
HTML::TreeBuilder::XPath
HTML::TableExtract
HTML::ElementTable
Spreadsheet::XLSX
IO::HTML
Regexp::Common
Test::More
Spiffy
Filter::Util::Call
Algorithm::Diff
Text::Diff
Test::Base
Test::CPAN::Meta::YAML
Test::YAML::Valid
Test::YAML::Meta
Test::YAML
YAML::Any
Data::Printer
LWP
Text::Template
HTML::Template
Module::Signature
Taint
ExtUtils::Installed
);
for(@modules) {
eval "use $_";
if ($@) {
my $msg = "\n\n\n [FATAL] did not found the following perl module: $_ " ;
$msg .= "\n you must install it in the shell by running the following commands:" ;
# if the user knows already the difference between the running the cmd
# with sudo or he / she probably knows already how-to install perl modules
$msg .= "\n" . 'as a start configure the cpan to install dependancies first' . "\n" ;
$msg .= "\n" . 'perl -MCPAN -e \'my $c = "CPAN::HandleConfig"; $c->load(doit => 1, autoconfig => 1); $c->edit(prerequisites_policy => "follow"); $c->edit(build_requires_install_policy => "yes"); $c->commit\'' . "\n" ;
$msg .= "\n" . 'than install by :' . "\n" ;
$msg .= "\n sudo perl -MCPAN -e 'install $_'\n\n\n" ;
$msg .= "\n if you seem to be stuck in circular reference kind of loop try even :\n" ;
$msg .= "\n sudo perl -MCPAN -e 'CPAN::Shell->force(qw( install $_));'\n" ;
$msg .= "\n sudo perl -MCPAN -e 'CPAN::Shell->force(qw( install $_));'\n" ;
$msg .= "\n You may end-up now with Ctrl + C \n\n\n" ;
return ( 1, "$msg") if $@;
} else {
say "[INFO ] == ok == check for prerequisite perl module : $_";
}
}
#eof foreach module
return ( 0 , "all required modules found" ) ;
}
#eof sub
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!