1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-17 00:02:29 +01:00
imapsync/INSTALL.d/prerequisites_imapsync

290 lines
5.6 KiB
Plaintext
Raw Normal View History

2015-05-28 19:04:57 +02:00
#!/bin/sh
2020-04-11 01:15:57 +02:00
# $Id: prerequisites_imapsync,v 1.35 2019/11/27 15:58:46 gilles Exp gilles $
2015-05-28 19:04:57 +02:00
MODULES_MANDATORY='
2018-05-07 16:04:23 +02:00
App::cpanminus
2015-05-28 19:04:57 +02:00
Authen::NTLM
2018-05-07 16:04:23 +02:00
CGI
2015-05-28 19:04:57 +02:00
Compress::Zlib
2017-09-23 23:54:48 +02:00
Crypt::OpenSSL::RSA
2015-05-28 19:04:57 +02:00
Data::Dumper
Data::Uniqid
Digest::HMAC
2017-09-23 23:54:48 +02:00
Digest::HMAC_MD5
2015-05-28 19:04:57 +02:00
Digest::MD5
2017-09-23 23:54:48 +02:00
Dist::CheckConflicts
2020-04-11 01:15:57 +02:00
Encode
2017-09-23 23:54:48 +02:00
Encode::Byte
2020-04-11 01:15:57 +02:00
Encode::IMAPUTF7
2015-05-28 19:04:57 +02:00
File::Copy::Recursive
2020-04-11 01:15:57 +02:00
File::Tail
2015-05-28 19:04:57 +02:00
IO::Socket::INET
IO::Socket::INET6
IO::Socket::SSL
IO::Tee
2017-09-23 23:54:48 +02:00
JSON
2016-09-19 17:17:24 +02:00
JSON::WebToken
2017-09-23 23:54:48 +02:00
JSON::WebToken::Crypt::RSA
HTML::Entities
LWP::UserAgent
2015-05-28 19:04:57 +02:00
Mail::IMAPClient
2020-04-11 01:15:57 +02:00
MIME::Base64
2017-09-23 23:54:48 +02:00
Module::Implementation
Module::Runtime
Module::ScanDeps
Net::SSLeay
Package::Stash
Package::Stash::XS
PAR::Packer
2015-05-28 19:04:57 +02:00
Parse::RecDescent
2017-09-23 23:54:48 +02:00
Pod::Usage
2016-09-19 17:17:24 +02:00
Readonly
2018-05-07 16:04:23 +02:00
Regexp::Common
2017-09-23 23:54:48 +02:00
Sys::MemInfo
2015-05-28 19:04:57 +02:00
Term::ReadKey
2017-09-23 23:54:48 +02:00
Test::Fatal
Test::Mock::Guard
2016-09-19 17:17:24 +02:00
Test::MockObject
2015-05-28 19:04:57 +02:00
Test::More
Test::Pod
2017-09-23 23:54:48 +02:00
Test::Requires
2018-05-07 16:04:23 +02:00
Test::Deep
2020-04-11 01:15:57 +02:00
Text::ParseWords
2017-09-23 23:54:48 +02:00
Try::Tiny
2015-05-28 19:04:57 +02:00
Unicode::String
URI::Escape
'
2019-07-03 01:17:46 +02:00
MODULES_FOR_CODERS='
Smart::Comments
'
2015-05-28 19:04:57 +02:00
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
2019-07-03 01:17:46 +02:00
echo 'Failure: Perl is not here. You have to install Perl first.'
2015-05-28 19:04:57 +02:00
return 1
fi
}
2017-09-23 23:54:48 +02:00
test_make() {
# Second we need make to build some Perl modules
2019-07-03 01:17:46 +02:00
if echo foo: | make -f - foo ; then
2017-09-23 23:54:48 +02:00
make_version=`make -v |head -1`
echo Ok: Found make $make_version
return 0
else
2019-07-03 01:17:46 +02:00
echo 'Failure: make is not here. You have to install the "make" command.'
2017-09-23 23:54:48 +02:00
return 1
fi
}
2019-07-03 01:17:46 +02:00
test_cpanm() {
# Second we need make to build some Perl modules
# redirect "cpanm ... < /dev/null" is there for macos buid via ssh
# no clue why it's necessary
if cpanm -h > /dev/null 2>&1 < /dev/null; then
cpanm_version=`cpanm --version < /dev/null | head -1`
echo Ok: Found cpanm $cpanm_version
return 0
else
echo 'Failure: cpanm is not here. You have to install the "cpanm" command.'
return 1
fi
}
2017-09-23 23:54:48 +02:00
2015-05-28 19:04:57 +02:00
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
2016-09-19 17:17:24 +02:00
return
2015-05-28 19:04:57 +02:00
}
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
}
2019-07-03 01:17:46 +02:00
# Debian, Ubuntu & Co
2020-04-11 01:15:57 +02:00
apt-cache -h > /dev/null 2>&1 && {
2015-05-28 19:04:57 +02:00
search_modules_apt "$@"
return
}
2019-07-03 01:17:46 +02:00
# Centos & Co
2015-05-28 19:04:57 +02:00
yum -h > /dev/null 2>&1 && {
search_modules_yum "$@"
return
}
2019-07-03 01:17:46 +02:00
# ArchLinux & Co
pacman -h > /dev/null 2>&1 && {
search_modules_pacman "$@"
return
}
2019-07-03 01:25:47 +02:00
# FreeBSD
pkg version > /dev/null 2>&1 && {
search_modules_freebsd "$@"
return
}
2019-07-03 01:17:46 +02:00
# no yum, no apt-get, no pacman
2015-05-28 19:04:57 +02:00
{
2016-09-19 17:17:24 +02:00
search_modules_cpanm "$@"
2015-05-28 19:04:57 +02:00
return
}
}
2016-09-19 17:17:24 +02:00
search_modules_cpanm() {
2015-05-28 19:04:57 +02:00
cat <<EOD
2016-09-19 17:17:24 +02:00
Here is a cpanm command to install missing Perl modules:
cpanm $@
2015-05-28 19:04:57 +02:00
EOD
}
2019-07-03 01:17:46 +02:00
search_modules_pacman() {
echo
echo Searching pacman packages names
#echo pacman -Fy
#pacman -Fy
echo pacman -S --noconfirm --needed pkgfile
pacman -S --noconfirm --needed pkgfile
echo pkgfile --update
pkgfile --update
for M in "$@" ; do
echo "==== Searching pacman package name for $M"
F=`echo $M|tr -s ":" "/"`.pm
# Not very good "pacman -Fs"
#echo pacman -Fs "$F"
#echo
#pacman -Fs "$F"
#echo
# Better! pkgfile --reg
echo "pkgfile --reg $F | grep perl-"
echo
pkgfile --reg "$F" | grep perl-
echo
done
}
2015-05-28 19:04:57 +02:00
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
2017-09-23 23:54:48 +02:00
echo yum -q whatprovides "*/$F"
2015-05-28 19:04:57 +02:00
echo
yum -q whatprovides "*/$F"
echo
done
}
search_modules_apt() {
echo
echo Searching deb packages names
for M in "$@" ; do
F=`echo $M|tr -s ":" "/"`.pm
2019-07-03 01:25:47 +02:00
echo "==== Searching deb package name for $M with: apt-file search /$F"
2015-05-28 19:04:57 +02:00
#echo apt-file search /$F
echo
2020-04-11 01:15:57 +02:00
if apt-file -h > /dev/null 2>&1
then
apt-file search /$F
else
echo "apt-file is not installed. Suggestion: apt-get install apt-file; apt-file update"
fi
2019-07-03 01:25:47 +02:00
echo
echo "==== Searching deb package name for $M with: apt-cache search $M"
2015-08-04 03:44:40 +02:00
#apt-cache search "$M"
2019-07-03 01:25:47 +02:00
apt-cache search "$M"
2015-05-28 19:04:57 +02:00
echo
done
}
2019-07-03 01:25:47 +02:00
search_modules_freebsd()
{
echo
echo Searching pkg FreeBSD names
for M in "$@" ; do
F=`echo $M|tr -s ":" "-"`
echo "==== Searching deb package name for $M with: pkg search p5-$F"
echo
pkg search "p5-$F"
echo
done
}
2015-05-28 19:04:57 +02:00
list_to_install() {
2016-09-19 17:17:24 +02:00
test -n "$LIST_TO_INSTALL" || return 0
2015-05-28 19:04:57 +02:00
echo
echo 'What you have to do before using imapsync:'
for M in $LIST_TO_INSTALL ; do
echo "Install Perl module $M"
done
2016-09-19 17:17:24 +02:00
# return false/bad if some modules are missing.
return 1
2015-05-28 19:04:57 +02:00
}
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
}
2019-07-03 01:17:46 +02:00
2015-05-28 19:04:57 +02:00
test_unix
#exit
2020-04-11 01:15:57 +02:00
test_perl || exit 1
2017-09-23 23:54:48 +02:00
test_make || exit
2015-05-28 19:04:57 +02:00
test_mandatory_modules
list_to_install
2016-09-19 17:17:24 +02:00
EXIT=$?
# Help the user to install missing modules
2015-05-28 19:04:57 +02:00
search_modules_any $LIST_TO_INSTALL
2018-05-07 16:04:23 +02:00
2020-04-11 01:15:57 +02:00
if test "$1" = "MODULES_MANDATORY"
then
search_modules_any $MODULES_MANDATORY
elif test -n "$1"
then
search_modules_any "$@"
fi
2019-07-03 01:17:46 +02:00
test_cpanm
2016-09-19 17:17:24 +02:00
exit $EXIT