comparison deploy/linux/deploy-appimage.sh @ 91:ddfd13c43519

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