Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build-all.sh 16KB

6 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. #!/bin/bash
  2. # ---------------------------------------------------------------------------------------------------------------------
  3. # check dependencies
  4. if ! which debootstrap > /dev/null; then
  5. echo "debootstrap not found, please install it"
  6. exit 1
  7. fi
  8. # ---------------------------------------------------------------------------------------------------------------------
  9. # startup as main script
  10. if [ -z "${SOURCED_BY_DOCKER}" ]; then
  11. # stop on error
  12. set -e
  13. # cd to correct path
  14. cd $(dirname $0)
  15. fi
  16. # ---------------------------------------------------------------------------------------------------------------------
  17. # set variables
  18. source common.env
  19. # where we build stuff inside the chroot
  20. CHROOT_CARLA_DIR="/tmp/carla-src"
  21. # used for downloading packages from kxstudio repos, in order to get lv2-gtk3 and windows bridges
  22. CARLA_GIT_VER="2.1~rc1+git20200331"
  23. PKGS_NUM="20200331"
  24. # ---------------------------------------------------------------------------------------------------------------------
  25. # function to remove old stuff
  26. cleanup()
  27. {
  28. if [ -d ${TARGETDIR}/chroot32 ]; then
  29. sudo umount -lf ${TARGETDIR}/chroot32/dev/pts || true
  30. sudo umount -lf ${TARGETDIR}/chroot32/sys || true
  31. sudo umount -lf ${TARGETDIR}/chroot32/proc || true
  32. fi
  33. if [ -d ${TARGETDIR}/chroot64 ]; then
  34. sudo umount -lf ${TARGETDIR}/chroot64/dev/pts || true
  35. sudo umount -lf ${TARGETDIR}/chroot64/sys || true
  36. sudo umount -lf ${TARGETDIR}/chroot64/proc || true
  37. fi
  38. if [ -d ${TARGETDIR}/chroot32 ]; then
  39. sudo mv ${TARGETDIR}/chroot32 ${TARGETDIR}/chroot32-deleteme2
  40. sudo rm -rf ${TARGETDIR}/chroot32-deleteme || true
  41. fi
  42. if [ -d ${TARGETDIR}/chroot64 ]; then
  43. sudo mv ${TARGETDIR}/chroot64 ${TARGETDIR}/chroot64-deleteme2
  44. sudo rm -rf ${TARGETDIR}/chroot64-deleteme || true
  45. fi
  46. }
  47. # ---------------------------------------------------------------------------------------------------------------------
  48. # create chroots
  49. prepare()
  50. {
  51. if [ ! -d ${TARGETDIR}/chroot32 ]; then
  52. sudo debootstrap --no-check-gpg --arch=i386 lucid ${TARGETDIR}/chroot32 http://old-releases.ubuntu.com/ubuntu/
  53. fi
  54. if [ ! -d ${TARGETDIR}/chroot64 ]; then
  55. sudo debootstrap --no-check-gpg --arch=amd64 lucid ${TARGETDIR}/chroot64 http://old-releases.ubuntu.com/ubuntu/
  56. fi
  57. }
  58. # ---------------------------------------------------------------------------------------------------------------------
  59. # setup chroots
  60. chroot_setup()
  61. {
  62. CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
  63. if [ ! -f ${CHROOT_DIR}/tmp/setup-aria2 ]; then
  64. pushd ${CHROOT_DIR}/tmp
  65. if [ x"${ARCH}" = x"32" ]; then
  66. wget -c https://github.com/q3aql/aria2-static-builds/releases/download/v1.34.0/aria2-1.34.0-linux-gnu-32bit-build1.tar.bz2
  67. else
  68. wget -c https://github.com/q3aql/aria2-static-builds/releases/download/v1.34.0/aria2-1.34.0-linux-gnu-64bit-build1.tar.bz2
  69. fi
  70. tar xf aria2-*.tar.bz2
  71. popd
  72. fi
  73. cat <<EOF | sudo chroot ${CHROOT_DIR}
  74. mount -t proc none /proc/
  75. mount -t sysfs none /sys/
  76. mount -t devpts none /dev/pts
  77. export HOME=/root
  78. export LANG=C
  79. export LC_ALL=C
  80. unset LC_TIME
  81. set -e
  82. if [ ! -f /tmp/setup-repo ]; then
  83. apt-get update
  84. apt-get install -y python-software-properties wget
  85. add-apt-repository ppa:kxstudio-debian/libs
  86. add-apt-repository ppa:kxstudio-debian/toolchain
  87. apt-get update
  88. touch /tmp/setup-repo
  89. fi
  90. if [ ! -f /tmp/setup-repo-list ]; then
  91. echo '
  92. deb http://old-releases.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
  93. deb http://old-releases.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse
  94. deb http://old-releases.ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse
  95. ' > /etc/apt/sources.list
  96. apt-get update
  97. touch /tmp/setup-repo-list
  98. fi
  99. if [ ! -f /tmp/setup-repo-upgrade ]; then
  100. dpkg-divert --local --rename --add /sbin/initctl
  101. ln -s /bin/true /sbin/initctl
  102. apt-get dist-upgrade
  103. touch /tmp/setup-repo-upgrade
  104. fi
  105. if [ ! -f /tmp/setup-repo-packages ]; then
  106. apt-get install -y build-essential autoconf libtool cmake libglib2.0-dev libgl1-mesa-dev git-core
  107. apt-get clean
  108. touch /tmp/setup-repo-packages
  109. fi
  110. if [ ! -f /tmp/setup-aria2 ]; then
  111. pushd /tmp/aria2-*
  112. make install
  113. popd
  114. rm -r /tmp/aria2-*
  115. touch /tmp/setup-aria2
  116. fi
  117. if [ ! -d ${CHROOT_CARLA_DIR} ]; then
  118. git clone --depth=1 -b develop git://github.com/falkTX/Carla ${CHROOT_CARLA_DIR}
  119. fi
  120. if [ ! -f ${CHROOT_CARLA_DIR}/source/native-plugins/external/README.md ]; then
  121. git clone git://github.com/falkTX/Carla-Plugins ${CHROOT_CARLA_DIR}/source/native-plugins/external
  122. fi
  123. cd ${CHROOT_CARLA_DIR}
  124. git checkout .
  125. git pull
  126. git submodule init
  127. git submodule update
  128. # might be updated by git pull
  129. chmod 777 data/linux/*.sh
  130. chmod 777 data/linux/common.env
  131. sync
  132. EOF
  133. }
  134. # ---------------------------------------------------------------------------------------------------------------------
  135. # build base libs
  136. chroot_build_deps()
  137. {
  138. CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
  139. cp build-deps.sh build-pyqt.sh common.env ${CHROOT_DIR}${CHROOT_CARLA_DIR}/data/linux/
  140. sudo cp /etc/ca-certificates.conf ${CHROOT_DIR}/etc/
  141. sudo cp -r /usr/share/ca-certificates/* ${CHROOT_DIR}/usr/share/ca-certificates/
  142. cat <<EOF | sudo chroot ${CHROOT_DIR}
  143. export HOME=/root
  144. export LANG=C
  145. export LC_ALL=C
  146. unset LC_TIME
  147. set -e
  148. if [ ! -f /tmp/setup-repo-packages-extra1 ]; then
  149. if [ x"${ARCH}" != x"32" ]; then
  150. apt-get install -y g++-4.8-multilib ia32-libs
  151. apt-get clean
  152. fi
  153. touch /tmp/setup-repo-packages-extra1
  154. fi
  155. update-ca-certificates
  156. ${CHROOT_CARLA_DIR}/data/linux/build-deps.sh ${ARCH}
  157. if [ ! -f /tmp/setup-repo-packages-extra2 ]; then
  158. apt-get install -y --no-install-recommends libdbus-1-dev libx11-dev libffi-static
  159. apt-get clean
  160. touch /tmp/setup-repo-packages-extra2
  161. fi
  162. ${CHROOT_CARLA_DIR}/data/linux/build-pyqt.sh ${ARCH}
  163. if [ ! -f /tmp/setup-repo-packages-extra3 ]; then
  164. apt-get install -y --no-install-recommends libasound2-dev libpulse-dev libgtk2.0-dev libqt4-dev qt4-dev-tools zip unzip
  165. apt-get clean
  166. touch /tmp/setup-repo-packages-extra3
  167. fi
  168. EOF
  169. }
  170. # ---------------------------------------------------------------------------------------------------------------------
  171. # build carla
  172. chroot_build_carla()
  173. {
  174. CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
  175. CHROOT_TARGET_DIR=/root/builds
  176. cat <<EOF | sudo chroot ${CHROOT_DIR}
  177. export HOME=/root
  178. export LANG=C
  179. export LC_ALL=C
  180. unset LC_TIME
  181. set -e
  182. export OLDPATH=\${PATH}
  183. export CFLAGS="-I${CHROOT_TARGET_DIR}/carla${ARCH}/include"
  184. export CXXFLAGS=${CFLAGS}
  185. export LDFLAGS="-L${CHROOT_TARGET_DIR}/carla${ARCH}/lib"
  186. export PKG_CONFIG_PATH=${CHROOT_TARGET_DIR}/carla${ARCH}/lib/pkgconfig
  187. export LINUX=true
  188. export MOC_QT4=/usr/bin/moc-qt4
  189. export RCC_QT4=/usr/bin/rcc
  190. export PYRCC5=${CHROOT_TARGET_DIR}/carla${ARCH}/bin/pyrcc5
  191. export PYUIC5=${CHROOT_TARGET_DIR}/carla${ARCH}/bin/pyuic5
  192. cd ${CHROOT_CARLA_DIR}
  193. make ${MAKE_ARGS}
  194. if [ x"${ARCH}" != x"32" ]; then
  195. export CFLAGS="-I${CHROOT_TARGET_DIR}/carla32/include -m32"
  196. export CXXFLAGS=${CFLAGS}
  197. export LDFLAGS="-L${CHROOT_TARGET_DIR}/carla32/lib -m32"
  198. export PKG_CONFIG_PATH=${CHROOT_TARGET_DIR}/carla32/lib/pkgconfig
  199. make posix32 ${MAKE_ARGS}
  200. fi
  201. EOF
  202. }
  203. # ---------------------------------------------------------------------------------------------------------------------
  204. # download carla extras
  205. download_carla_extras()
  206. {
  207. CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
  208. CARLA_GIT_VER="2.1~rc1+git20200331"
  209. cat <<EOF | sudo chroot ${CHROOT_DIR}
  210. set -e
  211. cd ${CHROOT_CARLA_DIR}
  212. if [ ! -d carla-pkgs${PKGS_NUM} ]; then
  213. mkdir -p tmp-carla-pkgs
  214. cd tmp-carla-pkgs
  215. wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-bridge-win32_${CARLA_GIT_VER}_i386.deb
  216. if [ x"${ARCH}" != x"32" ]; then
  217. wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-bridge-win64_${CARLA_GIT_VER}_amd64.deb
  218. wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-git_${CARLA_GIT_VER}_amd64.deb
  219. else
  220. wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-git_${CARLA_GIT_VER}_i386.deb
  221. fi
  222. cd ..
  223. mv tmp-carla-pkgs carla-pkgs${PKGS_NUM}
  224. fi
  225. if [ ! -f carla-pkgs${PKGS_NUM}/extracted ]; then
  226. cd carla-pkgs${PKGS_NUM}
  227. ar x carla-bridge-win32_${CARLA_GIT_VER}_i386.deb
  228. tar xf data.tar.xz
  229. rm control.tar.xz data.tar.xz debian-binary
  230. if [ x"${ARCH}" != x"32" ]; then
  231. ar x carla-bridge-win64_${CARLA_GIT_VER}_amd64.deb
  232. tar xf data.tar.xz
  233. rm control.tar.xz data.tar.xz debian-binary
  234. ar x carla-git_${CARLA_GIT_VER}_amd64.deb
  235. tar xf data.tar.xz
  236. rm control.tar.xz data.tar.xz debian-binary
  237. else
  238. ar x carla-git_${CARLA_GIT_VER}_i386.deb
  239. tar xf data.tar.xz
  240. rm control.tar.xz data.tar.xz debian-binary
  241. fi
  242. touch extracted
  243. cd ..
  244. fi
  245. if [ ! -f extra-bins${PKGS_NUM}/carla-bridge-win32.exe ]; then
  246. mkdir -p extra-bins${PKGS_NUM}
  247. cp carla-pkgs${PKGS_NUM}/usr/lib/carla/*.exe extra-bins${PKGS_NUM}/
  248. cp carla-pkgs${PKGS_NUM}/usr/lib/carla/*.dll extra-bins${PKGS_NUM}/
  249. cp carla-pkgs${PKGS_NUM}/usr/lib/carla/*-gtk3 extra-bins${PKGS_NUM}/
  250. fi
  251. EOF
  252. }
  253. # ---------------------------------------------------------------------------------------------------------------------
  254. # download carla extras
  255. chroot_pack_carla()
  256. {
  257. CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
  258. CHROOT_TARGET_DIR=/root/builds
  259. cat <<EOF | sudo chroot ${CHROOT_DIR}
  260. export HOME=/root
  261. export LANG=C
  262. export LC_ALL=C
  263. unset LC_TIME
  264. set -e
  265. export PKG_CONFIG_PATH=${CHROOT_TARGET_DIR}/carla${ARCH}/lib/pkgconfig
  266. export PATH=${CHROOT_TARGET_DIR}/carla${ARCH}/bin:\${PATH}
  267. export LINUX=true
  268. export MOC_QT4=/usr/bin/moc-qt4
  269. export RCC_QT4=/usr/bin/rcc
  270. export PYRCC5=${CHROOT_TARGET_DIR}/carla${ARCH}/bin/pyrcc5
  271. export PYUIC5=${CHROOT_TARGET_DIR}/carla${ARCH}/bin/pyuic5
  272. cd ${CHROOT_CARLA_DIR}
  273. rm -rf ./tmp-install
  274. make ${MAKE_ARGS} install DESTDIR=./tmp-install PREFIX=/usr
  275. make -C data/windows/unzipfx-carla -f Makefile.linux ${MAKE_ARGS}
  276. make -C data/windows/unzipfx-carla-control -f Makefile.linux ${MAKE_ARGS}
  277. # ---------------------------------------------------------------------------------------------------------------------
  278. # Standalone
  279. rm -rf build-carla build-carla-control build-lv2 build-vst carla carla-control *.zip
  280. mkdir build-carla
  281. mkdir build-carla/resources
  282. mkdir build-carla/src
  283. mkdir build-carla/src/modgui
  284. mkdir build-carla/src/patchcanvas
  285. mkdir build-carla/src/widgets
  286. cp extra-bins${PKGS_NUM}/* build-carla/
  287. cp -r ./tmp-install/usr/lib/carla/* build-carla/
  288. cp -LR ./tmp-install/usr/share/carla/resources/* build-carla/resources/
  289. cp ./tmp-install/usr/share/carla/carla build-carla/src/
  290. cp ./tmp-install/usr/share/carla/carla-control build-carla/src/
  291. cp ./tmp-install/usr/share/carla/*.py build-carla/src/
  292. cp ./tmp-install/usr/share/carla/modgui/*.py build-carla/src/modgui/
  293. cp ./tmp-install/usr/share/carla/patchcanvas/*.py build-carla/src/patchcanvas/
  294. cp ./tmp-install/usr/share/carla/widgets/*.py build-carla/src/widgets/
  295. export PYTHONPATH="./build-carla/src"
  296. # standalone
  297. python3 ./data/linux/app-carla.py build_exe
  298. mv build-carla/lib/library.zip build-carla/lib/library-carla.zip
  299. # plugins
  300. TARGET_NAME="bigmeter-ui" python3 ./data/linux/app-plugin.py build_exe
  301. mv build-carla/lib/library.zip build-carla/lib/library-bigmeter.zip
  302. TARGET_NAME="midipattern-ui" python3 ./data/linux/app-plugin.py build_exe
  303. mv build-carla/lib/library.zip build-carla/lib/library-midipattern.zip
  304. TARGET_NAME="notes-ui" python3 ./data/linux/app-plugin.py build_exe
  305. mv build-carla/lib/library.zip build-carla/lib/library-notes.zip
  306. TARGET_NAME="carla-plugin" python3 ./data/linux/app-plugin.py build_exe
  307. mv build-carla/lib/library.zip build-carla/lib/library-carla-p1.zip
  308. TARGET_NAME="carla-plugin-patchbay" python3 ./data/linux/app-plugin.py build_exe
  309. mv build-carla/lib/library.zip build-carla/lib/library-carla-p2.zip
  310. # carla-control, no merge needed
  311. python3 ./data/linux/app-carla-control.py build_exe
  312. # merge library stuff into one
  313. mkdir build-carla/lib/_lib
  314. pushd build-carla/lib/_lib
  315. unzip -o ../library-bigmeter.zip
  316. unzip -o ../library-midipattern.zip
  317. unzip -o ../library-notes.zip
  318. unzip -o ../library-carla-p1.zip
  319. unzip -o ../library-carla-p2.zip
  320. unzip -o ../library-carla.zip
  321. zip -r -9 ../library.zip *
  322. popd
  323. rm -r build-carla/lib/_lib build-carla/lib/library-*.zip
  324. # move resource binaries into right dir
  325. mv build-carla/{bigmeter-ui,midipattern-ui,notes-ui,carla-plugin} build-carla/resources/
  326. rm build-carla/carla-plugin-patchbay
  327. # symlink for carla-plugin-patchbay, lib and styles
  328. pushd build-carla/resources
  329. rm carla-plugin-patchbay
  330. ln -s carla-plugin carla-plugin-patchbay
  331. ln -s ../lib .
  332. ln -s ../styles .
  333. popd
  334. # magic for filetype detection in carla
  335. cp ${CHROOT_TARGET_DIR}/carla${ARCH}/share/misc/magic.mgc build-carla/
  336. # binaries for carla-control
  337. cp build-carla/libcarla_utils.so build-carla-control/
  338. cp -r build-carla/styles build-carla-control/
  339. # delete unneeded stuff
  340. find build-* -name "*.py" -delete
  341. find build-* -name "*.pyi" -delete
  342. find build-* -name "libQt*" -delete
  343. rm -f build-*/lib/PyQt5/{pylupdate,pyrcc}.so
  344. rm -f build-*/lib/PyQt5/{QtDBus,QtNetwork,QtPrintSupport,QtSql,QtTest,QtXml}.so
  345. rm -f build-carla/carla-bridge-lv2-modgui
  346. rm -f build-carla/libcarla_native-plugin.so
  347. rm -rf build-carla/src
  348. rm -rf build-*/lib/PyQt5/uic
  349. rmdir build-carla/resources/{modgui,patchcanvas,widgets}
  350. mkdir build-lv2
  351. cp -LR ./tmp-install/usr/lib/lv2/carla.lv2 build-lv2/
  352. rm -r build-lv2/carla.lv2/resources
  353. cp -LR build-carla/resources build-lv2/carla.lv2/
  354. cp build-carla/magic.mgc build-lv2/carla.lv2/
  355. cp extra-bins${PKGS_NUM}/* build-lv2/carla.lv2/
  356. rm build-lv2/carla.lv2/resources/carla-plugin-patchbay
  357. rm -r build-lv2/carla.lv2/resources/styles
  358. ln -s ../libcarla_utils.so build-lv2/carla.lv2/resources/
  359. ln -s ../styles build-lv2/carla.lv2/resources/
  360. ln -s carla-plugin build-lv2/carla.lv2/resources/carla-plugin-patchbay
  361. mkdir build-vst
  362. cp -LR ./tmp-install/usr/lib/vst/carla.vst build-vst/
  363. rm -r build-vst/carla.vst/resources
  364. cp -LR build-carla/resources build-vst/carla.vst/
  365. cp build-carla/magic.mgc build-vst/carla.vst/
  366. cp extra-bins${PKGS_NUM}/* build-vst/carla.vst/
  367. rm build-vst/carla.vst/resources/carla-plugin-patchbay
  368. rm -r build-vst/carla.vst/resources/styles
  369. ln -s ../libcarla_utils.so build-vst/carla.vst/resources/
  370. ln -s ../styles build-vst/carla.vst/resources/
  371. ln -s carla-plugin build-vst/carla.vst/resources/carla-plugin-patchbay
  372. rm build-{lv2,vst}/carla.*/carla-bridge-lv2-modgui
  373. rm build-{lv2,vst}/carla.*/libcarla_native-plugin.so
  374. mv build-carla carla-2.1
  375. zip --symlinks -r -9 carla.zip carla-2.1
  376. cat data/windows/unzipfx-carla/unzipfx2cat carla.zip > Carla
  377. chmod +x Carla
  378. rm -rf carla carla-2.1 carla.zip
  379. mv build-carla-control carla-control-2.1
  380. zip --symlinks -r -9 carla-control.zip carla-control-2.1
  381. cat data/windows/unzipfx-carla-control/unzipfx2cat carla-control.zip > CarlaControl
  382. chmod +x CarlaControl
  383. rm -rf carla-control carla-control-2.1 carla-control.zip
  384. rm -rf ${PKG_FOLDER}${ARCH}
  385. mkdir ${PKG_FOLDER}${ARCH}
  386. cp data/linux/README ${PKG_FOLDER}${ARCH}/
  387. mv Carla CarlaControl build-lv2/*.lv2 build-vst/*.vst ${PKG_FOLDER}${ARCH}/
  388. rmdir build-lv2 build-vst
  389. tar cJf ${PKG_FOLDER}${ARCH}.tar.xz ${PKG_FOLDER}${ARCH}
  390. mv ${PKG_FOLDER}${ARCH}.tar.xz /tmp/
  391. EOF
  392. }
  393. # ---------------------------------------------------------------------------------------------------------------------
  394. # run the functions
  395. if [ -z "${SOURCED_BY_DOCKER}" ]; then
  396. # name of final dir and xz file, needed only by chroot_pack_carla
  397. export PKG_FOLDER="Carla_2.1-linux"
  398. # cleanup
  399. prepare
  400. # 32bit build
  401. export ARCH=32
  402. chroot_setup
  403. chroot_build_deps
  404. chroot_build_carla
  405. download_carla_extras
  406. chroot_pack_carla
  407. # 64bit build
  408. export ARCH=64
  409. chroot_setup
  410. chroot_build_deps
  411. chroot_build_carla
  412. download_carla_extras
  413. chroot_pack_carla
  414. fi
  415. # ---------------------------------------------------------------------------------------------------------------------