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.

536 lines
16KB

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