annotate deploy/linux/deploy-appimage.sh @ 1906:2fcfc87aa65a appimage

Might as well publish
author Chris Cannam
date Thu, 28 Jun 2018 20:39:01 +0100
parents 9bd1dea5f412
children abddb04d2bf3
rev   line source
Chris@1883 1 #!/bin/bash
Chris@1883 2
Chris@1883 3 set -eu
Chris@1883 4
Chris@1883 5 program=sonic-visualiser
Chris@1883 6 checker=vamp-plugin-load-checker
Chris@1883 7 piper=piper-vamp-simple-server
Chris@1883 8
Chris@1903 9 get_id() {
Chris@1903 10 if [ -d .hg ]; then
Chris@1903 11 hg id | sed 's/[+ ].*$//'
Chris@1903 12 elif [ -d .git ]; then
Chris@1903 13 git rev-parse --short HEAD
Chris@1903 14 else
Chris@1903 15 echo "WARNING: can't figure out revision from VCS metadata" 1>&2
Chris@1903 16 echo "unknown"
Chris@1903 17 fi
Chris@1903 18 }
Chris@1903 19
Chris@1903 20 version=$(get_id)
Chris@1903 21
Chris@1883 22 targetdir="${program}.AppDir"
Chris@1883 23
Chris@1883 24 echo "Target dir is $targetdir"
Chris@1883 25
Chris@1883 26 if [ -d "$targetdir" ]; then
Chris@1883 27 echo "Target directory exists, not overwriting"
Chris@1883 28 exit
Chris@1883 29 fi
Chris@1883 30
Chris@1883 31 mkdir "$targetdir"
Chris@1883 32
Chris@1883 33 mkdir -p "$targetdir"/usr/bin
Chris@1883 34 mkdir -p "$targetdir"/usr/lib
Chris@1883 35
Chris@1883 36 cp "$program" "$checker" "$piper" "$targetdir"/usr/bin/
Chris@1883 37
Chris@1889 38 ldd /usr/lib/x86_64-linux-gnu/libpulse.so.0 || true
Chris@1889 39
Chris@1888 40 add_dependencies() {
Chris@1898 41
Chris@1888 42 local binary="$1"
Chris@1898 43
Chris@1898 44 for lib in $(ldd "$binary" | egrep '=> (/usr)?(/local)?/lib/' | \
Chris@1903 45 sed 's/^.*=> //' | sed 's/ .*$//'); do
Chris@1898 46
Chris@1903 47 base=$(basename "$lib")
Chris@1903 48 if grep -v '^#' sv-dependency-builds/linux/appimage/excludelist |
Chris@1903 49 grep -q "^$base$" ; then
Chris@1905 50 # echo "excluding: $lib"
Chris@1903 51 continue
Chris@1903 52 fi
Chris@1903 53
Chris@1888 54 mkdir -p "$targetdir/$(dirname $lib)"
Chris@1898 55
Chris@1888 56 if [ ! -f "$targetdir/$lib" ]; then
Chris@1898 57
Chris@1888 58 cp -Lv "$lib" "$targetdir/$lib"
Chris@1888 59 chmod +x "$targetdir/$lib"
Chris@1898 60
Chris@1898 61 # copy e.g. /usr/lib/pulseaudio/libpulsecommon-*.so up a
Chris@1898 62 # level to something in the load path
Chris@1898 63 last_element=$(basename $(dirname "$lib"))
Chris@1898 64 case "$last_element" in
Chris@1898 65 lib) ;;
Chris@1898 66 *-gnu) ;;
Chris@1898 67 *) cp -v "$targetdir/$lib" "$targetdir/$(dirname $(dirname $lib))"
Chris@1898 68 esac
Chris@1898 69
Chris@1888 70 add_dependencies "$lib"
Chris@1898 71
Chris@1888 72 fi
Chris@1888 73 done
Chris@1888 74 }
Chris@1888 75
Chris@1888 76 add_dependencies "$program"
Chris@1883 77
Chris@1901 78 cp -v "$targetdir/usr/local/lib/"* "$targetdir/usr/lib/"
Chris@1901 79
Chris@1905 80 qtplugins="gif icns ico jpeg tga tiff wbmp webp cocoa minimal offscreen xcb"
Chris@1905 81 qtlibdirs="/usr/lib/x86_64-linux-gnu/qt5 /usr/lib/x86_64-linux-gnu/qt /usr/lib/qt5 /usr/lib/qt"
Chris@1905 82
Chris@1905 83 for plug in $qtplugins; do
Chris@1905 84 for libdir in $qtlibdirs; do
Chris@1905 85 lib=$(find $libdir/plugins -name libq$plug.so -print 2>/dev/null || true)
Chris@1905 86 if [ -n "$lib" ]; then
Chris@1905 87 if [ -f "$lib" ]; then
Chris@1905 88 mkdir -p "$targetdir/$(dirname $lib)"
Chris@1905 89 cp -v "$lib" "$targetdir/$lib"
Chris@1905 90 chmod +x "$targetdir/$lib"
Chris@1905 91 add_dependencies "$lib"
Chris@1905 92 break
Chris@1905 93 fi
Chris@1905 94 fi
Chris@1905 95 done
Chris@1905 96 done
Chris@1905 97
Chris@1883 98 cp "$program.desktop" "$targetdir/"
Chris@1883 99
Chris@1883 100 cp "icons/sv-icon.svg" "$targetdir/"
Chris@1883 101
Chris@1883 102 cp sv-dependency-builds/linux/appimage/AppRun-x86_64 "$targetdir/AppRun"
Chris@1883 103 chmod +x "$targetdir/AppRun"
Chris@1883 104
Chris@1903 105 ARCH=x86_64 sv-dependency-builds/linux/appimage/appimagetool-x86_64.AppImage "$targetdir" "SonicVisualiser-$version-x86_64.AppImage"
Chris@1883 106