forked from bloatmode/matlab-aur
-
Notifications
You must be signed in to change notification settings - Fork 4
/
PKGBUILD
349 lines (311 loc) · 12.5 KB
/
PKGBUILD
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# Maintainer: Victrid <weihau.chiang at gmail dot com>
# Modified from Batuhan Baserdem <lastname dot firstname at gmail> https://github.com/bloatmode/matlab-aur
# Matlab packaging for archlinux
name=MATLAB
pkgbase=matlab
pkgname=('python-matlabengine' 'matlab')
pkgrel=4
# No need to modify the pkgver here, which will be determined by the script
# in the offline installer you provided.
pkgver=9.10.0.1710957
pkgdesc='A high-level language for numerical computation and visualization'
arch=('x86_64')
url='http://www.mathworks.com'
license=(custom)
makedepends=('gendesk' 'python' 'findutils' 'icoutils')
depends=(
'ca-certificates'
'lsb-release'
'alsa-lib'
'atk'
'libcap'
'libcups'
'libdbus'
'fontconfig'
'libgcrypt'
'gdk-pixbuf2'
'gst-plugins-base'
'gstreamer'
'gtk2'
'krb5'
'nspr'
'nss'
'pam'
'pango'
'cairo'
'libsm'
'libsndfile'
'libx11'
'libxcb'
'libxcomposite'
'libxcursor'
'libxdamage'
'libxext'
'libxfixes'
'libxft'
'libxi'
'libxmu'
'libxrandr'
'libxrender'
'libxslt'
'libxss'
'libxt'
'libxtst'
'libxxf86vm'
'procps-ng'
'xorg-server-xvfb'
'x11vnc'
'sudo'
'zlib')
# These I got from arch before and afraid to play around.
# GCC: https://www.mathworks.com/support/requirements/supported-compilers.html
depends+=(
'gconf'
'glu'
'gstreamer'
'libunwind'
'libxp'
'libxpm'
'portaudio'
'qt5-svg'
'qt5-webkit'
'qt5-websockets'
'qt5-x11extras'
'xerces-c')
provides=('matlab-licenses' 'python-matlabengine' 'matlab-bin')
source=(
"matlab.tar.zst" # Modify this to fit your file
"matlab.fik"
"matlab.lic"
"matlab.script")
md5sums=(SKIP SKIP SKIP 'b6651d0199305f18ab8c0c464b86a9c7')
# Limit products to lower size, set this to true to do a partial install
partialinstall=false
# Example list of products for a partial install; check README.md for details
products=(
"MATLAB"
#---MATLAB Product Family---#
"Curve_Fitting_Toolbox" # Math and Optimization
"Database_Toolbox" # Database Access and Reporting
"Deep_Learning_HDL_Toolbox"
"Deep_Learning_Toolbox"
"DSP_System_Toolbox"
"Global_Optimization_Toolbox"
"GPU_Coder"
"MATLAB_Coder" # Code Generation
"MATLAB_Compiler" # Application Deployement
"MATLAB_Compiler_SDK"
"Optimization_Toolbox"
"Parallel_Computing_Toolbox" # Parallel computing
"Partial_Differential_Equation_Toolbox"
"Reinforcement_Learning_Toolbox"
"Statistics_and_Machine_Learning_Toolbox" # AI, Data Science, Statistics
"Symbolic_Math_Toolbox"
"Text_Analytics_Toolbox"
#---Application Products---#
"Audio_Toolbox"
"Bioinformatics_Toolbox" # Computational Biology
"Computer_Vision_Toolbox"
"Image_Processing_Toolbox" # Image Processing and Computer Vision
"Signal_Processing_Toolbox" # Signal Processing
"Wavelet_Toolbox"
)
instdir="/usr/lib/${pkgbase}"
pkgver() {
cat "${srcdir}/${pkgbase}/VersionInfo.xml" | grep "<version>" | sed "s|\s*<version>\(.*\)</version>\s*|\1|g"
}
prepare() {
# Extract file installation key
release=$(cat "${srcdir}/${pkgbase}/VersionInfo.xml" | grep "<release>" | sed "s|\s*<release>\(.*\)</release>\s*|\1|g")
msg2 "Release from tarball: ${release}"
_fik=$(grep -o '[0-9-]*' "${srcdir}/${pkgbase}.fik")
msg2 "Modifying the installer settings..."
_set="${srcdir}/${pkgbase}/installer_input.txt"
sed -i "s|^# destinationFolder=|destinationFolder=${srcdir}/build|" "${_set}"
sed -i "s|^# fileInstallationKey=|fileInstallationKey=${_fik}|" "${_set}"
sed -i "s|^# agreeToLicense=|agreeToLicense=yes|" "${_set}"
sed -i "s|^# licensePath=|licensePath=${srcdir}/matlab.lic|" "${_set}"
# Select products if partialinstall is set
if [ "${partialinstall}" = 'true' ]; then
for _prod in "${products[@]}"; do
sed -i 's|^#\(product.'"${_prod}"'\)|\1|' "${_set}"
done
fi
# Desktop file
# Implemented a fix for intel gpus with mesa 20;
# https://wiki.archlinux.org/index.php/MATLAB#OpenGL_acceleration
# https://wiki.archlinux.org/index.php/Intel_graphics#Old_OpenGL_Driver_(i965)
msg2 "Generating desktop file..."
gendesk -f -n \
--pkgname "${pkgbase}" \
--pkgdesc "${pkgdesc}" \
--name "MATLAB" \
--categories "Development;Education;Science;Mathematics;IDE" \
--mimetypes "application/x-matlab-data;text/x-matlab" \
--icon "${pkgbase}" \
--exec 'sh -c '\''if [ "${MATLAB_INTEL_OVERRIDE}" = "yes" ] ; then exec env MESA_LOADER_DRIVER_OVERRIDE=i965 GTK_PATH=/usr/lib/gtk-2.0 matlab -desktop ; else exec env GTK_PATH=/usr/lib/gtk-2.0 matlab -desktop ; fi'\'
}
build() {
msg2 "Installing with original installer..."
# Using the installer with the -inputFile parameter will automatically
# cause the installation to be non-interactive
"${srcdir}/${pkgbase}/install" -inputFile "${srcdir}/${pkgbase}/installer_input.txt"
msg2 "Build the python API"
cd "${srcdir}/build/extern/engines/python"
msg2 "Checking supported vs existing matlab versions"
_matminor="$(find "${srcdir}/build/extern/engines/python" \
-name 'matlabengineforpython3*.so' |
sort |
sed 's|.*matlabengineforpython3_\([0-9]\+\)\.so|\1|g' |
tail -1)"
_pytminor="$(python -c 'import sys; print(sys.version_info.minor)')"
msg2 "Spoof version compatibility if not applicable"
if [[ "${_pytminor}" != "${_matminor}" ]]; then
_matcustom="${srcdir}/sitecustomize.py"
touch "${_matcustom}"
echo 'import sys' >> "${_matcustom}"
echo "sys.version_info = (3, ${_matminor}, 0)" >> "${_matcustom}"
fi
PYTHONPATH="${srcdir}" python setup.py build
msg2 removing build licenses...
rm -rf "${srcdir}/build/licenses/*"
}
package_python-matlabengine() {
depends+=("python" "matlab")
msg2 "Copying license"
install -D -m644 "${srcdir}/${pkgbase}/license_agreement.txt" \
"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
msg2 "Package the python API"
cd "${srcdir}/build/extern/engines/python"
PYTHONPATH="${srcdir}" python setup.py install --root="${pkgdir}" --optimize 1 --skip-build
msg2 "Spoofing trick to fool matlab into believing current python version is supported"
_matminor="$(find "${srcdir}/build/extern/engines/python" \
-name 'matlabengineforpython3*.so' |
sort |
sed 's|.*matlabengineforpython3_\([0-9]\+\)\.so|\1|g' |
tail -1)"
_prefix="$(python -c 'import sys; print(sys.prefix)')"
_pytminor="$(python -c 'import sys; print(sys.version_info.minor)')"
msg2 "Change around locations if spoofing is needed"
if [[ "${_pytminor}" != "${_matminor}" ]]; then
mv "${pkgdir}/${_prefix}/lib/python3".{"${_matminor}","${_pytminor}"}
_egginfo="$(ls "${pkgdir}/${_prefix}/lib/python3.${_pytminor}/site-packages/"*"-py3.${_matminor}.egg-info")"
mv "${_egginfo}" "${_egginfo%py3."${_matminor}".egg-info}py3.${_pytminor}.egg-info"
sed -i "s|sys.version_info|(3, $_matminor, 0)|" \
"${pkgdir}/${_prefix}/lib/python3.${_pytminor}/site-packages/matlab/engine/__init__.py"
fi
msg2 "Fix erronous referances in the _arch.txt files"
errstr=$(realpath "${srcdir}/build/extern/engines/python/")
trustr="${instdir}/extern/engines/python/"
for _dir in \
"${srcdir}/build/extern/engines/python/build/lib/matlab/engine" \
"${pkgdir}/${_prefix}/lib/python3.${_pytminor}/site-packages/matlab/engine" \
; do
sed -i "s|${errstr}|${trustr}|" "${_dir}/_arch.txt"
done
}
package_matlab() {
# Compilers should be optional depends
msg2 "Determining compiler versions..."
if [ "$(vercmp ${pkgver} "9.10" )" -ge "0" ]; then
optdepends+=('gcc9: For MEX support'
'gcc8-fortran: For MEX support')
gccexc="gcc-9"
gppexc="g++-9"
gfortranlib="gcc8-fortran"
gfortranexc="gfortran-8"
elif [ "$(vercmp ${pkgver} "9.9" )" -ge "0" ]; then
optdepends+=('gcc8: For MEX support'
'gcc8-fortran: For MEX support')
gccexc="gcc-8"
gppexc="g++-8"
gfortranlib="gcc8-fortran"
gfortranexc="gfortran-8"
elif [ "$(vercmp ${pkgver} "9.4" )" -ge "0" ]; then
optdepends+=('gcc6: For MEX support'
'gcc6-fortran: For MEX support')
gccexc="gcc-6"
gppexc="g++-6"
gfortranlib="gcc6-fortran"
gfortranexc="gfortran-6"
elif [ "$(vercmp ${pkgver} "9.1" )" -ge "0" ]; then
optdepends+=('gcc49: For MEX support')
gccexc="gcc-49"
gppexc="g++-49"
gfortranlib="gcc49"
gfortranexc="gfortran-49"
elif [ "$(vercmp ${pkgver} "8.2" )" -ge "0" ]; then
optdepends+=('gcc47: For MEX support')
gccexc="gcc-47"
gppexc="g++-47"
gfortranlib="gcc47"
gfortranexc="gfortran-47"
else
msg2 "You need to install the GCC for MEX support yourself."
msg2 "Visit here to determine your needed GCC version."
msg2 "https://www.mathworks.com/support/requirements/previous-releases.html"
msg2 "Create your own GCC package with name \"gcc-matlab\", and link these excutables to /usr/bin:"
msg2 "gcc-matlab g++-matlab gfortran-matlab"
gccexc="gcc-matlab"
gppexc="g++-matlab"
gfortranlib="gcc-matlab"
gfortranexc="gfortran-matlab"
fi
msg2 "Moving files from build area"
install -dm755 "${pkgdir}/usr/lib/"
mv "${srcdir}/build" "${pkgdir}/${instdir}"
msg2 "Copying license"
install -D -m644 "${srcdir}/${pkgbase}/license_agreement.txt" \
"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
msg2 "Symlink executables"
install -d -m755 "${pkgdir}/usr/bin/"
for _executable in deploytool matlab mbuild activate_matlab.sh; do
ln -s "${instdir}/bin/${_executable}" "${pkgdir}/usr/bin/${_executable}"
done
# This would otherwise conflict with mixtex
ln -s "${instdir}/bin/mex" "${pkgdir}/usr/bin/mex-${pkgbase}"
# This would otherwise conflict with mathematica
ln -s "${instdir}/bin/mcc" "${pkgdir}/usr/bin/mcc-${pkgbase}"
# Allow external software to find MATLAB linter binary
ln -s "${instdir}/bin/glnxa64/mlint" "${pkgdir}/usr/bin/mlint"
msg2 "Install desktop files"
install -D -m644 "${srcdir}/${pkgbase}.desktop" \
"${pkgdir}/usr/share/applications/${pkgbase}.desktop"
install -Dm644 "${srcdir}/${pkgbase}/bin/glnxa64/cef_resources/matlab_icon.png" "$pkgdir/usr/share/pixmaps/$pkgbase.png"
msg2 "Link mex options to ancient libraries"
sysdir="bin/glnxa64/mexopts"
mkdir -p "${pkgdir}/${instdir}/backup/${sysdir}"
cp "${pkgdir}/${instdir}/${sysdir}/gcc_glnxa64.xml" \
"${pkgdir}/${instdir}/backup/${sysdir}/"
sed -i "s/gcc/${gccexc}/g" "${pkgdir}/${instdir}/${sysdir}/gcc_glnxa64.xml"
cp "${pkgdir}/${instdir}/${sysdir}/g++_glnxa64.xml" \
"${pkgdir}/${instdir}/backup/${sysdir}/"
sed -i "s/g++/${gppexc}/g" "${pkgdir}/${instdir}/${sysdir}/g++_glnxa64.xml"
cp "${pkgdir}/${instdir}/${sysdir}/gfortran.xml" \
"${pkgdir}/${instdir}/backup/${sysdir}/"
sed -i "s/gfortran/${gfortranexc}/g" "${pkgdir}/${instdir}/${sysdir}/gfortran.xml"
cp "${pkgdir}/${instdir}/${sysdir}/gfortran6.xml" \
"${pkgdir}/${instdir}/backup/${sysdir}/"
sed -i "s/gfortran/${gfortranexc}/g" "${pkgdir}/${instdir}/${sysdir}/gfortran6.xml"
msg2 "Remove unused library files"
# <MATLABROOT>/sys/os/glnxa64/README.libstdc++
sysdir="sys/os/glnxa64"
install -d -m755 "${pkgdir}/${instdir}/backup/${sysdir}"
mv "${pkgdir}/${instdir}/${sysdir}/"{libstdc++.so.6.0.25,libstdc++.so.6} \
"${pkgdir}/${instdir}/backup/${sysdir}/"
mv "${pkgdir}/${instdir}/${sysdir}/libgcc_s.so.1" \
"${pkgdir}/${instdir}/backup/${sysdir}/"
mv "${pkgdir}/${instdir}/${sysdir}/"{libgfortran.so.5.0.0,libgfortran.so.5} \
"${pkgdir}/${instdir}/backup/${sysdir}/"
mv "${pkgdir}/${instdir}/${sysdir}/"{libquadmath.so.0.0.0,libquadmath.so.0} \
"${pkgdir}/${instdir}/backup/${sysdir}/"
# make sure MATLAB can find proper libraries libgfortran.so.3
mkdir -p "${pkgdir}/${instdir}/backup/bin"
cp "${pkgdir}/${instdir}/bin/matlab" "${pkgdir}/${instdir}/backup/bin"
# The gcc dependency should be determined at runtime.
sed -i "1s#^#if pacman -Q "${gfortranlib}' > /dev/null 2>&1 ; then \n export GCCVERSION=$(pacman -Q '${gfortranlib}" | awk '{print \$2}' | cut -d- -f1) \nfi\n\n#" "${pkgdir}/${instdir}/bin/matlab"
sed -i "1s/^/# Check the optional GCC dependency.\n/" "${pkgdir}/${instdir}/bin/matlab"
sed -i 's|LD_LIBRARY_PATH="`eval echo $LD_LIBRARY_PATH`"|if [ -n "${GCCVERSION}" ]; then \n LD_LIBRARY_PATH="`eval echo $LD_LIBRARY_PATH`:/usr/lib/gcc/x86_64-pc-linux-gnu/${GCCVERSION}"; \n else \n LD_LIBRARY_PATH="`eval echo $LD_LIBRARY_PATH`" \n fi \n|g' "${pkgdir}/${instdir}/bin/matlab"
msg2 "Install the script file to make scripting easier with matlab"
install -Dm 0755 "${srcdir}/matlab.script" "${pkgdir}/usr/bin/matscript"
}