#!/bin/sh # $Id: prerequisites_imapsync,v 1.12 2015/07/06 03:12:43 gilles Exp gilles $ MODULES_MANDATORY=' Digest::HMAC_MD5 Authen::NTLM Compress::Zlib Data::Dumper Data::Uniqid Digest::HMAC Digest::MD5 File::Copy::Recursive IO::Socket::INET IO::Socket::INET6 IO::Socket::SSL IO::Tee Mail::IMAPClient Parse::RecDescent Term::ReadKey Test::More Test::Pod Unicode::String URI::Escape ' MODULES_DEVEL=' Module::ScanDeps PAR::Packer ' test_perl() { # First we need perl if perl -v > /dev/null 2>&1 ; then perl_version=`perl -e 'printf "%vd\n", $^V;'` echo Ok: Found Perl $perl_version return 0 else echo Failure: Perl is not here. You have to install Perl first. return 1 fi } test_module() { test -n $1 || return M_tested=$1 shift if perl -m"$M_tested" -e '' >/dev/null 2>&1 ; then echo "Ok: Found Perl module $M_tested" else echo "Failure: Not found Perl module $M_tested $@" LIST_TO_INSTALL="$LIST_TO_INSTALL $M_tested" fi } test_mandatory_modules() { for M in $MODULES_MANDATORY do test_module $M done } search_modules_any() { test -n "$*" || { echo "All needed modules are already installed" return } apt-file -h > /dev/null 2>&1 && { search_modules_apt "$@" return } yum -h > /dev/null 2>&1 && { search_modules_yum "$@" return } # no yum, no apt-get { search_modules_cpan "$@" return } } search_modules_cpan() { cat < /dev/null 2>&1 && sw_vers # Darwin lsb_release -dirc > /dev/null 2>&1 && lsb_release -dirc # Linux uname -a } test_unix #exit test_perl || exit test_mandatory_modules list_to_install #search_modules_cpan $MODULES_MANDATORY search_modules_any $LIST_TO_INSTALL