annotate deploy/linux/deploy-appimage.sh @ 720:adc3c445a07f

Add a note in the changelog about 1.4.0 (not a feature release, just bringing things up-to-date)
author Chris Cannam
date Thu, 13 Dec 2018 10:58:51 +0000
parents 21e4df9865af
children 48e746f45bde
rev   line source
Chris@700 1 #!/bin/bash
Chris@700 2
Chris@700 3 set -eu
Chris@700 4
Chris@700 5 program=EasyMercurial
Chris@700 6
Chris@700 7 get_id() {
Chris@700 8 if [ -d .hg ]; then
Chris@700 9 hg id | sed 's/[+ ].*$//'
Chris@700 10 elif [ -d .git ]; then
Chris@700 11 git rev-parse --short HEAD
Chris@700 12 else
Chris@700 13 echo "WARNING: can't figure out revision from VCS metadata" 1>&2
Chris@700 14 echo "unknown"
Chris@700 15 fi
Chris@700 16 }
Chris@700 17
Chris@700 18 version=$(get_id)
Chris@700 19
Chris@700 20 if [ ! -x ./appimagetool-x86_64.AppImage ]; then
Chris@700 21 echo "Failed to find executable ./appimagetool-x86_64.AppImage, please provide that first"
Chris@700 22 exit 2
Chris@700 23 fi
Chris@700 24
Chris@700 25 targetdir="${program}.AppDir"
Chris@700 26
Chris@700 27 echo "Target dir is $targetdir"
Chris@700 28
Chris@700 29 if [ -d "$targetdir" ]; then
Chris@700 30 echo "Target directory exists, not overwriting"
Chris@700 31 exit 2
Chris@700 32 fi
Chris@700 33
Chris@700 34 mkdir "$targetdir"
Chris@700 35
Chris@700 36 mkdir -p "$targetdir"/usr/bin
Chris@700 37 mkdir -p "$targetdir"/usr/lib
Chris@700 38
Chris@700 39 cp "$program" "$targetdir"/usr/bin/
Chris@700 40
Chris@700 41 add_dependencies() {
Chris@700 42
Chris@700 43 local binary="$1"
Chris@700 44
Chris@700 45 echo "ldd $binary yields:"
Chris@700 46 ldd "$binary"
Chris@700 47
Chris@700 48 for lib in $(ldd "$binary" | grep '=> [^ ]*/lib/' | \
Chris@700 49 sed 's/^.*=> //' | sed 's/ .*$//'); do
Chris@700 50
Chris@700 51 base=$(basename "$lib")
Chris@700 52 if grep -v '^#' deploy/linux/appimage-excludelist |
Chris@700 53 grep -q "^$base$" ; then
Chris@700 54 echo "excluding: $lib"
Chris@700 55 continue
Chris@700 56 fi
Chris@700 57
Chris@700 58 target="$targetdir/usr/lib/$(basename $lib)"
Chris@700 59
Chris@700 60 mkdir -p "$(dirname $target)"
Chris@700 61
Chris@700 62 if [ ! -f "$target" ]; then
Chris@700 63
Chris@700 64 cp -Lv "$lib" "$target"
Chris@700 65 chmod +x "$target"
Chris@700 66
Chris@700 67 add_dependencies "$lib"
Chris@700 68
Chris@700 69 fi
Chris@700 70 done
Chris@700 71 }
Chris@700 72
Chris@700 73 add_dependencies "$program"
Chris@700 74
Chris@700 75 qtplugins="gif icns ico jpeg tga tiff wbmp webp cocoa minimal offscreen xcb"
Chris@700 76 qtlibdirs="/usr/lib/x86_64-linux-gnu/qt5 /usr/lib/x86_64-linux-gnu/qt /usr/lib/qt5 /usr/lib/qt"
Chris@700 77
Chris@700 78 QTDIR=${QTDIR:-}
Chris@700 79 if [ -n "$QTDIR" ]; then
Chris@700 80 qtlibdirs="$QTDIR $qtlibdirs"
Chris@700 81 fi
Chris@700 82
Chris@700 83 for plug in $qtplugins; do
Chris@700 84 for libdir in $qtlibdirs; do
Chris@700 85 lib=$(find $libdir/plugins -name libq$plug.so -print 2>/dev/null || true)
Chris@700 86 if [ -n "$lib" ]; then
Chris@700 87 if [ -f "$lib" ]; then
Chris@700 88 subdir=$(basename $(dirname $lib))
Chris@700 89 if [ t"$subdir" = t"plugins" ]; then
Chris@700 90 subdir=""
Chris@700 91 fi
Chris@700 92 target="$targetdir/usr/lib/qt5/plugins/$subdir/$(basename $lib)"
Chris@700 93 mkdir -p "$(dirname $target)"
Chris@700 94 cp -v "$lib" "$target"
Chris@700 95 chmod +x "$target"
Chris@700 96 add_dependencies "$lib"
Chris@700 97 break
Chris@700 98 fi
Chris@700 99 fi
Chris@700 100 done
Chris@700 101 done
Chris@700 102
Chris@700 103 cp "deploy/linux/$program.desktop" "$targetdir/"
Chris@700 104
Chris@700 105 cp images/icon/scalable/easyhg-icon.svg "$targetdir/"
Chris@700 106 cp images/icon/scalable/easyhg-icon.svg "$targetdir/$program.svg"
Chris@700 107 cp images/icon/128/easyhg-icon.png "$targetdir/"
Chris@700 108
Chris@700 109 cp "deploy/linux/AppRun" "$targetdir/"
Chris@700 110
Chris@700 111 chmod +x "$targetdir/AppRun"
Chris@700 112
Chris@700 113 # Do this with a separate extraction step, so as to make it work even
Chris@700 114 # in situations where FUSE is unavailable like in a Docker container
Chris@700 115 export ARCH=x86_64
Chris@700 116 ./appimagetool-x86_64.AppImage --appimage-extract
Chris@700 117 ./squashfs-root/AppRun "$targetdir" "$program-$version-x86_64.AppImage"