Chris@1883: #!/bin/bash Chris@1883: Chris@1883: set -eu Chris@1883: Chris@1883: program=sonic-visualiser Chris@1883: checker=vamp-plugin-load-checker Chris@1883: piper=piper-vamp-simple-server Chris@1883: Chris@1903: get_id() { Chris@1903: if [ -d .hg ]; then Chris@1903: hg id | sed 's/[+ ].*$//' Chris@1903: elif [ -d .git ]; then Chris@1903: git rev-parse --short HEAD Chris@1903: else Chris@1903: echo "WARNING: can't figure out revision from VCS metadata" 1>&2 Chris@1903: echo "unknown" Chris@1903: fi Chris@1903: } Chris@1903: Chris@1903: version=$(get_id) Chris@1903: Chris@1883: targetdir="${program}.AppDir" Chris@1883: Chris@1883: echo "Target dir is $targetdir" Chris@1883: Chris@1883: if [ -d "$targetdir" ]; then Chris@1883: echo "Target directory exists, not overwriting" Chris@1883: exit Chris@1883: fi Chris@1883: Chris@1883: mkdir "$targetdir" Chris@1883: Chris@1883: mkdir -p "$targetdir"/usr/bin Chris@1883: mkdir -p "$targetdir"/usr/lib Chris@1883: Chris@1883: cp "$program" "$checker" "$piper" "$targetdir"/usr/bin/ Chris@1883: Chris@1889: ldd /usr/lib/x86_64-linux-gnu/libpulse.so.0 || true Chris@1889: Chris@1888: add_dependencies() { Chris@1898: Chris@1888: local binary="$1" Chris@1898: Chris@1915: echo "ldd $binary yields:" Chris@1915: ldd "$binary" Chris@1915: Chris@1915: for lib in $(ldd "$binary" | grep '=> [^ ]*/lib/' | \ Chris@1903: sed 's/^.*=> //' | sed 's/ .*$//'); do Chris@1898: Chris@1903: base=$(basename "$lib") Chris@1903: if grep -v '^#' sv-dependency-builds/linux/appimage/excludelist | Chris@1903: grep -q "^$base$" ; then Chris@1915: echo "excluding: $lib" Chris@1903: continue Chris@1903: fi Chris@1915: Chris@1915: target="$targetdir/usr/lib/$(basename $lib)" Chris@1903: Chris@1915: mkdir -p "$(dirname $target)" Chris@1898: Chris@1915: if [ ! -f "$target" ]; then Chris@1898: Chris@1915: cp -Lv "$lib" "$target" Chris@1915: chmod +x "$target" Chris@1898: Chris@1888: add_dependencies "$lib" Chris@1898: Chris@1888: fi Chris@1888: done Chris@1888: } Chris@1888: Chris@1888: add_dependencies "$program" Chris@1915: add_dependencies "$checker" Chris@1915: add_dependencies "$piper" Chris@1883: Chris@1905: qtplugins="gif icns ico jpeg tga tiff wbmp webp cocoa minimal offscreen xcb" Chris@1909: qtlibdirs="/usr/lib/x86_64-linux-gnu/qt5 /usr/lib/x86_64-linux-gnu/qt /usr/lib/qt5 /usr/lib/qt" Chris@1909: Chris@1909: QTDIR=${QTDIR:-} Chris@1909: if [ -n "$QTDIR" ]; then Chris@1909: qtlibdirs="$QTDIR $qtlibdirs" Chris@1909: fi Chris@1905: Chris@1905: for plug in $qtplugins; do Chris@1905: for libdir in $qtlibdirs; do Chris@1905: lib=$(find $libdir/plugins -name libq$plug.so -print 2>/dev/null || true) Chris@1905: if [ -n "$lib" ]; then Chris@1905: if [ -f "$lib" ]; then Chris@1920: subdir=$(basename $(dirname $lib)) Chris@1920: if [ t"$subdir" = t"plugins" ]; then Chris@1920: subdir="" Chris@1920: fi Chris@1920: target="$targetdir/usr/lib/qt5/plugins/$subdir/$(basename $lib)" Chris@1915: mkdir -p "$(dirname $target)" Chris@1915: cp -v "$lib" "$target" Chris@1915: chmod +x "$target" Chris@1905: add_dependencies "$lib" Chris@1905: break Chris@1905: fi Chris@1905: fi Chris@1905: done Chris@1905: done Chris@1905: Chris@1883: cp "$program.desktop" "$targetdir/" Chris@1883: Chris@1883: cp "icons/sv-icon.svg" "$targetdir/" Chris@1952: cp "icons/sonic-visualiser.svg" "$targetdir/" Chris@1883: Chris@1883: cp sv-dependency-builds/linux/appimage/AppRun-x86_64 "$targetdir/AppRun" Chris@1883: chmod +x "$targetdir/AppRun" Chris@1883: Chris@1909: # Do this with a separate extraction step, so as to make it work even Chris@1909: # in situations where FUSE is unavailable like in a Docker container Chris@1909: export ARCH=x86_64 Chris@1909: sv-dependency-builds/linux/appimage/appimagetool-x86_64.AppImage --appimage-extract Chris@1909: ./squashfs-root/AppRun "$targetdir" "SonicVisualiser-$version-x86_64.AppImage" Chris@1883: