Chris@371
|
1 #!/bin/bash
|
Chris@371
|
2
|
Chris@371
|
3 set -eu
|
Chris@371
|
4
|
Chris@371
|
5 program=sonic-annotator
|
Chris@371
|
6
|
Chris@371
|
7 get_id() {
|
Chris@371
|
8 if [ -d .hg ]; then
|
Chris@371
|
9 hg id | sed 's/[+ ].*$//'
|
Chris@371
|
10 elif [ -d .git ]; then
|
Chris@371
|
11 git rev-parse --short HEAD
|
Chris@371
|
12 else
|
Chris@371
|
13 echo "WARNING: can't figure out revision from VCS metadata" 1>&2
|
Chris@371
|
14 echo "unknown"
|
Chris@371
|
15 fi
|
Chris@371
|
16 }
|
Chris@371
|
17
|
Chris@371
|
18 version=$(get_id)
|
Chris@371
|
19
|
Chris@371
|
20 targetdir="${program}.AppDir"
|
Chris@371
|
21
|
Chris@371
|
22 echo "Target dir is $targetdir"
|
Chris@371
|
23
|
Chris@371
|
24 if [ -d "$targetdir" ]; then
|
Chris@371
|
25 echo "Target directory exists, not overwriting"
|
Chris@371
|
26 exit
|
Chris@371
|
27 fi
|
Chris@371
|
28
|
Chris@371
|
29 mkdir "$targetdir"
|
Chris@371
|
30
|
Chris@371
|
31 mkdir -p "$targetdir"/usr/bin
|
Chris@371
|
32 mkdir -p "$targetdir"/usr/lib
|
Chris@371
|
33
|
Chris@371
|
34 cp "$program" "$targetdir"/usr/bin/
|
Chris@371
|
35
|
Chris@371
|
36 add_dependencies() {
|
Chris@371
|
37
|
Chris@371
|
38 local binary="$1"
|
Chris@371
|
39
|
Chris@371
|
40 echo "ldd $binary yields:"
|
Chris@371
|
41 ldd "$binary"
|
Chris@371
|
42
|
Chris@371
|
43 for lib in $(ldd "$binary" | grep '=> [^ ]*/lib/' | \
|
Chris@371
|
44 sed 's/^.*=> //' | sed 's/ .*$//'); do
|
Chris@371
|
45
|
Chris@371
|
46 base=$(basename "$lib")
|
Chris@371
|
47 if grep -v '^#' sv-dependency-builds/linux/appimage/excludelist |
|
Chris@371
|
48 grep -q "^$base$" ; then
|
Chris@371
|
49 echo "excluding: $lib"
|
Chris@371
|
50 continue
|
Chris@371
|
51 fi
|
Chris@371
|
52
|
Chris@371
|
53 target="$targetdir/usr/lib/$(basename $lib)"
|
Chris@371
|
54
|
Chris@371
|
55 mkdir -p "$(dirname $target)"
|
Chris@371
|
56
|
Chris@371
|
57 if [ ! -f "$target" ]; then
|
Chris@371
|
58
|
Chris@371
|
59 cp -Lv "$lib" "$target"
|
Chris@371
|
60 chmod +x "$target"
|
Chris@371
|
61
|
Chris@371
|
62 add_dependencies "$lib"
|
Chris@371
|
63
|
Chris@371
|
64 fi
|
Chris@371
|
65 done
|
Chris@371
|
66 }
|
Chris@371
|
67
|
Chris@371
|
68 add_dependencies "$program"
|
Chris@371
|
69
|
Chris@375
|
70 cp "$program.desktop" "$targetdir/"
|
Chris@375
|
71
|
Chris@376
|
72 # We don't want an icon, but AppImage seems to insist
|
Chris@376
|
73 cp "deploy/linux/sonic-visualiser.svg" "$targetdir/"
|
Chris@376
|
74
|
Chris@371
|
75 cp "deploy/linux/AppRun" "$targetdir/"
|
Chris@371
|
76
|
Chris@371
|
77 chmod +x "$targetdir/AppRun"
|
Chris@371
|
78
|
Chris@371
|
79 # Do this with a separate extraction step, so as to make it work even
|
Chris@371
|
80 # in situations where FUSE is unavailable like in a Docker container
|
Chris@371
|
81 export ARCH=x86_64
|
Chris@371
|
82 sv-dependency-builds/linux/appimage/appimagetool-x86_64.AppImage --appimage-extract
|
Chris@371
|
83 ./squashfs-root/AppRun "$targetdir" "SonicAnnotator-$version-x86_64.AppImage"
|
Chris@371
|
84
|