Advertisement
Guest User

zynaddsubfx.Slackbuild

a guest
Mar 16th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 10.62 KB | None | 0 0
  1. #!/bin/sh
  2. # $Id: zynaddsubfx.SlackBuild,v 1.5 2019/03/14 23:24:15 root Exp root $
  3. # Copyright 2019  Eric Hameleers, Eindhoven, NL
  4. # All rights reserved.
  5. #
  6. #   Permission to use, copy, modify, and distribute this software for
  7. #   any purpose with or without fee is hereby granted, provided that
  8. #   the above copyright notice and this permission notice appear in all
  9. #   copies.
  10. #
  11. #   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. #   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. #   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. #   IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. #   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. #   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. #   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. #   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. #   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. #   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. #   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. #   SUCH DAMAGE.
  23. # -----------------------------------------------------------------------------
  24. #
  25. # Slackware SlackBuild script
  26. # ===========================
  27. # By:          Eric Hameleers <alien@slackware.com>
  28. #
  29. #          Modified by Bob Funk to build with zyn-fusion/mruby-zest GUI
  30. #
  31. # For:         zynaddsubfx/zyn-fusion
  32. # Descr:       software synthesizer and lv2 plugin
  33. # URL:         http://zynaddsubfx.sourceforge.net/
  34. # Build needs:
  35. # Needs:       jack2, lash, liblo, mxml, mruby-zest, portaudio
  36. # Changelog:  
  37. # 3.0.3-1:     24/Feb/2019 by Eric Hameleers <alien@slackware.com>
  38. #              * Initial build.
  39. # 3.0.3-2:     14/mar/2019 by Eric Hameleers <alien@slackware.com>
  40. #              * Use ntk instead of fltk, this is needed to give the plugin
  41. #                version a proper GUI.
  42. # 3.0.3-3:     15/mar/2019 by Bob Funk <bobfunk11@gmail.com>
  43. #              * use mruby-zest instead of ntk, which provides the zyn-fusion
  44. #            interface
  45. #
  46. # Run 'sh zynaddsubfx.SlackBuild' to build a Slackware package.
  47. # The package (.t?z) and .txt file as well as build logs are created in /tmp .
  48. # Install the package using 'installpkg' or 'upgradepkg --install-new'.
  49. #
  50. # -----------------------------------------------------------------------------
  51.  
  52. PRGNAM=zynaddsubfx
  53. VERSION=${VERSION:-3.0.3}
  54. BUILD=${BUILD:-3}
  55. NUMJOBS=${NUMJOBS:-" -j$(nproc) "}
  56. TAG=${TAG:-alien}
  57.  
  58. DOCS="AUTHORS.txt COPYING ChangeLog HISTORY.txt README.adoc TODO*"
  59.  
  60. # Where do we look for sources?
  61. SRCDIR=$(cd $(dirname $0); pwd)
  62.  
  63. # Place to build (TMP) package (PKG) and output (OUTPUT) the program:
  64. TMP=${TMP:-/tmp/build}
  65. PKG=$TMP/package-$PRGNAM
  66. OUTPUT=${OUTPUT:-/tmp}
  67.  
  68. SOURCE="$SRCDIR/${PRGNAM}-${VERSION}.tar.bz2"
  69. SRCURL="http://sourceforge.net/projects/${PRGNAM}/files/${PRGNAM}/${VERSION}/${PRGNAM}-${VERSION}.tar.bz2"
  70.  
  71. ##
  72. ## --- with a little luck, you won't have to edit below this point --- ##
  73. ##
  74.  
  75. # Automatically determine the architecture we're building on:
  76. if [ -z "$ARCH" ]; then
  77.   case "$(uname -m)" in
  78.     i?86) ARCH=i586 ;;
  79.     arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;;
  80.     # Unless $ARCH is already set, use uname -m for all other archs:
  81.     *) ARCH=$(uname -m) ;;
  82.   esac
  83.   export ARCH
  84. fi
  85. # Set CFLAGS/CXXFLAGS and LIBDIRSUFFIX:
  86. case "$ARCH" in
  87.   i?86)      SLKCFLAGS="-O2 -march=${ARCH} -mtune=i686"
  88.              SLKLDFLAGS=""; LIBDIRSUFFIX=""
  89.              ;;
  90.   x86_64)    SLKCFLAGS="-O2 -fPIC"
  91.              SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64"
  92.              ;;
  93.   armv7hl)   SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16"
  94.              SLKLDFLAGS=""; LIBDIRSUFFIX=""
  95.              ;;
  96.   *)         SLKCFLAGS=${SLKCFLAGS:-"-O2"}
  97.              SLKLDFLAGS=${SLKLDFLAGS:-""}; LIBDIRSUFFIX=${LIBDIRSUFFIX:-""}
  98.              ;;
  99. esac
  100.  
  101. case "$ARCH" in
  102.     arm*)    TARGET=$ARCH-slackware-linux-gnueabi ;;
  103.     *)       TARGET=$ARCH-slackware-linux ;;
  104. esac
  105.  
  106. # Exit the script on errors:
  107. set -e
  108. trap 'echo "$0 FAILED at line ${LINENO}" | tee $OUTPUT/error-${PRGNAM}.log' ERR
  109. # Catch unitialized variables:
  110. set -u
  111. P1=${1:-1}
  112.  
  113. # Save old umask and set to 0022:
  114. _UMASK_=$(umask)
  115. umask 0022
  116.  
  117. # Create working directories:
  118. mkdir -p $OUTPUT          # place for the package to be saved
  119. mkdir -p $TMP/tmp-$PRGNAM # location to build the source
  120. mkdir -p $PKG             # place for the package to be built
  121. rm -rf $PKG/*             # always erase old package's contents
  122. rm -rf $TMP/tmp-$PRGNAM/* # remove the remnants of previous build
  123. rm -rf $OUTPUT/{checkout,configure,make,install,error,makepkg,patch}-$PRGNAM.log
  124.                           # remove old log files
  125.  
  126. # Source file availability:
  127. if ! [ -f ${SOURCE} ]; then
  128.   echo "Source '$(basename ${SOURCE})' not available yet..."
  129.   # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT
  130.   [ -w "$SRCDIR" ] || SOURCE="$OUTPUT/$(basename $SOURCE)"
  131.   if [ -f ${SOURCE} ]; then echo "Ah, found it!"; continue; fi
  132.   if ! [ "x${SRCURL}" == "x" ]; then
  133.     echo "Will download file to $(dirname $SOURCE)"
  134.     wget --no-check-certificate -nv -T 20 -O "${SOURCE}" "${SRCURL}" || true
  135.     if [ $? -ne 0 -o ! -s "${SOURCE}" ]; then
  136.       echo "Downloading '$(basename ${SOURCE})' failed... aborting the build."
  137.       mv -f "${SOURCE}" "${SOURCE}".FAIL
  138.       exit 1
  139.     fi
  140.   else
  141.     echo "File '$(basename ${SOURCE})' not available... aborting the build."
  142.     exit 1
  143.   fi
  144. fi
  145.  
  146. if [ "$P1" == "--download" ]; then
  147.   echo "Download complete."
  148.   exit 0
  149. fi
  150.  
  151. # --- PACKAGE BUILDING ---
  152.  
  153. echo "++"
  154. echo "|| $PRGNAM-$VERSION (zyn-fusion)"
  155. echo "++"
  156.  
  157. cd $TMP/tmp-$PRGNAM
  158.  
  159. echo "Fetching mruby-zest source code..."
  160. git clone --depth=1 https://github.com/mruby-zest/mruby-zest-build
  161. cd mruby-zest-build
  162. git submodule update --init
  163. chown -R root:root .
  164.  
  165. echo "Building the mruby-zest GUI..."
  166. make setup
  167. make builddep
  168. make
  169. cd ..
  170.  
  171. echo "Extracting the source archive(s) for $PRGNAM..."
  172. tar -xvf ${SOURCE}
  173. cd ${PRGNAM}-${VERSION}
  174. chown -R root:root .
  175. chmod -R u+w,go+r-w,a+rX-st .
  176.  
  177. echo Building ...
  178. mkdir -p build-${PRGNAM}
  179. cd build-${PRGNAM}
  180.   cmake \
  181.     -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
  182.     -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
  183.     -DCMAKE_C_FLAGS_RELEASE:STRING="$SLKCFLAGS" \
  184.     -DCMAKE_CXX_FLAGS_RELEASE:STRING="$SLKCFLAGS" \
  185.     -DCMAKE_BUILD_TYPE=Release \
  186.     -DCMAKE_INSTALL_PREFIX=/usr \
  187.     -DMAN_INSTALL_DIR=/usr/man \
  188.     -DSYSCONF_INSTALL_DIR=/etc \
  189.     -DLIB_SUFFIX=${LIBDIRSUFFIX} \
  190.     -DDefaultOutput=jack \
  191.     -DDefaultInput=jack \
  192.     -DGuiModule=zest \
  193.     -DJackEnable=ON \
  194.     -DPluginLibDir=lib${LIBDIRSUFFIX} \
  195.     ..
  196.   make $NUMJOBS 2>&1 | tee $OUTPUT/make-${PRGNAM}.log
  197.   make DESTDIR=$PKG install 2>&1 | tee $OUTPUT/install-${PRGNAM}.log
  198. cd -
  199.  
  200. make -C doc man xhtml 2>&1 | tee -a $OUTPUT/make-${PRGNAM}.log
  201.  
  202. # Install banks and examples:
  203. mkdir -p ${PKG}/usr/share/${PRGNAM}
  204. cp -a instruments/banks ${PKG}/usr/share/${PRGNAM}
  205. cp -a instruments/examples ${PKG}/usr/share/${PRGNAM}
  206.  
  207. # Install mruby-zest GUI components:
  208. cp $TMP/tmp-$PRGNAM/mruby-zest-build/libzest.so ${PKG}/usr/lib${LIBDIRSUFFIX}/
  209. cp $TMP/tmp-$PRGNAM/mruby-zest-build/zest ${PKG}/usr/bin/zyn-fusion
  210. mkdir ${PKG}/usr/lib${LIBDIRSUFFIX}/{font,schema,qml}
  211. cp -a $TMP/tmp-$PRGNAM/mruby-zest-build/deps/nanovg/example/*.ttf ${PKG}/usr/lib${LIBDIRSUFFIX}/font
  212. cp $TMP/tmp-$PRGNAM/mruby-zest-build/src/osc-bridge/schema/test.json ${PKG}/usr/lib${LIBDIRSUFFIX}/schema
  213. touch ${PKG}/usr/lib${LIBDIRSUFFIX}/qml/MainWindow.qml
  214.  
  215. # Install application icons:
  216. install -Dm 0644 ${PRGNAM}.ico ${PKG}/usr/share/pixmaps/${PRGNAM}.ico
  217. convert ${PRGNAM}.ico ${PKG}/usr/share/pixmaps/${PRGNAM}.png
  218. install -Dm 0644 ${PRGNAM}.svg \
  219.   ${PKG}/usr/share/icons/hicolor/scalable/apps/${PRGNAM}.svg
  220.  
  221. # Install the man page:
  222. install -Dm 0644 doc/${PRGNAM}.1 \
  223.   ${PKG}/usr//man/man1/${PRGNAM}.1
  224.  
  225. # Add this to the doinst.sh:
  226. mkdir -p $PKG/install
  227. cat <<EOINS >> $PKG/install/doinst.sh
  228. # Update the desktop database:
  229. if [ -x usr/bin/update-desktop-database ]; then
  230.   chroot . /usr/bin/update-desktop-database usr/share/applications > /dev/null 2>&1
  231. fi
  232.  
  233. # Update hicolor theme cache:
  234. if [ -d usr/share/icons/hicolor ]; then
  235.   if [ -x /usr/bin/gtk-update-icon-cache ]; then
  236.     chroot . /usr/bin/gtk-update-icon-cache -f -t usr/share/icons/hicolor 1> /dev/null 2> /dev/null
  237.   fi
  238. fi
  239.  
  240. # Update the mime database:
  241. if [ -x usr/bin/update-mime-database ]; then
  242.   chroot . /usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1
  243. fi
  244.  
  245. EOINS
  246.  
  247. # Add documentation for zynaddsubfx and zyn-fusion
  248. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/zyn-fusion
  249. cp $TMP/tmp-$PRGNAM/mruby-zest-build/contributing.adoc $PKG/usr/doc/$PRGNAM-$VERSION/zyn-fusion/
  250. cp $TMP/tmp-$PRGNAM/mruby-zest-build/LICENSE $PKG/usr/doc/$PRGNAM-$VERSION/zyn-fusion/
  251. cp $TMP/tmp-$PRGNAM/mruby-zest-build/package-README.txt $PKG/usr/doc/$PRGNAM-$VERSION/zyn-fusion/
  252. cp $TMP/tmp-$PRGNAM/mruby-zest-build/README.adoc $PKG/usr/doc/$PRGNAM-$VERSION/zyn-fusion/
  253.  
  254. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  255. cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION || true
  256. cp -a doc/${PRGNAM}.html ${PKG}/usr/doc/${PRGNAM}-${VERSION}/ || true
  257. cp -a doc/images ${PKG}/usr/doc/${PRGNAM}-${VERSION}/ || true
  258. cat $SRCDIR/$(basename $0) > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  259. chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION
  260. find $PKG/usr/doc -type f -exec chmod 644 {} \;
  261. # Remove the unwanted bits;
  262. rm -rf $PKG/usr/share/doc
  263.  
  264. # Compress the man page(s):
  265. if [ -d $PKG/usr/man ]; then
  266.   find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \;
  267.   for i in $(find $PKG/usr/man -type l -name "*.?") ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  268. fi
  269.  
  270. # Strip binaries (if any):
  271. find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  272.   | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  273.  
  274. # Add a package description:
  275. mkdir -p $PKG/install
  276. cat $SRCDIR/slack-desc > $PKG/install/slack-desc
  277. cat $SRCDIR/slack-required > $PKG/install/slack-required
  278.  
  279. # Build the package:
  280. cd $PKG
  281. makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz} 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log
  282. cd $OUTPUT
  283. md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz} > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz}.md5
  284. cd -
  285. cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt
  286. cat $PKG/install/slack-required > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.dep
  287.  
  288. # Restore the original umask:
  289. umask ${_UMASK_}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement