-
Notifications
You must be signed in to change notification settings - Fork 235
/
setup.sh
executable file
·112 lines (98 loc) · 3.94 KB
/
setup.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# Xiaoxin sGSI Build Tools - Build Environment Setup Utils
# Copyright (C) 2020 Xiaoxindada <2245062854@qq.com> && Pomelo Jiuyu <2652609017@qq.com>
LOCALDIR=`cd "$( dirname ${BASH_SOURCE[0]} )" && pwd`
cd $LOCALDIR
# Whether uses mirror for pip
USE_MIRROR_FOR_PIP=true
# Python pip mirror link
PIP_MIRROR=https://pypi.tuna.tsinghua.edu.cn/simple/
dump_welcome(){
echo -e "\033[34m $(cat banner/banner) \033[0m"
echo
source ./language_helper.sh
echo -e "\033[33m [$INFO_STR] $WELCOME - $ENVSETUP_TOOLS \033[0m"
echo
}
dependency_install(){
echo -e "\033[33m [$INFO_STR] $DETECTING_SYSTEM ... \033[0m"
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo -e "\033[33m [$INFO_STR] $DETECTED_LINUX \033[0m"
echo -e "\033[33m [$INFO_STR] $INSTPKG_WITH_APT ... \033[0m"
sudo apt install -y git p7zip curl wget unace unrar zip unzip p7zip-full p7zip-rar sharutils uudeview mpack arj cabextract file-roller aptitude device-tree-compiler squashfs-tools liblzma-dev liblz4-tool gawk aria2 selinux-utils
sudo apt update --fix-missing
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo -e "\033[33m [$INFO_STR] $DETECTED_MAC \033[0m"
echo -e "\033[33m [$INFO_STR] $INSTPKG_WITH_HB ... \033[0m"
brew install protobuf xz brotli lz4 aria2
fi
}
python_install(){
echo -e "\033[33m [$INFO_STR] $PY2ANDPIP_INST ... \033[0m"
sudo apt-get --purge remove -y python3-pip
sudo apt install python aptitude -y
sudo aptitude install python-dev -y
sudo add-apt-repository universe
sudo python get-pip.py
sudo apt install python3 python3-pip -y
}
pip_module_install(){
echo -e "\033[33m [$INFO_STR] $INSTALLING_PYTHONMOD... \033[0m"
if [[ "$USE_MIRROR_FOR_PIP" == "true" ]] ; then
sudo pip install backports.lzma pycryptodome pycrypto -i $PIP_MIRROR
sudo pip3 install backports.lzma pycryptodome pycrypto -i $PIP_MIRROR
elif [[ "$USE_MIRROR_FOR_PIP" == "false" ]] ; then
sudo pip install backports.lzma pycryptodome pycrypto
sudo pip3 install backports.lzma pycryptodome pycrypto
fi
echo -e "\033[33m [$INFO_STR] $INSTALLING_PYTHONMOD requirements\033[0m"
if [[ "$USE_MIRROR_FOR_PIP" == "true" ]] ; then
for requirements_list in $(find $LOCALDIR -type f | grep "requirements.txt");do
sudo pip install -r $requirements_list -i $PIP_MIRROR
sudo pip3 install -r $requirements_list -i $PIP_MIRROR
done
elif [[ "$USE_MIRROR_FOR_PIP" == "false" ]] ; then
for requirements_list in $(find $LOCALDIR -type f | grep "requirements.txt");do
sudo pip install -r $requirements_list
sudo pip3 install -r $requirements_list
done
fi
}
debug_packages_version(){
if [[ "$2" == "java" ]] ; then
$2 -version &> $2.ver
else
$2 --version &> $2.ver
fi
TARGET_SOFTWARE_VERSION=$(cat $2.ver | head -n 1)
echo -e "\033[33m [$DEBUG_STR] $1 $VERSION_STR: $TARGET_SOFTWARE_VERSION \033[0m"
rm -rf $2.ver
}
java_install(){
if apt list | grep -q openjdk-11-jdk ;then
JAVA_PACKAGE="openjdk-11-jdk"
else
JAVA_PACKAGE="openjdk-8-jdk"
fi
UNINSTALL_PACKAGE="openjdk-8-jdk"
if [[ "$JAVA_PACKAGE" != "$UNINSTALL_PACKAGE" ]];then
sudo apt -y purge $UNINSTALL_PACKAGE
fi
echo -e "\033[33m [$INFO_STR] $INSTALLING_JAVAPKG: $JAVA_PACKAGE... \033[0m"
sudo apt install -y $JAVA_PACKAGE default-jre
}
dump_welcome
{
trap 'echo -e "\033[31m [$ERROR_STR] $FAILED_INSTPKG ! \033[0m"; exit 1' ERR
java_install
dependency_install
python_install
pip_module_install
}
debug_packages_version Python python
debug_packages_version Pip pip
debug_packages_version Python3 python3
debug_packages_version Pip3 pip3
debug_packages_version Java java
echo -e "\033[32m [$INFO_STR] $SUCCFINISH_OPER: $ENVSETUP_TOOLS \033[0m"
echo -e "\033[32m [$INFO_STR] $SELECT_LANG_STR, $EXITING_STR... \033[0m"