annotate deploy/linux/deploy-appimage.sh @ 2596:04d381f0d89a tip

Default branch is now named default on git as well as hg, in case we ever want to switch to mirroring in the other direction
author Chris Cannam
date Thu, 27 Aug 2020 15:58:56 +0100
parents c0afaca5a029
children
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@1915 44 echo "ldd $binary yields:"
Chris@1915 45 ldd "$binary"
Chris@1915 46
Chris@1915 47 for lib in $(ldd "$binary" | grep '=> [^ ]*/lib/' | \
Chris@1903 48 sed 's/^.*=> //' | sed 's/ .*$//'); do
Chris@1898 49
Chris@1903 50 base=$(basename "$lib")
Chris@1903 51 if grep -v '^#' sv-dependency-builds/linux/appimage/excludelist |
Chris@1903 52 grep -q "^$base$" ; then
Chris@1915 53 echo "excluding: $lib"
Chris@1903 54 continue
Chris@1903 55 fi
Chris@1915 56
Chris@1915 57 target="$targetdir/usr/lib/$(basename $lib)"
Chris@1903 58
Chris@1915 59 mkdir -p "$(dirname $target)"
Chris@1898 60
Chris@1915 61 if [ ! -f "$target" ]; then
Chris@1898 62
Chris@1915 63 cp -Lv "$lib" "$target"
Chris@1915 64 chmod +x "$target"
Chris@1898 65
Chris@1888 66 add_dependencies "$lib"
Chris@1898 67
Chris@1888 68 fi
Chris@1888 69 done
Chris@1888 70 }
Chris@1888 71
Chris@1888 72 add_dependencies "$program"
Chris@1915 73 add_dependencies "$checker"
Chris@1915 74 add_dependencies "$piper"
Chris@1883 75
Chris@1905 76 qtplugins="gif icns ico jpeg tga tiff wbmp webp cocoa minimal offscreen xcb"
Chris@1909 77 qtlibdirs="/usr/lib/x86_64-linux-gnu/qt5 /usr/lib/x86_64-linux-gnu/qt /usr/lib/qt5 /usr/lib/qt"
Chris@1909 78
Chris@1909 79 QTDIR=${QTDIR:-}
Chris@1909 80 if [ -n "$QTDIR" ]; then
Chris@1909 81 qtlibdirs="$QTDIR $qtlibdirs"
Chris@1909 82 fi
Chris@1905 83
Chris@1905 84 for plug in $qtplugins; do
Chris@1905 85 for libdir in $qtlibdirs; do
Chris@1905 86 lib=$(find $libdir/plugins -name libq$plug.so -print 2>/dev/null || true)
Chris@1905 87 if [ -n "$lib" ]; then
Chris@1905 88 if [ -f "$lib" ]; then
Chris@1920 89 subdir=$(basename $(dirname $lib))
Chris@1920 90 if [ t"$subdir" = t"plugins" ]; then
Chris@1920 91 subdir=""
Chris@1920 92 fi
Chris@1920 93 target="$targetdir/usr/lib/qt5/plugins/$subdir/$(basename $lib)"
Chris@1915 94 mkdir -p "$(dirname $target)"
Chris@1915 95 cp -v "$lib" "$target"
Chris@1915 96 chmod +x "$target"
Chris@1905 97 add_dependencies "$lib"
Chris@1905 98 break
Chris@1905 99 fi
Chris@1905 100 fi
Chris@1905 101 done
Chris@1905 102 done
Chris@1905 103
Chris@1883 104 cp "$program.desktop" "$targetdir/"
Chris@1883 105
Chris@1883 106 cp "icons/sv-icon.svg" "$targetdir/"
Chris@1952 107 cp "icons/sonic-visualiser.svg" "$targetdir/"
Chris@1883 108
Chris@2057 109 cp "deploy/linux/AppRun" "$targetdir/"
Chris@2057 110
Chris@1883 111 chmod +x "$targetdir/AppRun"
Chris@1883 112
Chris@1909 113 # Do this with a separate extraction step, so as to make it work even
Chris@1909 114 # in situations where FUSE is unavailable like in a Docker container
Chris@1909 115 export ARCH=x86_64
Chris@1909 116 sv-dependency-builds/linux/appimage/appimagetool-x86_64.AppImage --appimage-extract
Chris@1909 117 ./squashfs-root/AppRun "$targetdir" "SonicVisualiser-$version-x86_64.AppImage"
Chris@1883 118