Mercurial > hg > easyhg
comparison deploy/linux/deploy-appimage.sh @ 700:21e4df9865af
Some work on Linux packaging
author | Chris Cannam |
---|---|
date | Wed, 12 Dec 2018 10:16:11 +0000 |
parents | |
children | 48e746f45bde |
comparison
equal
deleted
inserted
replaced
699:646e48a0d3a5 | 700:21e4df9865af |
---|---|
1 #!/bin/bash | |
2 | |
3 set -eu | |
4 | |
5 program=EasyMercurial | |
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 if [ ! -x ./appimagetool-x86_64.AppImage ]; then | |
21 echo "Failed to find executable ./appimagetool-x86_64.AppImage, please provide that first" | |
22 exit 2 | |
23 fi | |
24 | |
25 targetdir="${program}.AppDir" | |
26 | |
27 echo "Target dir is $targetdir" | |
28 | |
29 if [ -d "$targetdir" ]; then | |
30 echo "Target directory exists, not overwriting" | |
31 exit 2 | |
32 fi | |
33 | |
34 mkdir "$targetdir" | |
35 | |
36 mkdir -p "$targetdir"/usr/bin | |
37 mkdir -p "$targetdir"/usr/lib | |
38 | |
39 cp "$program" "$targetdir"/usr/bin/ | |
40 | |
41 add_dependencies() { | |
42 | |
43 local binary="$1" | |
44 | |
45 echo "ldd $binary yields:" | |
46 ldd "$binary" | |
47 | |
48 for lib in $(ldd "$binary" | grep '=> [^ ]*/lib/' | \ | |
49 sed 's/^.*=> //' | sed 's/ .*$//'); do | |
50 | |
51 base=$(basename "$lib") | |
52 if grep -v '^#' deploy/linux/appimage-excludelist | | |
53 grep -q "^$base$" ; then | |
54 echo "excluding: $lib" | |
55 continue | |
56 fi | |
57 | |
58 target="$targetdir/usr/lib/$(basename $lib)" | |
59 | |
60 mkdir -p "$(dirname $target)" | |
61 | |
62 if [ ! -f "$target" ]; then | |
63 | |
64 cp -Lv "$lib" "$target" | |
65 chmod +x "$target" | |
66 | |
67 add_dependencies "$lib" | |
68 | |
69 fi | |
70 done | |
71 } | |
72 | |
73 add_dependencies "$program" | |
74 | |
75 qtplugins="gif icns ico jpeg tga tiff wbmp webp cocoa minimal offscreen xcb" | |
76 qtlibdirs="/usr/lib/x86_64-linux-gnu/qt5 /usr/lib/x86_64-linux-gnu/qt /usr/lib/qt5 /usr/lib/qt" | |
77 | |
78 QTDIR=${QTDIR:-} | |
79 if [ -n "$QTDIR" ]; then | |
80 qtlibdirs="$QTDIR $qtlibdirs" | |
81 fi | |
82 | |
83 for plug in $qtplugins; do | |
84 for libdir in $qtlibdirs; do | |
85 lib=$(find $libdir/plugins -name libq$plug.so -print 2>/dev/null || true) | |
86 if [ -n "$lib" ]; then | |
87 if [ -f "$lib" ]; then | |
88 subdir=$(basename $(dirname $lib)) | |
89 if [ t"$subdir" = t"plugins" ]; then | |
90 subdir="" | |
91 fi | |
92 target="$targetdir/usr/lib/qt5/plugins/$subdir/$(basename $lib)" | |
93 mkdir -p "$(dirname $target)" | |
94 cp -v "$lib" "$target" | |
95 chmod +x "$target" | |
96 add_dependencies "$lib" | |
97 break | |
98 fi | |
99 fi | |
100 done | |
101 done | |
102 | |
103 cp "deploy/linux/$program.desktop" "$targetdir/" | |
104 | |
105 cp images/icon/scalable/easyhg-icon.svg "$targetdir/" | |
106 cp images/icon/scalable/easyhg-icon.svg "$targetdir/$program.svg" | |
107 cp images/icon/128/easyhg-icon.png "$targetdir/" | |
108 | |
109 cp "deploy/linux/AppRun" "$targetdir/" | |
110 | |
111 chmod +x "$targetdir/AppRun" | |
112 | |
113 # Do this with a separate extraction step, so as to make it work even | |
114 # in situations where FUSE is unavailable like in a Docker container | |
115 export ARCH=x86_64 | |
116 ./appimagetool-x86_64.AppImage --appimage-extract | |
117 ./squashfs-root/AppRun "$targetdir" "$program-$version-x86_64.AppImage" |