Debian Codegraph @

tools/build_appimage.sh

raw symbols SCIP
1 #!/bin/sh
2
3 set -e
4
5 srcdir=$(readlink -f "$1")
6 buildir=$(readlink -f "$2")
7
8 if [ -z "$srcdir" ] || [ -z "$buildir" ]; then
9 echo "usage: $0 <srcdir> <builddir>"
10 exit 1
11 fi
12
13 gitversion=$(git -C "$srcdir" describe)
14
15 ZSTD=$(which zstd)
16
17 if [ -z "$ZSTD" ]; then
18 echo "ERROR: cannot find zstd in PATH"
19 exit 1
20 fi
21
22 if [ -z "$(which linuxdeploy)" ]; then
23 echo "ERROR: cannot find linuxdeploy in PATH"
24 exit 1
25 fi
26
27 . /opt/rh/gcc-toolset-14/enable
28
29 mkdir -p "$buildir" && cd "$buildir"
30 cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/opt/rh/gcc-toolset-14/root/ \
31 -DCMAKE_BUILD_TYPE=Release -DAPPIMAGE_BUILD=ON "$srcdir"
32 make -j$(nproc)
33 rm -Rf appdir
34 make DESTDIR=appdir install
35
36 # copy the zstd binary into the app image
37 cp $ZSTD ./appdir/usr/bin/zstd
38
39 # Ensure we prefer the bundled libs also when calling dlopen, cf.: https://github.com/KDAB/hotspot/issues/89
40 mv "./appdir/usr/bin/heaptrack_gui" "./appdir/usr/bin/heaptrack_gui_bin"
41 cat << WRAPPER_SCRIPT > ./appdir/usr/bin/heaptrack_gui
42 #!/bin/bash
43 f="\$(readlink -f "\${0}")"
44 d="\$(dirname "\$f")"
45 unset QT_PLUGIN_PATH
46 LD_LIBRARY_PATH="\$d/../lib:\$LD_LIBRARY_PATH" "\$d/heaptrack_gui_bin" "\$@"
47 WRAPPER_SCRIPT
48 chmod +x ./appdir/usr/bin/heaptrack_gui
49
50 mv "./appdir/usr/lib/heaptrack/libexec/heaptrack_interpret" "./appdir/usr/lib/heaptrack/libexec/heaptrack_interpret_bin"
51 cat << WRAPPER_SCRIPT > ./appdir/usr/lib/heaptrack/libexec/heaptrack_interpret
52 #!/bin/bash
53 f="\$(readlink -f "\${0}")"
54 d="\$(dirname "\$f")"
55 LD_LIBRARY_PATH="\$d/../../:\$LD_LIBRARY_PATH" "\$d/heaptrack_interpret_bin" "\$@"
56 WRAPPER_SCRIPT
57 chmod +x ./appdir/usr/lib/heaptrack/libexec/heaptrack_interpret
58
59 # include breeze icons
60 mkdir -p "appdir/usr/share/icons/breeze"
61 cp -v "/usr/share/icons/breeze/breeze-icons.rcc" "appdir/usr/share/icons/breeze/"
62
63 # use the shell script as AppRun entry point
64 # also make sure we find the bundled zstd
65 cat << WRAPPER_SCRIPT > ./appdir/AppRun
66 #!/bin/bash
67 f="\$(readlink -f "\${0}")"
68 d="\$(dirname "\$f")"
69 bin="\$d/usr/bin"
70 PATH="\$PATH:\$bin" "\$bin/heaptrack" "\$@"
71 WRAPPER_SCRIPT
72 chmod +x ./appdir/AppRun
73
74 # tell the linuxdeploy qt plugin to include these platform plugins
75 export EXTRA_PLATFORM_PLUGINS="libqoffscreen.so;libqwayland-generic.so"
76
77 mkdir -p appdir/usr/plugins/wayland-shell-integration/
78 cp /usr/plugins/wayland-shell-integration/libxdg-shell.so appdir/usr/plugins/wayland-shell-integration/
79
80 linuxdeploy --appdir appdir --plugin qt \
81 -e "./appdir/usr/lib/heaptrack/libexec/heaptrack_interpret_bin" \
82 -e "./appdir/usr/lib/heaptrack/libheaptrack_preload.so" \
83 -e "./appdir/usr/lib/heaptrack/libheaptrack_inject.so" \
84 -e "./appdir/usr/bin/heaptrack_gui_bin" \
85 -e "./appdir/usr/bin/zstd" \
86 -l "/usr/lib64/libz.so.1" \
87 -l /usr/lib64/libharfbuzz.so.0 \
88 -l /usr/lib64/libfreetype.so.6 \
89 -l /usr/lib64/libfontconfig.so.1 \
90 -l /usr/lib64/libwayland-egl.so \
91 -i "$srcdir/src/analyze/gui/128-apps-heaptrack.png" --icon-filename=heaptrack \
92 -d "./appdir/usr/share/applications/org.kde.heaptrack.desktop" \
93 --output appimage
94
95 mv Heaptrack*x86_64.AppImage "/github/workspace/heaptrack-$gitversion-x86_64.AppImage"