-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathcreate-appimage.sh
More file actions
executable file
·250 lines (226 loc) · 9.15 KB
/
create-appimage.sh
File metadata and controls
executable file
·250 lines (226 loc) · 9.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#!/bin/sh -eux
##
## Creates UltraGrid AppImage
##
## @param $1 (optional) zsync URL - location used for AppImage updater
## @env $appimage_key (optional) signing key
## (new method, see https://github.com/probonopd/go-appimage/issues/318)
## \n
## Contains base64-encoded .tar.gz of pubkey.asc+privkey.asc.enc files
## containing exported GPG public and private (encrypted) key.
## \n
## Private key is encrypted by OpenSSL (see appimagetool.go source):
## `openssl aes-256-cbc -pass pass:dummy -in privkey.asc -out privkey.asc.enc -a -md sha256`
## @returns name of created AppImage
APPDIR=UltraGrid.AppDir
APPPREFIX=$APPDIR/usr
eval "$(grep 'srcdir *=' < Makefile | tr -d \ )"
umask 022
# soft fail - fail in CI, otherwise continue
handle_error() {
red=1
tput setaf $red 2>/dev/null || true
tput bold 2>/dev/null || true
echo "$1" >&2
tput sgr0 2>/dev/null || true
if [ -n "${GITHUB_REPOSITORY:-}" ]; then
exit 2
fi
}
mkdir tmpinstall $APPDIR
make DESTDIR=tmpinstall install
mv tmpinstall/usr/local $APPPREFIX
# add packet reflector
make -f "${srcdir?srcdir not found}/hd-rum-multi/Makefile" "SRCDIR=$srcdir/hd-rum-multi"
cp hd-rum $APPPREFIX/bin
make -C "$srcdir/tools" convert
cp "$srcdir/tools/convert" $APPPREFIX/bin
# add platform and other Qt plugins if using dynamic libs
# @todo copy only needed ones
# @todo use https://github.com/probonopd/linuxdeployqt
PLUGIN_LIBS=
QT_DIR=
QT_VER=
if [ -f $APPPREFIX/bin/uv-qt ]; then
QT_LDD_DEP=$(ldd $APPPREFIX/bin/uv-qt | grep Qt.Gui | grep -v 'not found')
QT_DIR=$(echo "$QT_LDD_DEP" | awk '{ print $3 }')
QT_DIR=$(dirname "$QT_DIR")
QT_VER=$(echo "$QT_LDD_DEP" | awk '{ print $1 }' | sed 's/.*Qt\([0-9]\)Gui.*/\1/g')
fi
if [ -n "$QT_DIR" ]; then
QT_PLUGIN_PREFIX=$QT_DIR/qt$QT_VER
SRC_PLUGIN_DIR=$QT_PLUGIN_PREFIX/plugins
DST_PLUGIN_DIR=$APPPREFIX/lib/$(basename "$QT_PLUGIN_PREFIX")/plugins
mkdir -p "$DST_PLUGIN_DIR"
cp -r "$SRC_PLUGIN_DIR"/* "$DST_PLUGIN_DIR"
PLUGIN_LIBS=$(find "$DST_PLUGIN_DIR" -type f)
fi
# append to string delimited with space if \$$1 non-empty
append() { eval "$1=\"\$$1\${$1:+ }$2\""; }
# deploy libdecor + its plugin(s) - it is dlopen-ed so not automatic
pfix=$APPPREFIX/lib/ultragrid/ultragrid_display_
if [ -f ${pfix}gl.so ] || [ -f ${pfix}sdl.so ] || [ -f ${pfix}vulkan.so ]; then
libdecor=$(find /usr/lib -name libdecor-0.so.0 | head -n 1)
if [ -f "$libdecor" ]; then
cp "$libdecor" $APPPREFIX/lib/
append PLUGIN_LIBS $APPPREFIX/lib/libdecor-0.so.0
plugins=$(dirname "$libdecor")/libdecor/plugins-1
if [ -d "$plugins" ]; then
dst=$APPPREFIX/lib/libdecor/plugins-1
mkdir -p $dst
cp "$plugins"/*.so $dst/
append PLUGIN_LIBS "$(find "$dst" -type f -exec echo {} +)"
fi
fi
fi
if [ -f $APPPREFIX/lib/ultragrid/ultragrid_vo_pp_text.so ]; then
if ! command -v convert >/dev/null; then
handle_error 'IM convert missing! (needed for bundle)'
fi
# https://stackoverflow.com/a/53355763
conf_path=$(convert -list configure |
sed -n '/CONFIGURE_PATH/ { s/[A-Z_]* *//; p; q; }')
codr_path=$(convert -list configure |
sed -n '/CODER_PATH/ { s/[A-Z_]* *//; p; q; }')
filt_path=$(convert -list configure |
sed -n '/FILTER_PATH/ { s/[A-Z_]* *//; p; q; }')
mkdir $APPDIR/etc $APPPREFIX/share/IM
cp -r "$conf_path" $APPDIR/etc/IM
cp -r "$codr_path" $APPPREFIX/share/IM/coders
cp -r "$filt_path" $APPPREFIX/share/IM/filters
fi
add_fonts() { # for GUI+testcard2
if ! command -v fc-match >/dev/null; then
handle_error "fc-match not found, not copying fonts!"
return
fi
# add DejaVu font
mkdir $APPPREFIX/share/fonts
for family in "DejaVu Sans" "DejaVu Sans Mono"; do
for style in "Book" "Bold"; do
FONT_PATH=$(fc-match "$family:style=$style" file | sed 's/.*=//')
cp "$FONT_PATH" $APPPREFIX/share/fonts
done
done
}
# copy dependencies
mkdir -p $APPPREFIX/lib
for n in "$APPPREFIX"/bin/* "$APPPREFIX"/lib/ultragrid/* $PLUGIN_LIBS; do
for lib in $(ldd "$n" | awk '{ print $3 }'); do
[ ! -f "$lib" ] && continue
DST_NAME=$APPPREFIX/lib/$(basename "$lib")
[ -f "$DST_NAME" ] && continue
cp "$lib" $APPPREFIX/lib
done
done
# hide Wayland libraries
if ls $APPPREFIX/lib/libwayland-* >/dev/null 2>&1; then
mkdir $APPPREFIX/lib/wayland
mv $APPPREFIX/lib/libwayland-* $APPPREFIX/lib/wayland
fi
# hide libOpenGL.so.0 libraries
if [ -f $APPPREFIX/lib/libOpenGL.so.0 ]; then
mkdir $APPPREFIX/lib/libopengl
mv $APPPREFIX/lib/libOpenGL.so.0 $APPPREFIX/lib/libopengl
fi
add_fonts
if command -v curl >/dev/null; then
dl() {
curl --fail -sSL ${GITHUB_TOKEN+-H "Authorization: token $GITHUB_TOKEN"} "$1"
}
elif command -v wget >/dev/null && wget -V | grep -q https; then
dl() {
wget -O - ${GITHUB_TOKEN+--header "Authorization: token $GITHUB_TOKEN"} "$1"
}
else
echo "Neither wget nor curl was found - if one needed later, it will " \
"fail!" >&2
fi
# Remove libraries that should not be bundled, see https://gitlab.com/probono/platformissues
[ -f excludelist ] || dl https://raw.githubusercontent.com/probonopd/AppImages/master/excludelist > excludelist || exit 1
DIRNAME=$(dirname "$0")
uname_m=$(uname -m)
excl_list_arch=x86
if expr "$uname_m" : arm >/dev/null || expr "$uname_m" : aarch64 > /dev/null; then
excl_list_arch=arm
fi
cat "$DIRNAME/excludelist.local.$excl_list_arch" >> excludelist
EXCLUDE_LIST=
while read -r x; do
if [ -z "$x" ] || expr "x$x" : x\# > /dev/null; then
continue
fi
NAME=$(echo "$x" | awk '{ print $1 }')
EXCLUDE_LIST="$EXCLUDE_LIST $NAME"
done < excludelist
# these dependencies will be preloaded by AppRun if found in system - include
# them for the cases when isn't
should_be_included() {
INCLUDE_LIST="\
libOpenGL.so.0\
libjack.so.0\
libpipewire-0.3.so.0\
"
echo "$INCLUDE_LIST" |
grep -E -q '(^|[^[:alnum:]_])'"${1?}"'([^[:alnum:]_]|$)'
}
for n in $EXCLUDE_LIST; do
if should_be_included "$n"; then
continue
fi
if [ -f "$APPPREFIX/lib/$n" ]; then
rm "$APPPREFIX/lib/$n"
fi
done
( cd $APPPREFIX/lib; rm -f libcmpto* ) # remove non-free components
# ship VA-API drivers if have libva
if [ -f "$(echo $APPPREFIX/lib/libva.so.* | cut -d\ -f 1)" ]; then
for n in ${LIBVA_DRIVERS_PATH:-} /usr/lib/x86_64-linux-gnu/dri /usr/lib/dri; do
if [ -d "$n" ]; then
cp -r "$n" $APPPREFIX/lib/va
break
fi
done
fi
cp -r "$srcdir/data/scripts/Linux-AppImage/AppRun" "$srcdir/data/scripts/Linux-AppImage/scripts" "$srcdir/data/ultragrid.png" $APPDIR
cp "$srcdir/data/uv-qt.desktop" $APPDIR/cz.cesnet.ultragrid.desktop
appimageupdatetool=$(command -v appimageupdatetool-x86_64.AppImage || command -v ./appimageupdatetool || true)
if [ -z "$appimageupdatetool" ]; then
appimageupdatetool=./appimageupdatetool
dl https://github.com/AppImage/AppImageUpdate/releases/download/continuous/appimageupdatetool-x86_64.AppImage > $appimageupdatetool # use AppImageUpdate for GUI updater
fi
cp "$appimageupdatetool" $APPDIR/appimageupdatetool
chmod ugo+x $APPDIR/appimageupdatetool
if [ -f /lib/x86_64-linux-gnu/libfuse.so.2 ]; then
mkdir $APPDIR/appimageupdatetool-lib
cp /lib/x86_64-linux-gnu/libfuse.so.2 $APPDIR/appimageupdatetool-lib
fi
# TODO: temporarily (? 2025-01-25) disable signing because validation fails
unset appimage_key
GIT_ROOT=$(git rev-parse --show-toplevel || true)
if [ -n "${appimage_key-}" ] && [ -n "${GIT_ROOT-}" ]; then
echo "$appimage_key" | base64 -d | tar -C "$GIT_ROOT" -xzaf -
export super_secret_password=dummy
fi
mkappimage=$(command -v ./mkappimage || command -v mkappimage-x86_64.AppImage || command -v mkappimage || true)
if [ -z "$mkappimage" ]; then
mkai_url=$(dl https://api.github.com/repos/probonopd/go-appimage/releases/tags/continuous | grep "browser_download_url.*mkappimage-.*-x86_64.AppImage" | head -n 1 | cut -d '"' -f 4)
dl "$mkai_url" > mkappimage
chmod +x mkappimage
mkappimage=./mkappimage
fi
if "$mkappimage" 2>&1 | grep fuse; then
if [ ! -d mkappimage-extracted ]; then
"$mkappimage" --appimage-extract
mv squashfs-root mkappimage-extracted
fi
mkappimage="mkappimage-extracted/AppRun"
fi
UPDATE_INFORMATION=
if [ $# -ge 1 ]; then
UPDATE_INFORMATION="-u zsync|$1"
fi
# shellcheck disable=SC1007,SC2086 # word spliting of
# $UPDATE_INFORMATION is a requested behavior
GITHUB_TOKEN= $mkappimage $UPDATE_INFORMATION $APPDIR
rm -rf $APPDIR tmpinstall