annotate deploy/linux/deploy-appimage.sh @ 1910:310670d04abe

Add docker file for appimage build
author Chris Cannam
date Fri, 29 Jun 2018 10:53:35 +0100
parents 12b96d6b1d66
children 61ef30fb141c
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@1909 81 qtlibdirs="/usr/lib/x86_64-linux-gnu/qt5 /usr/lib/x86_64-linux-gnu/qt /usr/lib/qt5 /usr/lib/qt"
Chris@1909 82
Chris@1909 83 QTDIR=${QTDIR:-}
Chris@1909 84 if [ -n "$QTDIR" ]; then
Chris@1909 85 qtlibdirs="$QTDIR $qtlibdirs"
Chris@1909 86 fi
Chris@1905 87
Chris@1905 88 for plug in $qtplugins; do
Chris@1905 89 for libdir in $qtlibdirs; do
Chris@1905 90 lib=$(find $libdir/plugins -name libq$plug.so -print 2>/dev/null || true)
Chris@1905 91 if [ -n "$lib" ]; then
Chris@1905 92 if [ -f "$lib" ]; then
Chris@1905 93 mkdir -p "$targetdir/$(dirname $lib)"
Chris@1905 94 cp -v "$lib" "$targetdir/$lib"
Chris@1905 95 chmod +x "$targetdir/$lib"
Chris@1905 96 add_dependencies "$lib"
Chris@1905 97 break
Chris@1905 98 fi
Chris@1905 99 fi
Chris@1905 100 done
Chris@1905 101 done
Chris@1905 102
Chris@1883 103 cp "$program.desktop" "$targetdir/"
Chris@1883 104
Chris@1883 105 cp "icons/sv-icon.svg" "$targetdir/"
Chris@1883 106
Chris@1883 107 cp sv-dependency-builds/linux/appimage/AppRun-x86_64 "$targetdir/AppRun"
Chris@1883 108 chmod +x "$targetdir/AppRun"
Chris@1883 109
Chris@1909 110 # Do this with a separate extraction step, so as to make it work even
Chris@1909 111 # in situations where FUSE is unavailable like in a Docker container
Chris@1909 112 export ARCH=x86_64
Chris@1909 113 sv-dependency-builds/linux/appimage/appimagetool-x86_64.AppImage --appimage-extract
Chris@1909 114 ./squashfs-root/AppRun "$targetdir" "SonicVisualiser-$version-x86_64.AppImage"
Chris@1883 115