mirror of
https://github.com/imapsync/imapsync.git
synced 2024-11-17 00:02:29 +01:00
197 lines
3.4 KiB
Bash
Executable File
197 lines
3.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# $Id: prerequisites_imapsync,v 1.25 2018/04/24 00:14:23 gilles Exp gilles $
|
|
|
|
MODULES_MANDATORY='
|
|
App::cpanminus
|
|
Authen::NTLM
|
|
CGI
|
|
Compress::Zlib
|
|
Crypt::OpenSSL::RSA
|
|
Data::Dumper
|
|
Data::Uniqid
|
|
Digest::HMAC
|
|
Digest::HMAC_MD5
|
|
Digest::MD5
|
|
Dist::CheckConflicts
|
|
Encode::Byte
|
|
File::Copy::Recursive
|
|
IO::Socket::INET
|
|
IO::Socket::INET6
|
|
IO::Socket::SSL
|
|
IO::Tee
|
|
JSON
|
|
JSON::WebToken
|
|
JSON::WebToken::Crypt::RSA
|
|
HTML::Entities
|
|
LWP::UserAgent
|
|
Mail::IMAPClient
|
|
Module::Implementation
|
|
Module::Runtime
|
|
Module::ScanDeps
|
|
Net::SSLeay
|
|
Package::Stash
|
|
Package::Stash::XS
|
|
PAR::Packer
|
|
Parse::RecDescent
|
|
Pod::Usage
|
|
Readonly
|
|
Regexp::Common
|
|
Sys::MemInfo
|
|
Term::ReadKey
|
|
Test::Fatal
|
|
Test::Mock::Guard
|
|
Test::MockObject
|
|
Test::More
|
|
Test::Pod
|
|
Test::Requires
|
|
Test::NoWarnings
|
|
Test::Deep
|
|
Test::Warn
|
|
Try::Tiny
|
|
Unicode::String
|
|
URI::Escape
|
|
'
|
|
|
|
|
|
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_make() {
|
|
# Second we need make to build some Perl modules
|
|
|
|
if make -v > /dev/null 2>&1 ; then
|
|
make_version=`make -v |head -1`
|
|
echo Ok: Found make $make_version
|
|
return 0
|
|
else
|
|
echo Failure: make is not here. You have to install the make command.
|
|
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
|
|
return
|
|
}
|
|
|
|
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_cpanm "$@"
|
|
return
|
|
}
|
|
}
|
|
|
|
search_modules_cpanm() {
|
|
cat <<EOD
|
|
Here is a cpanm command to install missing Perl modules:
|
|
cpanm $@
|
|
EOD
|
|
}
|
|
|
|
|
|
search_modules_yum() {
|
|
echo
|
|
echo Searching rpm packages names
|
|
for M in "$@" ; do
|
|
echo "==== Searching rpm package name for $M"
|
|
F=`echo $M|tr -s ":" "/"`.pm
|
|
echo yum -q whatprovides "*/$F"
|
|
echo
|
|
yum -q whatprovides "*/$F"
|
|
echo
|
|
done
|
|
}
|
|
|
|
search_modules_apt() {
|
|
echo
|
|
echo Searching deb packages names
|
|
for M in "$@" ; do
|
|
echo "==== Searching deb package name for $M"
|
|
F=`echo $M|tr -s ":" "/"`.pm
|
|
#echo apt-file search /$F
|
|
echo
|
|
apt-file search /$F
|
|
#apt-cache search "$M"
|
|
echo
|
|
done
|
|
}
|
|
|
|
|
|
list_to_install() {
|
|
test -n "$LIST_TO_INSTALL" || return 0
|
|
echo
|
|
echo 'What you have to do before using imapsync:'
|
|
for M in $LIST_TO_INSTALL ; do
|
|
echo "Install Perl module $M"
|
|
done
|
|
# return false/bad if some modules are missing.
|
|
return 1
|
|
}
|
|
|
|
test_unix() {
|
|
echo '$SHELL says ' $SHELL
|
|
echo '$0 gives ' $0
|
|
echo -n "ps -ef gives " ; ps -ef | grep $$ | grep -v grep| grep -v 'ps -ef'
|
|
sw_vers > /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_make || exit
|
|
test_mandatory_modules
|
|
list_to_install
|
|
EXIT=$?
|
|
|
|
# Help the user to install missing modules
|
|
search_modules_any $LIST_TO_INSTALL
|
|
|
|
test "$1" = "MODULES_MANDATORY" && search_modules_any $MODULES_MANDATORY
|
|
exit $EXIT
|