-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall.sh
executable file
·77 lines (62 loc) · 1.89 KB
/
install.sh
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
#!/bin/bash
set -e
set -x
DOCKER=0
BIN_PATH="/usr/bin/zcli"
PERL_PATH="/usr/share/perl5"
OS_FILE="/etc/os-release"
source $OS_FILE
if [[ "$1" != "" ]]; then
if [[ "$1" == "-docker" ]]; then
DOCKER=1
# Var to set autoconfirm option in CPAN
PERL_MM_USE_DEFAULT=1
elif [[ "$1" =~ "^(-h|--help)$" ]]; then
echo "$0 [-docker]"
echo " The docker option accept the interactive dialog in order not to need human interaction"
else
echo "The option '$1' is not recoignized"
exit 1
fi
fi
shopt -s nocasematch
if [[ $NAME =~ "debian" ]]; then
OS="debian"
elif [[ $NAME =~ "arch" ]]; then
OS="arch"
elif [[ $NAME =~ "centos" ]]; then
OS="centos"
else
echo "The OS was not recoignized"
exit 1
fi
if [ -d "$PERL_PATH/vendor_perl" ]; then
PERL_PATH="$PERL_PATH/vendor_perl"
fi
GIT_ZCLI_BIN="src/zcli.pl"
GIT_ZCLI_LIB="src/ZCLI"
BASE_DIR=$(dirname "$0")
ZCLI_BIN=$(realpath ${BASE_DIR}/$GIT_ZCLI_BIN)
ZCLI_LIB=$(realpath ${BASE_DIR}/$GIT_ZCLI_LIB)
DEPENDENCIES="$BASE_DIR/dependencies.txt"
# system packages
YES=""
if [[ $DOCKER -eq 1 ]]; then YES="-y"; fi
if [[ "$OS" == "centos" ]]; then
yum install `grep -E "build\b" $DEPENDENCIES | sed -E 's/build\s*=>\s*//'` $YES
yum install `grep build_centos $DEPENDENCIES | sed -E 's/build_centos\s*=>\s*//'` $YES
elif [[ "$OS" == "debian" ]]; then
apt-get install $YES `grep -E "build\b" $DEPENDENCIES | sed -E 's/build\s*=>\s*//'`
apt-get install $YES `grep -E "build_debian\b" $DEPENDENCIES | sed -E 's/build_debian\s*=>\s*//'`
else
pacman -S `grep -E "build\b" $DEPENDENCIES | sed -E 's/build\s*=>\s*//'`
fi
# perl modules
cpan install `grep common $DEPENDENCIES | sed -E 's/common\s*=>\s*//'`
## Necessary, the Term::ReadLine::Gnu module requires human interface for tests
FORCE=""
if [[ $DOCKER -eq 1 ]]; then FORCE="-f"; fi
cpan install $FORCE `grep linux $DEPENDENCIES | sed -E 's/linux\s*=>\s*//'`
ln -s $ZCLI_BIN $BIN_PATH
ln -s $ZCLI_LIB $PERL_PATH
exit 0