Use wine paths by default even if non-existent
[carla.git] / data / linux / build-all.sh
blob702830e695424c3cf7699cf94104cbab0efec65c
1 #!/bin/bash
3 VERSION="2.3.0-alpha1"
5 # ---------------------------------------------------------------------------------------------------------------------
6 # check dependencies
8 if ! which debootstrap > /dev/null; then
9 echo "debootstrap not found, please install it"
10 exit 1
13 # ---------------------------------------------------------------------------------------------------------------------
14 # startup as main script
16 if [ -z "${SOURCED_BY_DOCKER}" ]; then
17 # stop on error
18 set -e
20 # cd to correct path
21 cd $(dirname $0)
24 # ---------------------------------------------------------------------------------------------------------------------
25 # set variables
27 source common.env
29 # where we build stuff inside the chroot
30 CHROOT_CARLA_DIR="/tmp/carla-src"
32 # used for downloading packages from kxstudio repos, in order to get lv2-gtk3 and windows bridges
33 CARLA_GIT_VER="2.2~rc1+git20200718"
34 PKGS_NUM="20200718"
36 # ---------------------------------------------------------------------------------------------------------------------
37 # function to remove old stuff
39 cleanup()
42 if [ -d ${TARGETDIR}/chroot32 ]; then
43 sudo umount -lf ${TARGETDIR}/chroot32/dev/pts || true
44 sudo umount -lf ${TARGETDIR}/chroot32/sys || true
45 sudo umount -lf ${TARGETDIR}/chroot32/proc || true
48 if [ -d ${TARGETDIR}/chroot64 ]; then
49 sudo umount -lf ${TARGETDIR}/chroot64/dev/pts || true
50 sudo umount -lf ${TARGETDIR}/chroot64/sys || true
51 sudo umount -lf ${TARGETDIR}/chroot64/proc || true
54 if [ -d ${TARGETDIR}/chroot32 ]; then
55 sudo mv ${TARGETDIR}/chroot32 ${TARGETDIR}/chroot32-deleteme2
56 sudo rm -rf ${TARGETDIR}/chroot32-deleteme || true
59 if [ -d ${TARGETDIR}/chroot64 ]; then
60 sudo mv ${TARGETDIR}/chroot64 ${TARGETDIR}/chroot64-deleteme2
61 sudo rm -rf ${TARGETDIR}/chroot64-deleteme || true
66 # ---------------------------------------------------------------------------------------------------------------------
67 # create chroots
69 prepare()
72 if [ ! -d ${TARGETDIR}/chroot32 ]; then
73 sudo debootstrap --no-check-gpg --arch=i386 lucid ${TARGETDIR}/chroot32 http://old-releases.ubuntu.com/ubuntu/
76 if [ ! -d ${TARGETDIR}/chroot64 ]; then
77 sudo debootstrap --no-check-gpg --arch=amd64 lucid ${TARGETDIR}/chroot64 http://old-releases.ubuntu.com/ubuntu/
82 # ---------------------------------------------------------------------------------------------------------------------
83 # setup chroots
85 chroot_setup()
88 CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
90 if [ ! -f ${CHROOT_DIR}/tmp/setup-aria2 ]; then
91 pushd ${CHROOT_DIR}/tmp
92 if [ x"${ARCH}" = x"32" ]; then
93 wget -c https://github.com/q3aql/aria2-static-builds/releases/download/v1.34.0/aria2-1.34.0-linux-gnu-32bit-build1.tar.bz2
94 else
95 wget -c https://github.com/q3aql/aria2-static-builds/releases/download/v1.34.0/aria2-1.34.0-linux-gnu-64bit-build1.tar.bz2
97 tar xf aria2-*.tar.bz2
98 popd
101 cat <<EOF | sudo chroot ${CHROOT_DIR}
102 mount -t proc none /proc/
103 mount -t sysfs none /sys/
104 mount -t devpts none /dev/pts
105 export HOME=/root
106 export LANG=C
107 export LC_ALL=C
108 unset LC_TIME
110 set -e
112 if [ ! -f /tmp/setup-repo ]; then
113 apt-get update
114 apt-get install -y python-software-properties wget
115 add-apt-repository ppa:kxstudio-debian/libs
116 add-apt-repository ppa:kxstudio-debian/toolchain
117 apt-get update
118 touch /tmp/setup-repo
121 if [ ! -f /tmp/setup-repo-list ]; then
122 echo '
123 deb http://old-releases.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
124 deb http://old-releases.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse
125 deb http://old-releases.ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse
126 ' > /etc/apt/sources.list
127 apt-get update
128 touch /tmp/setup-repo-list
131 if [ ! -f /tmp/setup-repo-upgrade ]; then
132 dpkg-divert --local --rename --add /sbin/initctl
133 ln -s /bin/true /sbin/initctl
134 apt-get dist-upgrade
135 touch /tmp/setup-repo-upgrade
138 if [ ! -f /tmp/setup-repo-packages ]; then
139 apt-get install -y build-essential autoconf libtool cmake libglib2.0-dev libgl1-mesa-dev git-core
140 apt-get clean
141 touch /tmp/setup-repo-packages
144 if [ ! -f /tmp/setup-aria2 ]; then
145 pushd /tmp/aria2-*
146 make install
147 popd
148 rm -r /tmp/aria2-*
149 touch /tmp/setup-aria2
152 if [ ! -d ${CHROOT_CARLA_DIR} ]; then
153 git clone --depth=1 -b develop git://github.com/falkTX/Carla ${CHROOT_CARLA_DIR}
156 if [ ! -f ${CHROOT_CARLA_DIR}/source/native-plugins/external/README.md ]; then
157 git clone git://github.com/falkTX/Carla-Plugins ${CHROOT_CARLA_DIR}/source/native-plugins/external
160 cd ${CHROOT_CARLA_DIR}
161 git checkout .
162 git pull
163 git submodule init
164 git submodule update
166 # might be updated by git pull
167 chmod 777 data/linux/*.sh
168 chmod 777 data/linux/common.env
170 sync
176 # ---------------------------------------------------------------------------------------------------------------------
177 # build base libs
179 chroot_build_deps()
182 CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
183 cp build-deps.sh build-pyqt.sh common.env ${CHROOT_DIR}${CHROOT_CARLA_DIR}/data/linux/
184 sudo cp /etc/ca-certificates.conf ${CHROOT_DIR}/etc/
185 sudo cp -r /usr/share/ca-certificates/* ${CHROOT_DIR}/usr/share/ca-certificates/
187 cat <<EOF | sudo chroot ${CHROOT_DIR}
188 export HOME=/root
189 export LANG=C
190 export LC_ALL=C
191 unset LC_TIME
193 set -e
195 if [ ! -f /tmp/setup-repo-packages-extra1 ]; then
196 if [ x"${ARCH}" != x"32" ]; then
197 apt-get install -y g++-4.8-multilib ia32-libs
198 apt-get clean
200 touch /tmp/setup-repo-packages-extra1
203 update-ca-certificates
205 ${CHROOT_CARLA_DIR}/data/linux/build-deps.sh ${ARCH}
207 if [ ! -f /tmp/setup-repo-packages-extra2 ]; then
208 apt-get install -y --no-install-recommends libdbus-1-dev libx11-dev libffi-static
209 apt-get clean
210 touch /tmp/setup-repo-packages-extra2
213 ${CHROOT_CARLA_DIR}/data/linux/build-pyqt.sh ${ARCH}
215 if [ ! -f /tmp/setup-repo-packages-extra4 ]; then
216 apt-get install -y --no-install-recommends libasound2-dev libpulse-dev libgtk2.0-dev libqt4-dev qt4-dev-tools zip unzip
217 apt-get install -y --no-install-recommends libfreetype6-dev libxcursor-dev libxext-dev
218 apt-get clean
219 touch /tmp/setup-repo-packages-extra4
226 # ---------------------------------------------------------------------------------------------------------------------
227 # build carla
229 chroot_build_carla()
232 CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
233 CHROOT_TARGET_DIR=/root/builds
235 cat <<EOF | sudo chroot ${CHROOT_DIR}
236 export HOME=/root
237 export LANG=C
238 export LC_ALL=C
239 unset LC_TIME
241 set -e
243 export OLDPATH=\${PATH}
244 export CFLAGS="-I${CHROOT_TARGET_DIR}/carla${ARCH}/include"
245 export CXXFLAGS="${CFLAGS}"
246 export LDFLAGS="-L${CHROOT_TARGET_DIR}/carla${ARCH}/lib"
247 export PKG_CONFIG_PATH=${CHROOT_TARGET_DIR}/carla${ARCH}/lib/pkgconfig
248 export LINUX=true
249 export MOC_QT4=/usr/bin/moc-qt4
250 export RCC_QT4=/usr/bin/rcc
251 export PYRCC5=${CHROOT_TARGET_DIR}/carla${ARCH}/bin/pyrcc5
252 export PYUIC5=${CHROOT_TARGET_DIR}/carla${ARCH}/bin/pyuic5
254 cd ${CHROOT_CARLA_DIR}
256 make ${MAKE_ARGS}
258 if [ x"${ARCH}" != x"32" ]; then
259 export CFLAGS="-I${CHROOT_TARGET_DIR}/carla32/include -m32"
260 export CXXFLAGS=${CFLAGS}
261 export LDFLAGS="-L${CHROOT_TARGET_DIR}/carla32/lib -m32"
262 export PKG_CONFIG_PATH=${CHROOT_TARGET_DIR}/carla32/lib/pkgconfig
263 make posix32 ${MAKE_ARGS}
270 # ---------------------------------------------------------------------------------------------------------------------
271 # download carla extras
273 download_carla_extras()
276 CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
278 cat <<EOF | sudo chroot ${CHROOT_DIR}
279 set -e
281 cd ${CHROOT_CARLA_DIR}
283 if [ ! -d carla-pkgs${PKGS_NUM} ]; then
284 mkdir -p tmp-carla-pkgs
285 cd tmp-carla-pkgs
286 wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-bridge-win32_${CARLA_GIT_VER}_i386.deb
287 if [ x"${ARCH}" != x"32" ]; then
288 wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-bridge-win64_${CARLA_GIT_VER}_amd64.deb
289 wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-git_${CARLA_GIT_VER}_amd64.deb
290 else
291 wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-git_${CARLA_GIT_VER}_i386.deb
293 cd ..
294 mv tmp-carla-pkgs carla-pkgs${PKGS_NUM}
297 if [ ! -f carla-pkgs${PKGS_NUM}/extracted ]; then
298 cd carla-pkgs${PKGS_NUM}
299 ar x carla-bridge-win32_${CARLA_GIT_VER}_i386.deb
300 tar xf data.tar.xz
301 rm control.tar.xz data.tar.xz debian-binary
302 if [ x"${ARCH}" != x"32" ]; then
303 ar x carla-bridge-win64_${CARLA_GIT_VER}_amd64.deb
304 tar xf data.tar.xz
305 rm control.tar.xz data.tar.xz debian-binary
306 ar x carla-git_${CARLA_GIT_VER}_amd64.deb
307 tar xf data.tar.xz
308 rm control.tar.xz data.tar.xz debian-binary
309 else
310 ar x carla-git_${CARLA_GIT_VER}_i386.deb
311 tar xf data.tar.xz
312 rm control.tar.xz data.tar.xz debian-binary
314 touch extracted
315 cd ..
318 if [ ! -f extra-bins${PKGS_NUM}/carla-bridge-win32.exe ]; then
319 mkdir -p extra-bins${PKGS_NUM}
320 cp carla-pkgs${PKGS_NUM}/usr/lib/carla/*.exe extra-bins${PKGS_NUM}/
321 cp carla-pkgs${PKGS_NUM}/usr/lib/carla/*.dll extra-bins${PKGS_NUM}/
322 cp carla-pkgs${PKGS_NUM}/usr/lib/carla/*-gtk3 extra-bins${PKGS_NUM}/
329 # ---------------------------------------------------------------------------------------------------------------------
330 # download carla extras
332 chroot_pack_carla()
335 CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
336 CHROOT_TARGET_DIR=/root/builds
338 cat <<EOF | sudo chroot ${CHROOT_DIR}
339 export HOME=/root
340 export LANG=C
341 export LC_ALL=C
342 unset LC_TIME
344 set -e
346 export PKG_CONFIG_PATH=${CHROOT_TARGET_DIR}/carla${ARCH}/lib/pkgconfig
347 export PATH=${CHROOT_TARGET_DIR}/carla${ARCH}/bin:\${PATH}
348 export LINUX=true
349 export MOC_QT4=/usr/bin/moc-qt4
350 export RCC_QT4=/usr/bin/rcc
351 export PYRCC5=${CHROOT_TARGET_DIR}/carla${ARCH}/bin/pyrcc5
352 export PYUIC5=${CHROOT_TARGET_DIR}/carla${ARCH}/bin/pyuic5
354 cd ${CHROOT_CARLA_DIR}
356 rm -rf ./tmp-install
357 make ${MAKE_ARGS} install DESTDIR=./tmp-install PREFIX=/usr
359 make -C data/windows/unzipfx-carla -f Makefile.linux clean
360 make -C data/windows/unzipfx-carla-control -f Makefile.linux clean
362 make -C data/windows/unzipfx-carla -f Makefile.linux ${MAKE_ARGS}
363 make -C data/windows/unzipfx-carla-control -f Makefile.linux ${MAKE_ARGS}
365 # ---------------------------------------------------------------------------------------------------------------------
366 # Standalone
368 rm -rf build-carla build-carla-control build-lv2 build-vst carla carla-control *.zip
370 mkdir build-carla
371 mkdir build-carla/resources
372 mkdir build-carla/src
373 mkdir build-carla/src/modgui
374 mkdir build-carla/src/patchcanvas
375 mkdir build-carla/src/widgets
377 cp extra-bins${PKGS_NUM}/* build-carla/
378 cp -r ./tmp-install/usr/lib/carla/* build-carla/
379 cp -LR ./tmp-install/usr/share/carla/resources/* build-carla/resources/
380 cp ./tmp-install/usr/share/carla/carla build-carla/src/
381 cp ./tmp-install/usr/share/carla/carla-control build-carla/src/
382 cp ./tmp-install/usr/share/carla/*.py build-carla/src/
383 cp ./tmp-install/usr/share/carla/modgui/*.py build-carla/src/modgui/
384 cp ./tmp-install/usr/share/carla/patchcanvas/*.py build-carla/src/patchcanvas/
385 cp ./tmp-install/usr/share/carla/widgets/*.py build-carla/src/widgets/
387 export PYTHONPATH="./build-carla/src"
389 # standalone
390 python3 ./data/linux/app-carla.py build_exe
391 mv build-carla/lib/library.zip build-carla/lib/library-carla.zip
393 # plugins
394 TARGET_NAME="bigmeter-ui" python3 ./data/linux/app-plugin.py build_exe
395 mv build-carla/lib/library.zip build-carla/lib/library-bigmeter.zip
397 TARGET_NAME="midipattern-ui" python3 ./data/linux/app-plugin.py build_exe
398 mv build-carla/lib/library.zip build-carla/lib/library-midipattern.zip
400 TARGET_NAME="notes-ui" python3 ./data/linux/app-plugin.py build_exe
401 mv build-carla/lib/library.zip build-carla/lib/library-notes.zip
403 TARGET_NAME="xycontroller-ui" python3 ./data/linux/app-plugin.py build_exe
404 mv build-carla/lib/library.zip build-carla/lib/library-xycontroller.zip
406 TARGET_NAME="carla-plugin" python3 ./data/linux/app-plugin.py build_exe
407 mv build-carla/lib/library.zip build-carla/lib/library-carla-p1.zip
409 TARGET_NAME="carla-plugin-patchbay" python3 ./data/linux/app-plugin.py build_exe
410 mv build-carla/lib/library.zip build-carla/lib/library-carla-p2.zip
412 # carla-control, no merge needed
413 python3 ./data/linux/app-carla-control.py build_exe
415 # merge library stuff into one
416 mkdir build-carla/lib/_lib
417 pushd build-carla/lib/_lib
418 unzip -o ../library-bigmeter.zip
419 unzip -o ../library-midipattern.zip
420 unzip -o ../library-notes.zip
421 unzip -o ../library-xycontroller.zip
422 unzip -o ../library-carla-p1.zip
423 unzip -o ../library-carla-p2.zip
424 unzip -o ../library-carla.zip
425 zip -r -9 ../library.zip *
426 popd
427 rm -r build-carla/lib/_lib build-carla/lib/library-*.zip
429 # move resource binaries into right dir
430 mv build-carla/{bigmeter-ui,midipattern-ui,notes-ui,xycontroller-ui,carla-plugin} build-carla/resources/
431 rm build-carla/carla-plugin-patchbay
433 # symlink for carla-plugin-patchbay, lib and styles
434 pushd build-carla/resources
435 rm carla-plugin-patchbay
436 ln -s carla-plugin carla-plugin-patchbay
437 ln -s ../lib .
438 ln -s ../styles .
439 popd
441 # magic for filetype detection in carla
442 cp ${CHROOT_TARGET_DIR}/carla${ARCH}/share/misc/magic.mgc build-carla/
444 # binaries for carla-control
445 cp build-carla/libcarla_utils.so build-carla-control/
446 cp -r build-carla/styles build-carla-control/
448 # delete unneeded stuff
449 find build-* -name "*.py" -delete
450 find build-* -name "*.pyi" -delete
451 find build-* -name "libQt*" -delete
452 rm -f build-*/lib/PyQt5/{pylupdate,pyrcc}.so
453 rm -f build-*/lib/PyQt5/{QtDBus,QtNetwork,QtPrintSupport,QtSql,QtTest,QtXml}.so
454 rm -f build-carla/carla-bridge-lv2-modgui
455 rm -f build-carla/libcarla_native-plugin.so
456 rm -rf build-carla/src
457 rm -rf build-*/lib/PyQt5/uic
458 rmdir build-carla/resources/{modgui,patchcanvas,widgets}
460 mkdir build-lv2
461 cp -LR ./tmp-install/usr/lib/lv2/carla.lv2 build-lv2/
462 rm -r build-lv2/carla.lv2/resources
463 cp -LR build-carla/resources build-lv2/carla.lv2/
464 cp build-carla/magic.mgc build-lv2/carla.lv2/
465 cp extra-bins${PKGS_NUM}/* build-lv2/carla.lv2/
466 rm build-lv2/carla.lv2/resources/carla-plugin-patchbay
467 rm -r build-lv2/carla.lv2/resources/styles
468 ln -s ../libcarla_utils.so build-lv2/carla.lv2/resources/
469 ln -s ../styles build-lv2/carla.lv2/resources/
470 ln -s carla-plugin build-lv2/carla.lv2/resources/carla-plugin-patchbay
472 mkdir build-vst
473 cp -LR ./tmp-install/usr/lib/vst/carla.vst build-vst/
474 rm -r build-vst/carla.vst/resources
475 cp -LR build-carla/resources build-vst/carla.vst/
476 cp build-carla/magic.mgc build-vst/carla.vst/
477 cp extra-bins${PKGS_NUM}/* build-vst/carla.vst/
478 rm build-vst/carla.vst/resources/carla-plugin-patchbay
479 rm -r build-vst/carla.vst/resources/styles
480 ln -s ../libcarla_utils.so build-vst/carla.vst/resources/
481 ln -s ../styles build-vst/carla.vst/resources/
482 ln -s carla-plugin build-vst/carla.vst/resources/carla-plugin-patchbay
484 rm build-{lv2,vst}/carla.*/carla-bridge-lv2-modgui
485 rm build-{lv2,vst}/carla.*/libcarla_native-plugin.so
487 mv build-carla carla-${VERSION}
488 zip --symlinks -r -9 carla.zip carla-${VERSION}
489 cat data/windows/unzipfx-carla/unzipfx2cat carla.zip > Carla
490 chmod +x Carla
491 rm -rf carla carla-${VERSION} carla.zip
493 mv build-carla-control carla-control-${VERSION}
494 zip --symlinks -r -9 carla-control.zip carla-control-${VERSION}
495 cat data/windows/unzipfx-carla-control/unzipfx2cat carla-control.zip > CarlaControl
496 chmod +x CarlaControl
497 rm -rf carla-control carla-control-${VERSION} carla-control.zip
499 rm -rf ${PKG_FOLDER}${ARCH}
500 mkdir ${PKG_FOLDER}${ARCH}
501 cp data/linux/README ${PKG_FOLDER}${ARCH}/
502 mv Carla CarlaControl build-lv2/*.lv2 build-vst/*.vst ${PKG_FOLDER}${ARCH}/
503 rmdir build-lv2 build-vst
504 tar cJf ${PKG_FOLDER}${ARCH}.tar.xz ${PKG_FOLDER}${ARCH}
505 mv ${PKG_FOLDER}${ARCH}.tar.xz /tmp/
511 # ---------------------------------------------------------------------------------------------------------------------
512 # run the functions
514 if [ -z "${SOURCED_BY_DOCKER}" ]; then
515 # name of final dir and xz file, needed only by chroot_pack_carla
516 export PKG_FOLDER="Carla_${VERSION}-linux"
518 # cleanup
519 prepare
521 # 32bit build
522 export ARCH=32
523 chroot_setup
524 chroot_build_deps
525 chroot_build_carla
526 download_carla_extras
527 chroot_pack_carla
529 # 64bit build
530 export ARCH=64
531 chroot_setup
532 chroot_build_deps
533 chroot_build_carla
534 download_carla_extras
535 chroot_pack_carla
538 # ---------------------------------------------------------------------------------------------------------------------