63cb012d84b3bfb60e92ddcbf66e72778872bb8b
[platform/upstream/dldt.git] / scripts / install_dependencies / install_openvino_dependencies.sh
1 #!/bin/bash
2
3 # Copyright (c) 2018 Intel Corporation
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 set -e
18
19 if [ $EUID -ne 0 ]; then
20     echo "ERROR: this script must be run as root to install 3rd party packages." >&2
21     echo "Please try again with \"sudo -E $0\", or as root." >&2
22     exit 1
23 fi
24
25 params=$@
26
27 yes_or_no_ffmpeg() {
28     if [ "$params" == "-y" ]; then
29         return 0
30     fi
31
32     while true; do
33         read -p "Add third-party RPM Fusion repository and install FFmpeg package (y/n): " yn
34         case $yn in
35             [Yy]*) return 0  ;;
36             [Nn]*) return  1 ;;
37         esac
38     done
39 }
40
41 yes_or_no_gst_bad_ugly() {
42     if [ "$params" == "-y" ]; then
43         return 0
44     fi
45
46     while true; do
47         read -p "Add third-party RPM Epel, Nux, Fusion, Forensics repositories and install dependencies for GStreamer Bad & Ugly Plugins (y/n): " yn
48         case $yn in
49             [Yy]*) return 0  ;;
50             [Nn]*) return  1 ;;
51         esac
52     done
53 }
54
55 if [ -f /etc/lsb-release ]; then
56     # Ubuntu
57     echo
58     echo "This script installs the following OpenVINO 3rd-party dependencies:"
59     echo "  1. GTK+, FFmpeg and GStreamer libraries used by OpenCV"
60     echo "  2. libusb library required for Myriad plugin for Inference Engine"
61     echo "  3. build dependencies for OpenVINO samples"
62     echo "  4. build dependencies for GStreamer Plugins"
63     echo
64     PKGS=(
65         cpio
66         build-essential
67         cmake
68         libusb-1.0-0-dev
69         libdrm-dev
70         libgstreamer1.0-0
71         gstreamer1.0-plugins-base
72         gstreamer1.0-plugins-good
73         gstreamer1.0-plugins-bad
74         gstreamer1.0-vaapi
75         ffmpeg
76     )
77     system_ver=$(cat /etc/lsb-release | grep -i "DISTRIB_RELEASE" | cut -d "=" -f2)
78     if [ "$system_ver" = "16.04" ]; then
79         PKGS+=( libgtk2.0-0 )
80     else
81         if [ "$system_ver" = "20.04" ]; then
82             PKGS+=( libglib2.0-0
83                     gstreamer1.0-plugins-ugly
84                     gstreamer1.0-libav
85                     libgstreamer-plugins-base1.0-dev
86                     gstreamer1.0-doc
87                     gstreamer1.0-tools
88                     gstreamer1.0-x
89                     gstreamer1.0-alsa
90                     gstreamer1.0-gl
91                     gstreamer1.0-gtk3
92                     gstreamer1.0-qt5
93                     gstreamer1.0-pulseaudio
94                     libgstrtspserver-1.0-dev
95                     python3-gst-1.0
96                     libfluidsynth2
97                     libnettle7
98                     libopenexr24
99                     python3.8
100                     libpython3.8
101                 )
102         elif [ "$system_ver" = "18.04" ]; then
103             PKGS+=( libglib2.0
104                     libfluidsynth1
105                     libnettle6
106                     libopenexr22
107                     gstreamer1.0-plugins-ugly
108                     gstreamer1.0-alsa
109                     gstreamer1.0-gtk3
110                 )
111         fi
112         PKGS+=( flex
113                 bison
114                 libgsl23
115                 gobject-introspection
116                 libgl-dev
117                 libtag-extras1
118                 libusb-1.0-0-dev
119                 libdirectfb-1.7-7
120                 libfaac0
121                 libfdk-aac1
122                 liblrdf0
123                 libmjpegtools-dev
124                 libopenni2-0
125                 libmpeg2-4
126                 libopencore-amrnb0
127                 libopencore-amrwb0
128                 liba52-0.7.4
129         )
130     fi
131     apt update
132     # shellcheck disable=SC2068
133     apt install -y ${PKGS[@]}
134 else
135     # CentOS
136     echo
137     echo "This script installs the following OpenVINO 3rd-party dependencies:"
138     echo "  1. GTK+ and GStreamer libraries used by OpenCV"
139     echo "  2. libusb library required for Myriad plugin for Inference Engine"
140     echo "  3. Python 3.6 for Model Optimizer"
141     echo "  4. gcc 4.8.5 and other build dependencies for OpenVINO samples"
142     echo "  5. build dependencies for GStreamer Plugins"
143     echo
144     PKGS=(
145         libusbx-devel
146         gtk2
147         gstreamer1
148         gstreamer1-plugins-good
149         gstreamer1-plugins-bad-free
150         gcc
151         gcc-c++
152         make
153         glibc-static
154         glibc
155         libstdc++-static
156         libstdc++
157         libstdc++
158         libgcc
159         cmake
160         python36
161         python36-pip
162         glib2-devel
163         flex
164         bison
165         gmp
166         gsl
167         gobject-introspection
168         libcap
169         libcap
170         gettext
171         libXrandr
172         libX11
173         iso-codes
174         mesa-libEGL
175         mesa-libGLES
176         mesa-libGL
177         libgudev1
178         libtheora
179         cdparanoia
180         pango
181         mesa-libgbm
182         alsa-lib
183         libjpeg-turbo
184         libvisual
185         libXv
186         opus
187         libvorbis
188         patch
189         bzip2
190         libv4l
191         flac
192         gdk-pixbuf2
193         libdv
194         mpg123
195         libraw1394
196         libavc1394
197         libiec61883
198         pulseaudio-libs
199         libsoup
200         speex
201         wavpack
202         boost-regex-1.53.0
203     )
204     yum install -y ${PKGS[@]}
205
206     # Thirdparty repositories for installing GStreamer Bad & Ugly Plugins dependencies.
207     if yes_or_no_gst_bad_ugly; then
208         GST_BAD_UGLY_PKGS=(
209             bluez-libs
210             libusb
211             libass
212             libbs2b
213             libchromaprint
214             lcms2
215             libssh2
216             libdc1394
217             libXext
218             libssh
219             libdca
220             faac
221             fdk-aac
222             flite
223             fluidsynth
224             game-music-emu
225             gsm
226             nettle
227             kate
228             liblrdf
229             libde265
230             mjpegtools
231             libmms
232             libmodplug
233             libmpcdec
234             neon
235             openal-soft
236             OpenEXR
237             openjpeg2
238             openni
239             libdvdnav
240             librtmp
241             librsvg2
242             sbc
243             libsndfile
244             soundtouch
245             spandsp
246             libsrtp
247             zvbi
248             vo-amrwbenc
249             webrtc-audio-processing
250             wildmidi
251             zbar
252             libnice
253             libxkbcommon
254             libmpeg2
255             libcdio
256             opencore-amr
257             libva
258             python36-gobject
259             python3-devel
260         )
261         yum install -y epel-release
262         rpm -Uvh https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
263         RPMFUSION_IS_INSTALLED=1
264         yum install -y https://forensics.cert.org/cert-forensics-tools-release-el7.rpm
265         yum install -y ${GST_BAD_UGLY_PKGS[@]}
266     else
267         echo "Dependencies for GStreamer Ugly & Bad plugins installation skipped."
268         echo
269     fi
270
271     echo
272     echo "Intel(R) Distribution of OpenVINO(TM) toolkit can use FFmpeg for processing video streams with OpenCV. Please select your preferred method for installing FFmpeg:"
273     echo
274     echo "Option 1: Allow installer script to add a third party repository, RPM Fusion (https://rpmfusion.org/), which contains FFmpeg. FFmpeg rpm package will be installed from this repository. "
275     echo "WARNING: This repository is NOT PROVIDED OR SUPPORTED by Intel or CentOS. Neither Intel nor CentOS has control over this repository. Terms governing your use of FFmpeg can be found here: https://www.ffmpeg.org/legal.html "
276     echo "Once added, this repository will be enabled on your operating system and can thus receive updates to all packages installed from it. "
277     echo
278     echo "Consider the following ways to prevent unintended 'updates' from this third party repository from over-writing some core part of CentOS:"
279     echo "a) Only enable these archives from time to time, and generally leave them disabled. See: man yum"
280     echo "b) Use the exclude= and includepkgs= options on a per sub-archive basis, in the matching .conf file found in /etc/yum.repos.d/ See: man yum.conf"
281     echo "c) The yum Priorities plug-in can prevent a 3rd party repository from replacing base packages, or prevent base/updates from replacing a 3rd party package."
282     echo
283     echo "Option 2: Skip FFmpeg installation."
284     echo
285
286     if yes_or_no_ffmpeg; then
287         if [[ -z $RPMFUSION_IS_INSTALLED ]]; then
288             yum install -y epel-release
289             rpm -Uvh https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
290         fi
291         yum install -y ffmpeg
292     else
293         echo "FFmpeg installation skipped. You may build FFmpeg from sources as described here: https://trac.ffmpeg.org/wiki/CompilationGuide/Centos"
294         echo
295     fi
296     exit
297 fi