forked from hailo-ai/tappas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_system_requirements.sh
executable file
·150 lines (132 loc) · 4.43 KB
/
check_system_requirements.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
readonly table_file="system_reqs_table.log"
readonly log_file="system_reqs_results.log"
readonly log_boundary=" | "
# V marks a satisfied requirement.
readonly log_found="V$log_boundary"
# X marks an unsatisfied requirement.
readonly log_missing="X$log_boundary"
readonly log_warning=" $log_boundary"
if [ -z "$GCC_VERSION" ]; then
echo GCC version not set
exit 1
fi
declare -a apt_reqs
apt_reqs[0]='ffmpeg'
apt_reqs[1]='x11-utils'
apt_reqs[2]='python3-dev'
apt_reqs[3]='python3-pip'
apt_reqs[4]='python3-setuptools'
apt_reqs[5]='libgirepository'
apt_reqs[6]="gcc-$GCC_VERSION"
apt_reqs[7]="g++-$GCC_VERSION"
apt_reqs[8]='python-gi-dev'
apt_reqs[9]='pkg-config'
apt_reqs[10]='libcairo2-dev'
apt_reqs[11]='libgirepository1.0-dev'
apt_reqs[12]='libgstreamer1.0-dev'
apt_reqs[13]='cmake'
apt_reqs[14]='libgstreamer-plugins-base1.0-dev'
apt_reqs[15]='libzmq3-dev'
apt_reqs[16]='rsync'
apt_reqs[17]='git'
apt_reqs[18]='libgstreamer-plugins-bad1.0-dev'
apt_reqs[19]='gstreamer1.0-plugins-base'
apt_reqs[20]='gstreamer1.0-plugins-good'
apt_reqs[21]='gstreamer1.0-plugins-bad'
apt_reqs[22]='gstreamer1.0-libav'
apt_reqs[23]='gstreamer1.0-tools'
apt_reqs[24]='gstreamer1.0-x'
declare -a pkg_config_reqs
pkg_config_reqs[0]='opencv_imgproc'
pkg_config_reqs[1]='opencv_core'
pkg_config_reqs[2]='opencv_imgcodec'
pkg_config_reqs[3]='opencv_features2d'
pkg_config_reqs[4]='opencv_calib3d'
pkg_config_reqs[5]='opencv_flann'
error=false
function check_system_requirements__apt_packages() {
installed_packages=$(apt list --installed)
for requirement in ${apt_reqs[@]}
do
# Find if the current requirement is installed with apt:
found="$(( echo $installed_packages | grep $requirement) || echo "X")"
if [[ $found == "X" ]]; then
echo "WARNING: Requirement $requirement not found." 1>&2
echo "$log_warning Missing package: $requirement." >> $log_file
error=true
else
found="V"
echo "$log_found Package $requirement found." >> $log_file
fi
echo -e "Apt-Package\t$requirement\t$found\tRequired" >> $table_file
done
}
function check_system_requirements__pkg_config(){
pkg-config opencv4 2> /dev/null
if [[ $? -ne 0 ]];then
echo "WARNING: Requirement opencv4 not found." 1>&2
echo "$log_warning Missing package: opencv4." >> $log_file
error=true
found="X"
else
found="V"
echo "$log_found Package opencv4 found." >> $log_file
fi
echo -e "Pkg_config-Package\topencv4\t$found\tRequired" >> $table_file
installed_libs=$(pkg-config --libs opencv4)
for requirement in ${pkg_config_reqs[@]}
do
found="$( echo $installed_libs | grep $requirement 2>/dev/null)"
if [[ $found == "" ]]; then
echo "WARNING: Requirement $requirement not found." 1>&2
echo "$log_warning Missing package: $requirement." >> $log_file
error=true
found="X"
else
found="V"
echo "$log_found Package $requirement found." >> $log_file
fi
echo -e "Pkg_config-Package\t$requirement\t$found\tRequired" >> $table_file
done
}
function check_system_requirements__check_gst() {
gst-inspect-1.0 --gst-version &>>/dev/null
if [[ $? -ne 0 ]]; then
echo "WARNING: Requirement Gstreamer not found." 1>&2
echo "$log_warning Missing package: Gstreamer." >> $log_file
error=true
found="X"
else
found="V"
echo "$log_found Package Gstreamer found." >> $log_file
fi
echo -e "Package\tGstreamer\t$found\tRequired" >> $table_file
}
function check_system_requirements__print_report() {
echo -e "\nSYSTEM REQUIREMENTS REPORT\n"
column -t $table_file
echo ""
echo "See $log_file for more information."
rm $table_file
exit 1
}
function check_system_requirements__main() {
if test -f $table_file; then
rm $table_file
fi
echo -e "Component\tRequirement\tFound" >> $table_file
echo -e "==========\t==========\t==========\t========== " >> $table_file
if test -f $log_file; then
rm $log_file
fi
echo -e "HAILO System requirements check - log\n" >> $log_file
check_system_requirements__apt_packages
check_system_requirements__pkg_config
check_system_requirements__check_gst
if [ "$error" == true ]; then
check_system_requirements__print_report
fi
rm $table_file
}
check_system_requirements__main