-
Notifications
You must be signed in to change notification settings - Fork 0
/
dep_install.sh
130 lines (115 loc) · 3.2 KB
/
dep_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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/bash
# Copyright (c) [2021] Huawei Technologies Co.,Ltd.ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
####################################
# @Author : lemon-higgins
# @email : [email protected]
# @Date : 2021-04-23 16:08:22
# @License : Mulan PSL v2
# @Version : 1.0
# @Desc :
#####################################
usage() {
printf "Usage: sh dep_install.sh [options]\n
-e: install addtitional dependencies qemu for remote testing\n
-g shell_file: run shell file to set crocess compiliation, if have run srcipt must use source\n
-h: print this usage info\n
\n"
}
common_dep(){
yum install expect psmisc make iputils python3-six python3-paramiko -y
}
anolis_dep(){
yum install expect psmisc make iputils gcc -y
yum install python39 -y
ln -s -f /usr/bin/pip3.9 /etc/alternatives/pip3
ln -s -f /usr/bin/pip-3.9 /etc/alternatives/pip-3
ln -s -f /usr/bin/python3.9 /etc/alternatives/python3
pip3 install paramiko -i https://pypi.tuna.tsinghua.edu.cn/simple
}
qemu_dep(){
echo "install qemu"
yum install bridge-utils -y
qemu-system-aarch64 --version && qemu-system-arm --version
if [ $? -eq 0 ]; then
return 0
fi
yum install qemu-system-aarch64 qemu-system-arm -y
if [ $? -ne 0 ]; then
echo "ERROR: qemu not install, you need install it youself."
return 1
fi
}
run_name=$0
in_qemu=0
run_shell=""
check_option(){
had_g=0
for opt in "$@"; do
if [[ $opt == "-h" ]]; then
usage
return 0
elif [[ $opt == "-e" ]]; then
in_qemu=1
elif [[ $opt == "-g" ]]; then
had_g=1
check_name=${run_name##*/}
if [[ $check_name == "dep_install.sh" ]]; then
echo "ERROR: run with crocess compiliation, must use 'source' to run script"
return 1
fi
elif [ $had_g -eq 1 ]; then
run_shell=$opt
else
usage
return 1
fi
done
if [[ had_g -eq 1 && run_shell == "" ]]; then
echo "ERROR: -g parameter need"
usage
return 1
fi
return 0
}
main(){
check_option $@
if [ $? -ne 0 ]; then
return 1
fi
uname -r | grep 'oe'
if [ $? -eq 0 ]; then
common_dep
if [ $? -ne 0 ]; then
return 1
fi
fi
uname -r | grep 'an'
if [ $? -eq 0 ]; then
anolis_dep
if [ $? -ne 0 ]; then
return 1
fi
fi
if [ $in_qemu -eq 1 ]; then
qemu_dep
if [ $? -ne 0 ]; then
return 1
fi
fi
if [ $run_shell ]; then
source $run_shell
if [ $? -ne 0 ]; then
echo "ERROR: run crocess compiliation file $run_shell fail"
return 1
fi
fi
return 0
}
main $@