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.

477 lines
15KB

  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. # stop on error
  10. set -e
  11. # ---------------------------------------------------------------------------------------------------------------------
  12. # cd to correct path
  13. cd $(dirname $0)
  14. # ---------------------------------------------------------------------------------------------------------------------
  15. # set variables
  16. source common.env
  17. CHROOT_CARLA_DIR="/tmp/carla-src"
  18. PKG_FOLDER="Carla_2.0-RC1-linux"
  19. # ---------------------------------------------------------------------------------------------------------------------
  20. # function to remove old stuff
  21. cleanup()
  22. {
  23. if [ -d ${TARGETDIR}/chroot32 ]; then
  24. sudo umount -lf ${TARGETDIR}/chroot32/dev/pts || true
  25. sudo umount -lf ${TARGETDIR}/chroot32/sys || true
  26. sudo umount -lf ${TARGETDIR}/chroot32/proc || true
  27. fi
  28. if [ -d ${TARGETDIR}/chroot64 ]; then
  29. sudo umount -lf ${TARGETDIR}/chroot64/dev/pts || true
  30. sudo umount -lf ${TARGETDIR}/chroot64/sys || true
  31. sudo umount -lf ${TARGETDIR}/chroot64/proc || true
  32. fi
  33. if [ -d ${TARGETDIR}/chroot32 ]; then
  34. sudo mv ${TARGETDIR}/chroot32 ${TARGETDIR}/chroot32-deleteme
  35. sudo rm -rf ${TARGETDIR}/chroot32-deleteme || true
  36. fi
  37. if [ -d ${TARGETDIR}/chroot64 ]; then
  38. sudo mv ${TARGETDIR}/chroot64 ${TARGETDIR}/chroot64-deleteme
  39. sudo rm -rf ${TARGETDIR}/chroot64-deleteme || true
  40. fi
  41. }
  42. # ---------------------------------------------------------------------------------------------------------------------
  43. # create chroots
  44. if [ ! -d ${TARGETDIR}/chroot32 ]; then
  45. sudo debootstrap --arch=i386 lucid ${TARGETDIR}/chroot32 http://old-releases.ubuntu.com/ubuntu/
  46. fi
  47. if [ ! -d ${TARGETDIR}/chroot64 ]; then
  48. sudo debootstrap --arch=amd64 lucid ${TARGETDIR}/chroot64 http://old-releases.ubuntu.com/ubuntu/
  49. fi
  50. # ---------------------------------------------------------------------------------------------------------------------
  51. # setup chroots
  52. chroot_setup()
  53. {
  54. CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
  55. if [ ! -f ${CHROOT_DIR}/tmp/setup-aria2 ]; then
  56. pushd ${CHROOT_DIR}/tmp
  57. if [ x"${ARCH}" = x"32" ]; then
  58. wget -c https://github.com/q3aql/aria2-static-builds/releases/download/v1.34.0/aria2-1.34.0-linux-gnu-32bit-build1.tar.bz2
  59. else
  60. wget -c https://github.com/q3aql/aria2-static-builds/releases/download/v1.34.0/aria2-1.34.0-linux-gnu-64bit-build1.tar.bz2
  61. fi
  62. tar xf aria2-*.tar.bz2
  63. popd
  64. fi
  65. cat <<EOF | sudo chroot ${CHROOT_DIR}
  66. mount -t proc none /proc/
  67. mount -t sysfs none /sys/
  68. mount -t devpts none /dev/pts
  69. export HOME=/root
  70. export LANG=C
  71. export LC_ALL=C
  72. unset LC_TIME
  73. set -e
  74. if [ ! -f /tmp/setup-repo ]; then
  75. apt-get update
  76. apt-get install -y python-software-properties wget
  77. add-apt-repository ppa:kxstudio-debian/libs
  78. add-apt-repository ppa:kxstudio-debian/toolchain
  79. apt-get update
  80. touch /tmp/setup-repo
  81. fi
  82. if [ ! -f /tmp/setup-repo-list ]; then
  83. echo '
  84. deb http://old-releases.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
  85. deb http://old-releases.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse
  86. deb http://old-releases.ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse
  87. ' > /etc/apt/sources.list
  88. apt-get update
  89. touch /tmp/setup-repo-list
  90. fi
  91. if [ ! -f /tmp/setup-repo-upgrade ]; then
  92. dpkg-divert --local --rename --add /sbin/initctl
  93. ln -s /bin/true /sbin/initctl
  94. apt-get dist-upgrade
  95. touch /tmp/setup-repo-upgrade
  96. fi
  97. if [ ! -f /tmp/setup-repo-packages ]; then
  98. apt-get install -y build-essential autoconf libtool cmake libglib2.0-dev libgl1-mesa-dev git-core
  99. apt-get clean
  100. touch /tmp/setup-repo-packages
  101. fi
  102. if [ ! -f /tmp/setup-aria2 ]; then
  103. pushd /tmp/aria2-*
  104. make install
  105. popd
  106. rm -r /tmp/aria2-*
  107. touch /tmp/setup-aria2
  108. fi
  109. if [ ! -d ${CHROOT_CARLA_DIR} ]; then
  110. git clone --depth=1 git://github.com/falkTX/Carla ${CHROOT_CARLA_DIR}
  111. fi
  112. if [ ! -f ${CHROOT_CARLA_DIR}/source/native-plugins/external/README.md ]; then
  113. git clone --depth=1 git://github.com/falkTX/Carla-Plugins ${CHROOT_CARLA_DIR}/source/native-plugins/external
  114. fi
  115. cd ${CHROOT_CARLA_DIR}
  116. git checkout .
  117. git pull
  118. git submodule update
  119. # might be updated by git pull
  120. chmod 777 data/linux/*.sh
  121. chmod 777 data/linux/common.env
  122. sync
  123. EOF
  124. }
  125. export ARCH=32
  126. chroot_setup
  127. export ARCH=64
  128. chroot_setup
  129. # ---------------------------------------------------------------------------------------------------------------------
  130. # build base libs
  131. chroot_build_deps()
  132. {
  133. CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
  134. cp build-deps.sh common.env ${CHROOT_DIR}${CHROOT_CARLA_DIR}/data/linux/
  135. sudo cp /etc/ca-certificates.conf ${CHROOT_DIR}/etc/
  136. sudo cp -r /usr/share/ca-certificates/* ${CHROOT_DIR}/usr/share/ca-certificates/
  137. cat <<EOF | sudo chroot ${CHROOT_DIR}
  138. export HOME=/root
  139. export LANG=C
  140. export LC_ALL=C
  141. unset LC_TIME
  142. set -e
  143. if [ ! -f /tmp/setup-repo-packages-extra1 ]; then
  144. if [ x"${ARCH}" != x"32" ]; then
  145. apt-get install -y g++-4.8-multilib ia32-libs
  146. apt-get clean
  147. fi
  148. touch /tmp/setup-repo-packages-extra1
  149. fi
  150. update-ca-certificates
  151. ${CHROOT_CARLA_DIR}/data/linux/build-deps.sh ${ARCH}
  152. if [ ! -f /tmp/setup-repo-packages-extra2 ]; then
  153. apt-get install -y --no-install-recommends libasound2-dev libgtk2.0-dev libqt4-dev libx11-dev
  154. apt-get install -y --no-install-recommends pyqt4-dev-tools python3-pyqt4.qtopengl python3-liblo python3-sip
  155. apt-get install -y cx-freeze-python3 zip
  156. apt-get clean
  157. touch /tmp/setup-repo-packages-extra2
  158. fi
  159. EOF
  160. }
  161. export ARCH=32
  162. chroot_build_deps
  163. export ARCH=64
  164. chroot_build_deps
  165. # ---------------------------------------------------------------------------------------------------------------------
  166. # build carla
  167. chroot_build_carla()
  168. {
  169. CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
  170. CHROOT_TARGET_DIR=/root/builds
  171. cat <<EOF | sudo chroot ${CHROOT_DIR}
  172. export HOME=/root
  173. export LANG=C
  174. export LC_ALL=C
  175. unset LC_TIME
  176. set -e
  177. export CFLAGS="-I${CHROOT_TARGET_DIR}/carla${ARCH}/include"
  178. export CXXFLAGS=${CFLAGS}
  179. export LDFLAGS="-L${CHROOT_TARGET_DIR}/carla${ARCH}/lib"
  180. export PKG_CONFIG_PATH=${CHROOT_TARGET_DIR}/carla${ARCH}/lib/pkgconfig
  181. export RCC_QT4=/usr/bin/rcc
  182. export LINUX=true
  183. export DEFAULT_QT=4
  184. cd ${CHROOT_CARLA_DIR}
  185. make ${MAKE_ARGS}
  186. if [ x"${ARCH}" != x"32" ]; then
  187. export CFLAGS="-I${CHROOT_TARGET_DIR}/carla32/include -m32"
  188. export CXXFLAGS=${CFLAGS}
  189. export LDFLAGS="-L${CHROOT_TARGET_DIR}/carla32/lib -m32"
  190. export PKG_CONFIG_PATH=${CHROOT_TARGET_DIR}/carla32/lib/pkgconfig
  191. make posix32 ${MAKE_ARGS}
  192. fi
  193. EOF
  194. }
  195. export ARCH=32
  196. chroot_build_carla
  197. export ARCH=64
  198. chroot_build_carla
  199. # ---------------------------------------------------------------------------------------------------------------------
  200. # download carla extras
  201. download_carla_extras()
  202. {
  203. CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
  204. CARLA_VER="1.9.11+git20180916"
  205. WINBR_VER="1.9.11+git20180916"
  206. WINE32_VER="1.9.11+git20180916"
  207. WINE64_VER="1.9.11.git20180916"
  208. cat <<EOF | sudo chroot ${CHROOT_DIR}
  209. set -e
  210. cd ${CHROOT_CARLA_DIR}
  211. if [ ! -d carla-pkgs${PKGS_NUM} ]; then
  212. mkdir -p tmp-carla-pkgs
  213. cd tmp-carla-pkgs
  214. wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-bridge-win32_${WINBR_VER}_i386.deb
  215. wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-bridge-wine32_${WINE32_VER}_i386.deb
  216. if [ x"${ARCH}" != x"32" ]; then
  217. aria2c https://github.com/KXStudio/Repository/releases/download/initial/carla-bridge-wine64_${WINE64_VER}_amd64.deb
  218. wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-bridge-win64_${WINBR_VER}_amd64.deb
  219. wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-git_${CARLA_VER}_amd64.deb
  220. else
  221. wget -c https://launchpad.net/~kxstudio-debian/+archive/ubuntu/apps/+files/carla-git_${CARLA_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}/extrated ]; then
  227. cd carla-pkgs${PKGS_NUM}
  228. dpkg -x carla-bridge-win32_${WINBR_VER}_i386.deb .
  229. dpkg -x carla-bridge-wine32_${WINE32_VER}_i386.deb .
  230. if [ x"${ARCH}" != x"32" ]; then
  231. dpkg -x carla-bridge-win64_${WINBR_VER}_amd64.deb .
  232. dpkg -x carla-bridge-wine64_${WINE64_VER}_amd64.deb .
  233. dpkg -x carla-git_${CARLA_VER}_amd64.deb .
  234. else
  235. dpkg -x carla-git_${CARLA_VER}_i386.deb .
  236. fi
  237. touch extrated
  238. cd ..
  239. fi
  240. if [ ! -f extra-bins/carla-bridge-win32.exe ]; then
  241. mkdir -p extra-bins
  242. cp carla-pkgs${PKGS_NUM}/usr/lib/carla/*.exe extra-bins/
  243. cp carla-pkgs${PKGS_NUM}/usr/lib/carla/*.dll extra-bins/
  244. cp carla-pkgs${PKGS_NUM}/usr/lib/carla/*-gtk3 extra-bins/
  245. cp carla-pkgs${PKGS_NUM}/usr/lib/carla/*-qt5 extra-bins/
  246. fi
  247. EOF
  248. }
  249. export ARCH=32
  250. download_carla_extras
  251. export ARCH=64
  252. download_carla_extras
  253. # ---------------------------------------------------------------------------------------------------------------------
  254. # download carla extras
  255. chroot_pack_carla()
  256. {
  257. CHROOT_DIR=${TARGETDIR}/chroot${ARCH}
  258. CXFREEZE_FLAGS="--include-modules=re,sip,subprocess,inspect"
  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 RCC_QT4=/usr/bin/rcc
  267. export LINUX="true"
  268. cd ${CHROOT_CARLA_DIR}
  269. rm -rf ./tmp-install
  270. make ${MAKE_ARGS} install DESTDIR=./tmp-install PREFIX=/usr
  271. make -C data/windows/unzipfx-carla -f Makefile.linux ${MAKE_ARGS}
  272. make -C data/windows/unzipfx-carla-control -f Makefile.linux ${MAKE_ARGS}
  273. # ---------------------------------------------------------------------------------------------------------------------
  274. # Standalone
  275. rm -rf build-carla build-carla-control build-lv2 build-vst carla *.zip
  276. mkdir build-carla
  277. mkdir build-carla/resources
  278. mkdir build-carla/src
  279. mkdir build-carla/src/widgets
  280. cp extra-bins/* build-carla/
  281. cp -r ./tmp-install/usr/lib/carla/* build-carla/
  282. cp -LR ./tmp-install/usr/share/carla/resources/* build-carla/resources/
  283. cp ./tmp-install/usr/share/carla/carla build-carla/src/
  284. cp ./tmp-install/usr/share/carla/carla-control build-carla/src/
  285. cp ./tmp-install/usr/share/carla/*.py build-carla/src/
  286. cp ./tmp-install/usr/share/carla/widgets/*.py build-carla/src/widgets/
  287. mv build-carla/resources/carla-plugin build-carla/resources/carla-plugin.py
  288. mv build-carla/resources/bigmeter-ui build-carla/resources/bigmeter-ui.py
  289. mv build-carla/resources/midipattern-ui build-carla/resources/midipattern-ui.py
  290. mv build-carla/resources/notes-ui build-carla/resources/notes-ui.py
  291. cxfreeze-python3 ${CXFREEZE_FLAGS} build-carla/src/carla --target-dir=build-carla/
  292. cxfreeze-python3 ${CXFREEZE_FLAGS} build-carla/src/carla-control --target-dir=build-carla-control/
  293. cxfreeze-python3 ${CXFREEZE_FLAGS} build-carla/resources/carla-plugin.py --target-dir=build-carla/resources/
  294. cxfreeze-python3 ${CXFREEZE_FLAGS} build-carla/resources/bigmeter-ui.py --target-dir=build-carla/resources/
  295. cxfreeze-python3 ${CXFREEZE_FLAGS} build-carla/resources/midipattern-ui.py --target-dir=build-carla/resources/
  296. cxfreeze-python3 ${CXFREEZE_FLAGS} build-carla/resources/notes-ui.py --target-dir=build-carla/resources/
  297. cp /usr/lib/libpython3.2mu.so.1.0 build-carla/
  298. cp /usr/lib/libffi.so.5 build-carla/
  299. cp /usr/lib/libssl.so.0.9.8 build-carla/
  300. cp /usr/lib/libcrypto.so.0.9.8 build-carla/
  301. cp /lib/libbz2.so.1.0 build-carla/
  302. cp /lib/libselinux.so.1 build-carla/
  303. cp /root/builds/carla${ARCH}/share/misc/magic.mgc build-carla/
  304. cp /usr/lib/libpython3.2mu.so.1.0 build-carla-control/
  305. cp /usr/lib/libffi.so.5 build-carla-control/
  306. cp /usr/lib/libssl.so.0.9.8 build-carla-control/
  307. cp /usr/lib/libcrypto.so.0.9.8 build-carla-control/
  308. cp /lib/libbz2.so.1.0 build-carla-control/
  309. cp /lib/libselinux.so.1 build-carla-control/
  310. cp build-carla/libcarla_utils.so build-carla-control/
  311. cp -r build-carla/styles build-carla-control/
  312. find build-carla -name "*.py" -delete
  313. find build-carla -name PyQt4.QtAssistant.so -delete
  314. find build-carla -name PyQt4.QtNetwork.so -delete
  315. find build-carla -name PyQt4.QtScript.so -delete
  316. find build-carla -name PyQt4.QtTest.so -delete
  317. find build-carla -name PyQt4.QtXml.so -delete
  318. rm -rf build-carla/src
  319. find build-carla-control -name "*.py" -delete
  320. find build-carla-control -name PyQt4.QtAssistant.so -delete
  321. find build-carla-control -name PyQt4.QtNetwork.so -delete
  322. find build-carla-control -name PyQt4.QtScript.so -delete
  323. find build-carla-control -name PyQt4.QtTest.so -delete
  324. find build-carla-control -name PyQt4.QtXml.so -delete
  325. rm -rf build-carla-control/src
  326. cd build-carla/resources/ && \
  327. rm *.so* carla-plugin-patchbay && \
  328. ln -s ../*.so* . && \
  329. ln -s carla-plugin carla-plugin-patchbay && \
  330. cd ../..
  331. mkdir build-lv2
  332. cp -LR ./tmp-install/usr/lib/lv2/carla.lv2 build-lv2/
  333. rm -r build-lv2/carla.lv2/resources
  334. cp -LR build-carla/resources build-lv2/carla.lv2/
  335. cp build-carla/magic.mgc build-lv2/carla.lv2/
  336. cp extra-bins/* build-lv2/carla.lv2/
  337. rm build-lv2/carla.lv2/resources/*carla*.so build-lv2/carla.lv2/resources/carla-plugin-patchbay
  338. ln -s ../libcarla_utils.so build-lv2/carla.lv2/resources/
  339. ln -s carla-plugin build-lv2/carla.lv2/resources/carla-plugin-patchbay
  340. mkdir build-vst
  341. cp -LR ./tmp-install/usr/lib/vst/carla.vst build-vst/
  342. rm -r build-vst/carla.vst/resources
  343. cp -LR build-carla/resources build-vst/carla.vst/
  344. cp build-carla/magic.mgc build-vst/carla.vst/
  345. cp extra-bins/* build-vst/carla.vst/
  346. rm build-vst/carla.vst/resources/*carla*.so build-vst/carla.vst/resources/carla-plugin-patchbay
  347. ln -s ../libcarla_utils.so build-vst/carla.vst/resources/
  348. ln -s carla-plugin build-vst/carla.vst/resources/carla-plugin-patchbay
  349. mv build-carla carla
  350. zip --symlinks -r -9 carla.zip carla
  351. cat data/windows/unzipfx-carla/unzipfx2cat carla.zip > Carla
  352. chmod +x Carla
  353. rm -rf carla carla.zip
  354. mv build-carla-control carla-control
  355. zip --symlinks -r -9 carla-control.zip carla-control
  356. cat data/windows/unzipfx-carla-control/unzipfx2cat carla-control.zip > CarlaControl
  357. chmod +x CarlaControl
  358. rm -rf carla-control carla-control.zip
  359. rm -rf ${PKG_FOLDER}${ARCH}
  360. mkdir ${PKG_FOLDER}${ARCH}
  361. cp data/linux/README ${PKG_FOLDER}${ARCH}/
  362. mv Carla CarlaControl build-lv2/*.lv2 build-vst/*.vst ${PKG_FOLDER}${ARCH}/
  363. tar cJf ${PKG_FOLDER}${ARCH}.tar.xz ${PKG_FOLDER}${ARCH}
  364. mv ${PKG_FOLDER}${ARCH}.tar.xz /tmp/
  365. rmdir build-lv2 build-vst
  366. EOF
  367. }
  368. export ARCH=32
  369. chroot_pack_carla
  370. export ARCH=64
  371. chroot_pack_carla
  372. # ---------------------------------------------------------------------------------------------------------------------