comparison deploy/linux/deploy-appimage.sh @ 612:40cc49380398

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