This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
msdk_pre_install_internal.py
executable file
·277 lines (231 loc) · 10.9 KB
/
msdk_pre_install_internal.py
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#!/usr/bin/python
"""
Copyright (c) 2018 Intel Corporation All Rights Reserved.
THESE MATERIALS ARE PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THESE
MATERIALS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
File Name: msdk_pre_install.py
Abstract: Complete install for Intel Visual Analytics, including
* Intel(R) Media SDK
* Intel(R) Media driver
* Libva
* Drivers
* Prerequisites
"""
import os, sys, platform
import os.path
import argparse
import subprocess
import grp
class diagnostic_colors:
ERROR = '\x1b[31;1m' # Red/bold
SUCCESS = '\x1b[32;1m' # green/bold
RESET = '\x1b[0m' # Reset attributes
INFO = '\x1b[34;1m' # info
OUTPUT = '' # command's coutput printing
STDERR = '\x1b[36;1m' # cyan/bold
SKIPPED = '\x1b[33;1m' # yellow/bold
class loglevelcode:
ERROR = 0
SUCCESS = 1
INFO = 2
GLOBAL_LOGLEVEL=3
def print_info( msg, loglevel ):
global GLOBAL_LOGLEVEL
""" printing information """
if loglevel==loglevelcode.ERROR and GLOBAL_LOGLEVEL>=0:
color = diagnostic_colors.ERROR
msgtype=" [ ERROR ] "
print( color + msgtype + diagnostic_colors.RESET + msg )
elif loglevel==loglevelcode.SUCCESS and GLOBAL_LOGLEVEL>=1:
color = diagnostic_colors.SUCCESS
msgtype=" [ OK ] "
print( color + msgtype + diagnostic_colors.RESET + msg )
elif loglevel==loglevelcode.INFO and GLOBAL_LOGLEVEL>=2:
color = diagnostic_colors.INFO
msgtype=" [ INFO ] "
print( color + msgtype + diagnostic_colors.RESET + msg )
return
def run_cmd(cmd):
output=""
fin=os.popen(cmd+" 2>&1","r")
for line in fin:
output+=line
fin.close()
return output
def fnParseCommandline():
if len(sys.argv) == 1:
return "-all"
elif len(sys.argv) > 3:
return "not support"
exit(0)
if sys.argv[1] == "-h":
print("[%s" % sys.argv[0] + " usage]")
print( "\t -h: display help")
print( "\t -all: install all components")
print( "\t -b BUILD_TARGET: build all components")
print( "\t -m : build msdk only")
exit(0)
return sys.argv[1]
if __name__ == "__main__":
LIBVA_INSTALL_PREFIX="/opt/intel/svet/msdk"
LIBVA_INSTALL_PATH=LIBVA_INSTALL_PREFIX+"/lib"
LIBVA_DRIVERS_PATH=LIBVA_INSTALL_PATH+"/dri"
LIBVA_DRIVER_NAME="iHD"
WORKING_DIR=run_cmd("pwd").strip()
msg_tmp = "Working directory: " + WORKING_DIR
print_info(msg_tmp, loglevelcode.INFO)
BUILD_TARGET=""
build_msdk = False
build_all = False
cmd = fnParseCommandline()
if cmd == "-b":
BUILD_TARGET=sys.argv[2]
build_all = True
pre_install = False
elif cmd == "-m":
print_info("Build MSDK", loglevelcode.INFO)
build_msdk = True
pre_install = False
else:
pre_install = True
if pre_install == True:
print("")
print("************************************************************************")
print_info("Install required tools and create build environment.", loglevelcode.INFO)
print("************************************************************************")
# Install the necessary tools
print("Please input the sudo password to proceed\n")
cmd ="sudo apt-get -y install git libssl-dev dh-autoreconf cmake libgl1-mesa-dev libpciaccess-dev build-essential curl unzip-dev libavcodec-dev libavutil-dev libavformat-dev;"
cmd+="sudo apt-get -y install coreutils pkg-config opencl-clhpp-headers opencl-c-headers ocl-icd-opencl-dev"
os.system(cmd)
print("")
print("************************************************************************")
print_info("Pull all the source code.", loglevelcode.INFO)
print("************************************************************************")
# Pull all the source code
print("libva")
if not os.path.exists("%s/libva"%(WORKING_DIR)):
cmd = "cd %s; git clone https://github.com/intel/libva.git;"%(WORKING_DIR)
cmd+= "cd libva;"
cmd+="git checkout 2.11.0"
print(cmd)
os.system(cmd);
print("libva-utils")
if not os.path.exists("%s/libva-utils"%(WORKING_DIR)):
cmd = "cd %s; git clone https://github.com/intel/libva-utils.git;"%(WORKING_DIR)
cmd += "cd libva-utils;"
cmd+="git checkout 2.11.1"
print(cmd)
os.system(cmd);
print("media-driver")
if not os.path.exists("%s/media-driver"%(WORKING_DIR)):
cmd = "cd %s; git clone https://github.com/intel/media-driver.git; "%(WORKING_DIR)
cmd += "cd media-driver;"
cmd+= "git checkout intel-media-21.1.3"
print(cmd)
os.system(cmd);
print("gmmlib")
if not os.path.exists("%s/gmmlib"%(WORKING_DIR)):
cmd = "cd %s; git clone https://github.com/intel/gmmlib.git; "%(WORKING_DIR)
cmd += "cd gmmlib;"
cmd+= "git checkout intel-gmmlib-21.1.1"
print(cmd)
os.system(cmd);
print("MediaSDK")
if not os.path.exists("%s/MediaSDK"%(WORKING_DIR)):
cmd = "cd %s; git clone https://github.com/Intel-Media-SDK/MediaSDK.git; "%(WORKING_DIR)
cmd+= "cd MediaSDK;"
cmd+= "git checkout intel-mediasdk-21.1.3"
print(cmd)
os.system(cmd);
if build_all == True:
print("")
print("************************************************************************")
print_info("Build and Install libVA", loglevelcode.INFO)
print("************************************************************************")
# Build and install libVA including the libVA utils for vainfo.
# libVA origin:fbf7138389f7d6adb6ca743d0ddf2dbc232895f6 (011118), libVA utils origin: 7b85ff442d99c233fb901a6fe3407d5308971645 (011118)
cmd ="export LIBRARY_PATH=%s:$LIBRARY_PATH; "%(LIBVA_INSTALL_PATH)
cmd+="cd %s/libva; "%(WORKING_DIR)
cmd+="./autogen.sh --prefix=%s --libdir=%s; make -j4; sudo make install"%(LIBVA_INSTALL_PREFIX, LIBVA_INSTALL_PATH)
print(cmd)
os.system(cmd)
cmd ="export PKG_CONFIG_PATH=%s/pkgconfig:$PKG_CONFIG_PATH; "%(LIBVA_INSTALL_PATH)
cmd+="export LIBRARY_PATH=%s:$LIBRARY_PATH; "%(LIBVA_INSTALL_PATH)
cmd+="export C_INCLUDE_PATH=%s/include:$C_INCLUDE_PATH; "%(LIBVA_INSTALL_PREFIX)
cmd+="export CPLUS_INCLUDE_PATH=%s/include:$CPLUS_INCLUDE_PATH; "%(LIBVA_INSTALL_PREFIX)
cmd+="cd %s/libva-utils; "%(WORKING_DIR)
cmd+="./autogen.sh --prefix=%s --libdir=%s; make -j4; sudo make install"%(LIBVA_INSTALL_PREFIX, LIBVA_INSTALL_PATH)
print(cmd)
os.system(cmd)
print("")
print("************************************************************************")
print_info("Build and Install media driver", loglevelcode.INFO)
print("************************************************************************")
# Build and install media driver
cmd ="export LIBRARY_PATH=%s:$LIBRARY_PATH; "%(LIBVA_INSTALL_PATH)
cmd+= "rm -rf %s/gmmlib/build; "%(WORKING_DIR)
cmd+= "mkdir -p %s/gmmlib/build; "%(WORKING_DIR)
cmd+= "cd %s/gmmlib/build; "%(WORKING_DIR)
cmd+= "cmake ../ -DCMAKE_INSTALL_PREFIX=%s ;"%(LIBVA_INSTALL_PREFIX)
cmd+= "make -j4;"
cmd+= "sudo make install;"
print(cmd)
os.system(cmd)
cmd ="export PKG_CONFIG_PATH=%s/pkgconfig:$PKG_CONFIG_PATH; "%(LIBVA_INSTALL_PATH)
cmd+="export LD_LIBRARY_PATH=%s:$LD_LIBRARY_PATH; "%(LIBVA_INSTALL_PATH)
cmd+="export LIBRARY_PATH=%s:$LIBRARY_PATH; "%(LIBVA_INSTALL_PATH)
cmd+="export C_INCLUDE_PATH=%s/include:$C_INCLUDE_PATH; "%(LIBVA_INSTALL_PREFIX)
cmd+="export CPLUS_INCLUDE_PATH=%s/include:$CPLUS_INCLUDE_PATH; "%(LIBVA_INSTALL_PREFIX)
cmd+= "rm -rf %s/media_build; "%(WORKING_DIR)
cmd+= "mkdir -p %s/media_build; "%(WORKING_DIR)
cmd+= "cd %s/media_build; "%(WORKING_DIR)
cmd+= "cmake ../media-driver -DCMAKE_INSTALL_PREFIX=%s -DLIBVA_INSTALL_PATH=%s; "%(LIBVA_INSTALL_PREFIX, LIBVA_INSTALL_PATH)
cmd+= "make -j4; "
cmd+= "sudo LD_LIBRARY_PATH=%s:$LD_LIBRARY_PATH LIBRARY_PATH=%s:$LIBRARY_PATH make install; "%(LIBVA_INSTALL_PATH, LIBVA_INSTALL_PATH)
print(cmd)
os.system(cmd)
if build_all == True or build_msdk == True:
print("")
print("************************************************************************")
print_info("Build and Install Media SDK and samples", loglevelcode.INFO)
print("************************************************************************")
if not os.path.exists("%s/MediaSDK"%(WORKING_DIR)):
print("MediaSDK source code doen't exist!")
sys.exit()
# Build and install Media SDK library and samples
cmd ="export LIBRARY_PATH=%s:$LIBRARY_PATH; "%(LIBVA_INSTALL_PATH)
cmd+="export C_INCLUDE_PATH=%s/include:$C_INCLUDE_PATH; "%(LIBVA_INSTALL_PREFIX)
cmd+="export CPLUS_INCLUDE_PATH=%s/include:$CPLUS_INCLUDE_PATH; "%(LIBVA_INSTALL_PREFIX)
cmd+="export PKG_CONFIG_PATH=%s/pkgconfig:$PKG_CONFIG_PATH;"%(LIBVA_INSTALL_PATH)
cmd+="cd %s/MediaSDK; "%(WORKING_DIR)
cmd+="rm -rf build; "
cmd+="mkdir -p build; "
cmd+="cd build; "
cmd+="cmake ../ -DCMAKE_INSTALL_PREFIX=%s; "%(LIBVA_INSTALL_PREFIX)
cmd+="make -j4; "
cmd+="sudo make install; "
print(cmd)
os.system(cmd)
if pre_install == True:
if not os.path.exists("%s/MediaSDK"%(WORKING_DIR)):
print("MediaSDK source code doen't exist!")
sys.exit()
#cmd = "sudo echo '/usr/lib/x86_64-linux-gnu' > /etc/ld.so.conf.d/libdrm-intel.conf; "
cmd = "sudo echo '%s' > /etc/ld.so.conf.d/libdrm-intel.conf; "%(LIBVA_INSTALL_PATH)
#cmd+= "sudo echo '/usr/lib' >> /etc/ld.so.conf.d/libdrm-intel.conf; "
cmd+= "sudo ldconfig"
print(cmd)
os.system(cmd)
print("************************************************************************")
print(" Done, all installation, please reboot system !!! ")
print("************************************************************************")