Mercurial > hg > sonic-annotator
comparison deploy/linux/deploy-appimage.sh @ 371:a0ff34e9e86b
First cut at Linux AppImage
author | Chris Cannam |
---|---|
date | Fri, 05 Jun 2020 11:08:37 +0100 |
parents | |
children | 932d426bc2f2 |
comparison
equal
deleted
inserted
replaced
370:3e0133aa2354 | 371:a0ff34e9e86b |
---|---|
1 #!/bin/bash | |
2 | |
3 set -eu | |
4 | |
5 program=sonic-annotator | |
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 cp "deploy/linux/AppRun" "$targetdir/" | |
71 | |
72 chmod +x "$targetdir/AppRun" | |
73 | |
74 # Do this with a separate extraction step, so as to make it work even | |
75 # in situations where FUSE is unavailable like in a Docker container | |
76 export ARCH=x86_64 | |
77 sv-dependency-builds/linux/appimage/appimagetool-x86_64.AppImage --appimage-extract | |
78 ./squashfs-root/AppRun "$targetdir" "SonicAnnotator-$version-x86_64.AppImage" | |
79 |