annotate deploy/linux/deploy-appimage.sh @ 733:7942b7633505

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