-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
setup-arm.sh
executable file
·403 lines (349 loc) · 11.9 KB
/
setup-arm.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
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-only
# MuseScore-CLA-applies
#
# MuseScore
# Music Composition & Notation
#
# Copyright (C) 2023 MuseScore BVBA and others
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# For maximum AppImage compatibility, build on the oldest Linux distribution
# that still receives security updates from its manufacturer.
echo "Setup Linux build environment"
trap 'echo Setup failed; exit 1' ERR
df -h .
while [[ "$#" -gt 0 ]]; do
case $1 in
--arch) PACKARCH="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
BUILD_TOOLS=$HOME/build_tools
ENV_FILE=$BUILD_TOOLS/environment.sh
mkdir -p $BUILD_TOOLS
# Let's remove the file with environment variables to recreate it
rm -f $ENV_FILE
echo "echo 'Setup MuseScore build environment'" >> $ENV_FILE
##########################################################################
# GET DEPENDENCIES
##########################################################################
# DISTRIBUTION PACKAGES
apt_packages=(
cimg-dev
curl
desktop-file-utils
file
fuse
git
gpg
libboost-dev
libboost-filesystem-dev
libboost-regex-dev
libcairo2-dev
libfuse-dev
libtool
libssl-dev
patchelf
pkg-config
software-properties-common # installs `add-apt-repository`
unzip
wget
xxd
p7zip-full
libasound2-dev
libfontconfig1-dev
libfreetype6-dev
libfreetype6
libgl1-mesa-dev
libjack-dev
libnss3-dev
libportmidi-dev
libpulse-dev
libsndfile1-dev
zlib1g-dev
make
patch
coreutils
gawk
sed
desktop-file-utils # installs `desktop-file-validate` for appimagetool
zsync # installs `zsyncmake` for appimagetool
libglib2.0-dev
librsvg2-dev
argagg-dev
libgcrypt20-dev
libcurl4-openssl-dev
libgpg-error-dev
)
# MuseScore compiles without these but won't run without them
apt_packages_runtime=(
libcups2
libdbus-1-3
libegl1-mesa-dev
libgles2-mesa-dev
libodbc1
libpq-dev
libxcomposite-dev
libxcursor-dev
libxi-dev
libxkbcommon-x11-0
libxrandr2
libxtst-dev
libdrm-dev
libxcb-icccm4
libxcb-image0
libxcb-keysyms1
libxcb-randr0
libxcb-render-util0
libxcb-xinerama0
)
apt_packages_ffmpeg=(
ffmpeg
libavcodec-dev
libavformat-dev
libswscale-dev
)
apt-get update # no package lists in Docker image
DEBIAN_FRONTEND="noninteractive" TZ="Europe/London" apt-get install -y --no-install-recommends \
"${apt_packages[@]}" \
"${apt_packages_runtime[@]}" \
"${apt_packages_ffmpeg[@]}"
# Add additional ppas (Qt 5.15.2 and Cmake)
# Poor naming of the cmake ppa, this ppa has bionic/focal/jammy dists
add-apt-repository --yes ppa:theofficialgman/cmake-bionic
add-apt-repository --yes ppa:theofficialgman/opt-qt-5.15.2-focal-arm
apt-get update
# add an exception for the "detected dubious ownership in repository" (only seen inside a Docker image)
git config --global --add safe.directory /MuseScore
##########################################################################
# GET TOOLS
##########################################################################
# COMPILER
apt_packages_compiler=(
automake
gcc
g++
)
apt-get install -y --no-install-recommends \
"${apt_packages_compiler[@]}"
# CMAKE
# Get newer CMake (only used cached version if it is the same)
apt-get install -y --no-install-recommends cmake
cmake --version
# Ninja
apt-get install -y --no-install-recommends ninja-build
echo "ninja version"
ninja --version
##########################################################################
# GET QT
##########################################################################
# Get newer Qt (only used cached version if it is the same)
apt_packages_qt=(
qt515base
qt515declarative
qt515quickcontrols
qt515quickcontrols2
qt515graphicaleffects
qt515imageformats
qt515networkauth-no-lgpl
qt515remoteobjects
qt515svg
qt515tools
qt515translations
qt515wayland
qt515x11extras
qt515xmlpatterns
)
apt-get install -y \
"${apt_packages_qt[@]}"
qt_version="5152"
qt_dir="/opt/qt515"
##########################################################################
# Compile and install nlohmann-json
##########################################################################
export CFLAGS="-Wno-psabi"
export CXXFLAGS="-Wno-psabi"
CURRDIR=${PWD}
cd /
git clone https://github.com/nlohmann/json
cd /json/
git checkout --recurse-submodules v3.10.4
git submodule update --init --recursive
mkdir -p build
cd build
cmake -DJSON_BuildTests=OFF ..
cmake --build . -j $(nproc)
cmake --build . --target install
cd /
##########################################################################
# Compile and install linuxdeploy
##########################################################################
git clone https://github.com/linuxdeploy/linuxdeploy
cd /linuxdeploy/
git checkout --recurse-submodules 49f4f237762395c6a37
git submodule update --init --recursive
# patch src/core/generate-excludelist.sh to use curl instead of wget which fails on armhf
sed -i 's/wget --quiet "$url" -O -/curl "$url"/g' src/core/generate-excludelist.sh
mkdir -p build
cd build
cmake -DBUILD_TESTING=OFF -DUSE_SYSTEM_BOOST=ON ..
cmake --build . -j $(nproc)
mkdir -p $BUILD_TOOLS/linuxdeploy
mv /linuxdeploy/build/bin/* $BUILD_TOOLS/linuxdeploy/
$BUILD_TOOLS/linuxdeploy/linuxdeploy --version
cd /
##########################################################################
# Compile and install linuxdeploy-plugin-qt
##########################################################################
git clone https://github.com/linuxdeploy/linuxdeploy-plugin-qt
cd /linuxdeploy-plugin-qt/
git checkout --recurse-submodules 59b6c1f90e21ba14
git submodule update --init --recursive
# patch src/core/generate-excludelist.sh to use curl instead of wget which fails on armhf
sed -i 's/wget --quiet "$url" -O -/curl "$url"/g' lib/linuxdeploy/src/core/generate-excludelist.sh
mkdir -p build
cd build
cmake -DBUILD_TESTING=OFF -DUSE_SYSTEM_BOOST=ON ..
cmake --build . -j $(nproc)
mv /linuxdeploy-plugin-qt/build/bin/linuxdeploy-plugin-qt $BUILD_TOOLS/linuxdeploy/linuxdeploy-plugin-qt
$BUILD_TOOLS/linuxdeploy/linuxdeploy --list-plugins
cd /
##########################################################################
# Compile and install linuxdeploy-plugin-appimage
##########################################################################
git clone https://github.com/linuxdeploy/linuxdeploy-plugin-appimage
cd /linuxdeploy-plugin-appimage/
git checkout --recurse-submodules 779bd58443e8cc
git submodule update --init --recursive
mkdir -p build
cd build
cmake -DBUILD_TESTING=OFF ..
cmake --build . -j $(nproc)
mv /linuxdeploy-plugin-appimage/build/src/linuxdeploy-plugin-appimage $BUILD_TOOLS/linuxdeploy/linuxdeploy-plugin-appimage
cd /
$BUILD_TOOLS/linuxdeploy/linuxdeploy --list-plugins
##########################################################################
# Compile and install AppImageKit
##########################################################################
git clone https://github.com/AppImage/AppImageKit
cd /AppImageKit/
git checkout --recurse-submodules 13
git submodule update --init --recursive
mkdir -p build
cd build
cmake -DBUILD_TESTING=OFF ..
cmake --build . -j $(nproc)
cmake --build . --target install
mkdir -p $BUILD_TOOLS/appimagetool
cd /
appimagetool --version
##########################################################################
# Compile and install appimageupdatetool
##########################################################################
git clone https://github.com/AppImageCommunity/AppImageUpdate.git
cd AppImageUpdate
git checkout --recurse-submodules 2.0.0-alpha-1-20220512
git submodule update --init --recursive
mkdir -p build
cd build
if [ "$PACKARCH" == "armv7l" ]; then
cp ../ci/libgcrypt.pc /usr/lib/arm-linux-gnueabihf/pkgconfig/libgcrypt.pc
sed -i 's|x86_64-linux-gnu|arm-linux-gnueabihf|g' /usr/lib/arm-linux-gnueabihf/pkgconfig/libgcrypt.pc
sed -i 's|x86_64-pc-linux-gnu|arm-pc-linux-gnueabihf|g' /usr/lib/arm-linux-gnueabihf/pkgconfig/libgcrypt.pc
echo 'prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${prefix}/lib/arm-linux-gnueabihf
host=arm-unknown-linux-gnueabihf
mtcflags=
mtlibs=
Name: gpg-error
Description: GPG Runtime
Version: 1.27
Cflags:
Libs: -L${libdir} -lgpg-error
Libs.private:
URL: https://www.gnupg.org/software/libgpg-error/index.html' > /usr/lib/arm-linux-gnueabihf/pkgconfig/gpg-error.pc
else
cp ../ci/libgcrypt.pc /usr/lib/aarch64-linux-gnu/pkgconfig/libgcrypt.pc
sed -i 's|x86_64|aarch64|g' /usr/lib/aarch64-linux-gnu/pkgconfig/libgcrypt.pc
echo 'prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${prefix}/lib/aarch64-linux-gnu
host=aarch64-unknown-linux-gnu
mtcflags=
mtlibs=
Name: gpg-error
Description: GPG Runtime
Version: 1.27
Cflags:
Libs: -L${libdir} -lgpg-error
Libs.private:
URL: https://www.gnupg.org/software/libgpg-error/index.html' > /usr/lib/aarch64-linux-gnu/pkgconfig/gpg-error.pc
fi
cmake -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_SYSTEM_NAME=Linux ..
make -j"$(nproc)"
# create the extracted appimage directory
mkdir -p $BUILD_TOOLS/appimageupdatetool
make install DESTDIR=$BUILD_TOOLS/appimageupdatetool/appimageupdatetool-${PACKARCH}.AppDir
mkdir -p $BUILD_TOOLS/appimageupdatetool/appimageupdatetool-${PACKARCH}.AppDir/resources
cp -v ../resources/*.xpm $BUILD_TOOLS/appimageupdatetool/appimageupdatetool-${PACKARCH}.AppDir/resources/
$BUILD_TOOLS/linuxdeploy/linuxdeploy -v0 --appdir $BUILD_TOOLS/appimageupdatetool/appimageupdatetool-${PACKARCH}.AppDir --output appimage -d ../resources/appimageupdatetool.desktop -i ../resources/appimage.png
cd $BUILD_TOOLS/appimageupdatetool
ln -s "appimageupdatetool-${PACKARCH}.AppDir/AppRun" appimageupdatetool # symlink for convenience
rm -rf /usr/lib/arm-linux-gnueabihf/pkgconfig/libgcrypt.pc /usr/lib/aarch64-linux-gnu/pkgconfig/libgcrypt.pc
cd /
$BUILD_TOOLS/appimageupdatetool/appimageupdatetool --version
cd ${CURRDIR}
# delete build folders
rm -rf /linuxdeploy*
rm -rf /AppImageKit
rm -rf /AppImageUpdate
# Dump syms
if [ "$PACKARCH" == "armv7l" ]; then
echo "Get Breakpad"
breakpad_dir=$BUILD_TOOLS/breakpad
if [[ ! -d "$breakpad_dir" ]]; then
curl -o $BUILD_TOOLS/dump_syms.7z "https://s3.amazonaws.com/utils.musescore.org/breakpad/linux/armv7l/dump_syms.zip"
7z x -y $BUILD_TOOLS/dump_syms.7z -o"$breakpad_dir"
fi
echo export DUMPSYMS_BIN="$breakpad_dir/dump_syms" >> $ENV_FILE
else
echo "Get Breakpad"
breakpad_dir=$BUILD_TOOLS/breakpad
if [[ ! -d "$breakpad_dir" ]]; then
curl -o $BUILD_TOOLS/dump_syms.7z "https://s3.amazonaws.com/utils.musescore.org/breakpad/linux/aarch64/dump_syms.zip"
7z x -y $BUILD_TOOLS/dump_syms.7z -o"$breakpad_dir"
fi
echo export DUMPSYMS_BIN="$breakpad_dir/dump_syms" >> $ENV_FILE
fi
echo export PATH="${qt_dir}/bin:\${PATH}" >> ${ENV_FILE}
echo export LD_LIBRARY_PATH="${qt_dir}/lib:\${LD_LIBRARY_PATH}" >> ${ENV_FILE}
echo export QT_PATH="${qt_dir}" >> ${ENV_FILE}
echo export QT_PLUGIN_PATH="${qt_dir}/plugins" >> ${ENV_FILE}
echo export QML2_IMPORT_PATH="${qt_dir}/qml" >> ${ENV_FILE}
echo export CFLAGS="-Wno-psabi" >> ${ENV_FILE}
echo export CXXFLAGS="-Wno-psabi" >> ${ENV_FILE}
##########################################################################
# POST INSTALL
##########################################################################
chmod +x "$ENV_FILE"
# # tidy up (reduce size of Docker image)
# apt-get clean autoclean
# apt-get autoremove --purge -y
# rm -rf /tmp/* /var/{cache,log,backups}/* /var/lib/apt/*
df -h .
echo "Setup script done"