1#!/bin/sh
2
3set -e
4
5if [ ! -f ./bin/chatterino ] || [ ! -x ./bin/chatterino ]; then
6    echo "ERROR: No chatterino binary file found. This script must be run in the build folder, and chatterino must be built first."
7    exit 1
8fi
9
10export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/qt512/lib/"
11export PATH="/opt/qt512/bin:$PATH"
12
13script_path=$(readlink -f "$0")
14script_dir=$(dirname "$script_path")
15chatterino_dir=$(dirname "$script_dir")
16
17qmake_path=$(command -v qmake)
18
19echo "Running LDD on chatterino binary:"
20ldd ./bin/chatterino
21echo ""
22
23echo "Running make install in the appdir"
24make INSTALL_ROOT=appdir -j"$(nproc)" install ; find appdir/
25echo ""
26
27cp "$chatterino_dir"/resources/icon.png ./appdir/chatterino.png
28
29linuxdeployqt_path="linuxdeployqt-6-x86_64.AppImage"
30linuxdeployqt_url="https://github.com/probonopd/linuxdeployqt/releases/download/6/linuxdeployqt-6-x86_64.AppImage"
31
32if [ ! -f "$linuxdeployqt_path" ]; then
33    wget -nv "$linuxdeployqt_url"
34    chmod a+x "$linuxdeployqt_path"
35fi
36if [ ! -f appimagetool-x86_64.AppImage ]; then
37    wget -nv "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
38    chmod a+x appimagetool-x86_64.AppImage
39fi
40echo "Run LinuxDeployQT"
41./"$linuxdeployqt_path" \
42    appdir/usr/share/applications/*.desktop \
43    -no-translations \
44    -bundle-non-qt-libs \
45    -unsupported-allow-new-glibc \
46    -qmake="$qmake_path"
47
48rm -rf appdir/home
49rm -f appdir/AppRun
50
51echo "Run AppImageTool"
52
53# shellcheck disable=SC2016
54echo '#!/bin/sh
55here="$(dirname "$(readlink -f "${0}")")"
56export QT_QPA_PLATFORM_PLUGIN_PATH="$here/usr/plugins"
57cd "$here/usr"
58exec "$here/usr/bin/chatterino" "$@"' > appdir/AppRun
59chmod a+x appdir/AppRun
60
61./appimagetool-x86_64.AppImage appdir
62