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.

539 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 clean
  277. make -C data/windows/unzipfx-carla-control -f Makefile.linux clean
  278. make -C data/windows/unzipfx-carla -f Makefile.linux ${MAKE_ARGS}
  279. make -C data/windows/unzipfx-carla-control -f Makefile.linux ${MAKE_ARGS}
  280. # ---------------------------------------------------------------------------------------------------------------------
  281. # Standalone
  282. rm -rf build-carla build-carla-control build-lv2 build-vst carla carla-control *.zip
  283. mkdir build-carla
  284. mkdir build-carla/resources
  285. mkdir build-carla/src
  286. mkdir build-carla/src/modgui
  287. mkdir build-carla/src/patchcanvas
  288. mkdir build-carla/src/widgets
  289. cp extra-bins${PKGS_NUM}/* build-carla/
  290. cp -r ./tmp-install/usr/lib/carla/* build-carla/
  291. cp -LR ./tmp-install/usr/share/carla/resources/* build-carla/resources/
  292. cp ./tmp-install/usr/share/carla/carla build-carla/src/
  293. cp ./tmp-install/usr/share/carla/carla-control build-carla/src/
  294. cp ./tmp-install/usr/share/carla/*.py build-carla/src/
  295. cp ./tmp-install/usr/share/carla/modgui/*.py build-carla/src/modgui/
  296. cp ./tmp-install/usr/share/carla/patchcanvas/*.py build-carla/src/patchcanvas/
  297. cp ./tmp-install/usr/share/carla/widgets/*.py build-carla/src/widgets/
  298. export PYTHONPATH="./build-carla/src"
  299. # standalone
  300. python3 ./data/linux/app-carla.py build_exe
  301. mv build-carla/lib/library.zip build-carla/lib/library-carla.zip
  302. # plugins
  303. TARGET_NAME="bigmeter-ui" python3 ./data/linux/app-plugin.py build_exe
  304. mv build-carla/lib/library.zip build-carla/lib/library-bigmeter.zip
  305. TARGET_NAME="midipattern-ui" python3 ./data/linux/app-plugin.py build_exe
  306. mv build-carla/lib/library.zip build-carla/lib/library-midipattern.zip
  307. TARGET_NAME="notes-ui" python3 ./data/linux/app-plugin.py build_exe
  308. mv build-carla/lib/library.zip build-carla/lib/library-notes.zip
  309. TARGET_NAME="xycontroller-ui" python3 ./data/linux/app-plugin.py build_exe
  310. mv build-carla/lib/library.zip build-carla/lib/library-xycontroller.zip
  311. TARGET_NAME="carla-plugin" python3 ./data/linux/app-plugin.py build_exe
  312. mv build-carla/lib/library.zip build-carla/lib/library-carla-p1.zip
  313. TARGET_NAME="carla-plugin-patchbay" python3 ./data/linux/app-plugin.py build_exe
  314. mv build-carla/lib/library.zip build-carla/lib/library-carla-p2.zip
  315. # carla-control, no merge needed
  316. python3 ./data/linux/app-carla-control.py build_exe
  317. # merge library stuff into one
  318. mkdir build-carla/lib/_lib
  319. pushd build-carla/lib/_lib
  320. unzip -o ../library-bigmeter.zip
  321. unzip -o ../library-midipattern.zip
  322. unzip -o ../library-notes.zip
  323. unzip -o ../library-xycontroller.zip
  324. unzip -o ../library-carla-p1.zip
  325. unzip -o ../library-carla-p2.zip
  326. unzip -o ../library-carla.zip
  327. zip -r -9 ../library.zip *
  328. popd
  329. rm -r build-carla/lib/_lib build-carla/lib/library-*.zip
  330. # move resource binaries into right dir
  331. mv build-carla/{bigmeter-ui,midipattern-ui,notes-ui,xycontroller-ui,carla-plugin} build-carla/resources/
  332. rm build-carla/carla-plugin-patchbay
  333. # symlink for carla-plugin-patchbay, lib and styles
  334. pushd build-carla/resources
  335. rm carla-plugin-patchbay
  336. ln -s carla-plugin carla-plugin-patchbay
  337. ln -s ../lib .
  338. ln -s ../styles .
  339. popd
  340. # magic for filetype detection in carla
  341. cp ${CHROOT_TARGET_DIR}/carla${ARCH}/share/misc/magic.mgc build-carla/
  342. # binaries for carla-control
  343. cp build-carla/libcarla_utils.so build-carla-control/
  344. cp -r build-carla/styles build-carla-control/
  345. # delete unneeded stuff
  346. find build-* -name "*.py" -delete
  347. find build-* -name "*.pyi" -delete
  348. find build-* -name "libQt*" -delete
  349. rm -f build-*/lib/PyQt5/{pylupdate,pyrcc}.so
  350. rm -f build-*/lib/PyQt5/{QtDBus,QtNetwork,QtPrintSupport,QtSql,QtTest,QtXml}.so
  351. rm -f build-carla/carla-bridge-lv2-modgui
  352. rm -f build-carla/libcarla_native-plugin.so
  353. rm -rf build-carla/src
  354. rm -rf build-*/lib/PyQt5/uic
  355. rmdir build-carla/resources/{modgui,patchcanvas,widgets}
  356. mkdir build-lv2
  357. cp -LR ./tmp-install/usr/lib/lv2/carla.lv2 build-lv2/
  358. rm -r build-lv2/carla.lv2/resources
  359. cp -LR build-carla/resources build-lv2/carla.lv2/
  360. cp build-carla/magic.mgc build-lv2/carla.lv2/
  361. cp extra-bins${PKGS_NUM}/* build-lv2/carla.lv2/
  362. rm build-lv2/carla.lv2/resources/carla-plugin-patchbay
  363. rm -r build-lv2/carla.lv2/resources/styles
  364. ln -s ../libcarla_utils.so build-lv2/carla.lv2/resources/
  365. ln -s ../styles build-lv2/carla.lv2/resources/
  366. ln -s carla-plugin build-lv2/carla.lv2/resources/carla-plugin-patchbay
  367. mkdir build-vst
  368. cp -LR ./tmp-install/usr/lib/vst/carla.vst build-vst/
  369. rm -r build-vst/carla.vst/resources
  370. cp -LR build-carla/resources build-vst/carla.vst/
  371. cp build-carla/magic.mgc build-vst/carla.vst/
  372. cp extra-bins${PKGS_NUM}/* build-vst/carla.vst/
  373. rm build-vst/carla.vst/resources/carla-plugin-patchbay
  374. rm -r build-vst/carla.vst/resources/styles
  375. ln -s ../libcarla_utils.so build-vst/carla.vst/resources/
  376. ln -s ../styles build-vst/carla.vst/resources/
  377. ln -s carla-plugin build-vst/carla.vst/resources/carla-plugin-patchbay
  378. rm build-{lv2,vst}/carla.*/carla-bridge-lv2-modgui
  379. rm build-{lv2,vst}/carla.*/libcarla_native-plugin.so
  380. mv build-carla carla-${VERSION}
  381. zip --symlinks -r -9 carla.zip carla-${VERSION}
  382. cat data/windows/unzipfx-carla/unzipfx2cat carla.zip > Carla
  383. chmod +x Carla
  384. rm -rf carla carla-${VERSION} carla.zip
  385. mv build-carla-control carla-control-${VERSION}
  386. zip --symlinks -r -9 carla-control.zip carla-control-${VERSION}
  387. cat data/windows/unzipfx-carla-control/unzipfx2cat carla-control.zip > CarlaControl
  388. chmod +x CarlaControl
  389. rm -rf carla-control carla-control-${VERSION} carla-control.zip
  390. rm -rf ${PKG_FOLDER}${ARCH}
  391. mkdir ${PKG_FOLDER}${ARCH}
  392. cp data/linux/README ${PKG_FOLDER}${ARCH}/
  393. mv Carla CarlaControl build-lv2/*.lv2 build-vst/*.vst ${PKG_FOLDER}${ARCH}/
  394. rmdir build-lv2 build-vst
  395. tar cJf ${PKG_FOLDER}${ARCH}.tar.xz ${PKG_FOLDER}${ARCH}
  396. mv ${PKG_FOLDER}${ARCH}.tar.xz /tmp/
  397. EOF
  398. }
  399. # ---------------------------------------------------------------------------------------------------------------------
  400. # run the functions
  401. if [ -z "${SOURCED_BY_DOCKER}" ]; then
  402. # name of final dir and xz file, needed only by chroot_pack_carla
  403. export PKG_FOLDER="Carla_${VERSION}-linux"
  404. # cleanup
  405. prepare
  406. # 32bit build
  407. export ARCH=32
  408. chroot_setup
  409. chroot_build_deps
  410. chroot_build_carla
  411. download_carla_extras
  412. chroot_pack_carla
  413. # 64bit build
  414. export ARCH=64
  415. chroot_setup
  416. chroot_build_deps
  417. chroot_build_carla
  418. download_carla_extras
  419. chroot_pack_carla
  420. fi
  421. # ---------------------------------------------------------------------------------------------------------------------