|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +#-----------------------------------------------------------------------# |
| 4 | +# Keyboard Visualizer AppImage Build Script # |
| 5 | +#-----------------------------------------------------------------------# |
| 6 | + |
| 7 | +set -x |
| 8 | +set -e |
| 9 | + |
| 10 | +#-----------------------------------------------------------------------# |
| 11 | +# Build in a temporary directory to keep the system clean # |
| 12 | +# Use RAM disk if possible (if available and not building on a CI # |
| 13 | +# system like Travis) # |
| 14 | +#-----------------------------------------------------------------------# |
| 15 | +if [ "$CI" == "" ] && [ -d /dev/shm ]; then |
| 16 | + TEMP_BASE=/dev/shm |
| 17 | +else |
| 18 | + TEMP_BASE=/tmp |
| 19 | +fi |
| 20 | + |
| 21 | +BUILD_DIR=$(mktemp -d -p "$TEMP_BASE" appimage-build-XXXXXX) |
| 22 | + |
| 23 | +#-----------------------------------------------------------------------# |
| 24 | +# Make sure to clean up build dir, even if errors occur # |
| 25 | +#-----------------------------------------------------------------------# |
| 26 | +cleanup () { |
| 27 | + if [ -d "$BUILD_DIR" ]; then |
| 28 | + rm -rf "$BUILD_DIR" |
| 29 | + fi |
| 30 | +} |
| 31 | +trap cleanup EXIT |
| 32 | + |
| 33 | +#-----------------------------------------------------------------------# |
| 34 | +# Store repo root as variable # |
| 35 | +#-----------------------------------------------------------------------# |
| 36 | +REPO_ROOT=$(readlink -f $(dirname $(dirname $0))) |
| 37 | +OLD_CWD=$(readlink -f .) |
| 38 | + |
| 39 | +#-----------------------------------------------------------------------# |
| 40 | +# Switch to build dir # |
| 41 | +#-----------------------------------------------------------------------# |
| 42 | +pushd "$BUILD_DIR" |
| 43 | + |
| 44 | +#-----------------------------------------------------------------------# |
| 45 | +# Configure build files with qmake # |
| 46 | +# we need to explicitly set the install prefix, as qmake's default is # |
| 47 | +# /usr/local for some reason... # |
| 48 | +#-----------------------------------------------------------------------# |
| 49 | +qmake "$REPO_ROOT" |
| 50 | + |
| 51 | +#-----------------------------------------------------------------------# |
| 52 | +# Build project and install files into AppDir # |
| 53 | +#-----------------------------------------------------------------------# |
| 54 | +make -j$(nproc) |
| 55 | +make install INSTALL_ROOT=AppDir |
| 56 | + |
| 57 | +#-----------------------------------------------------------------------# |
| 58 | +# Now, build AppImage using linuxdeploy and linuxdeploy-plugin-qt # |
| 59 | +# Download linuxdeploy and its Qt plugin # |
| 60 | +#-----------------------------------------------------------------------# |
| 61 | +wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage |
| 62 | +wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage |
| 63 | + |
| 64 | +#-----------------------------------------------------------------------# |
| 65 | +# Make them executable # |
| 66 | +#-----------------------------------------------------------------------# |
| 67 | +chmod +x linuxdeploy*.AppImage |
| 68 | + |
| 69 | +#-----------------------------------------------------------------------# |
| 70 | +# Make sure Qt plugin finds QML sources so it can deploy the imported # |
| 71 | +# files # |
| 72 | +export QML_SOURCES_PATHS="$REPO_ROOT"/src |
| 73 | + |
| 74 | +./linuxdeploy-x86_64.AppImage --appimage-extract-and-run --appdir AppDir -e KeyboardVisualizer -i "$REPO_ROOT"/KeyboardVisualizerQT/KeyboardVisualizer.png -d "$REPO_ROOT"/KeyboardVisualizerQT/KeyboardVisualizer.desktop |
| 75 | +./linuxdeploy-plugin-qt-x86_64.AppImage --appimage-extract-and-run --appdir AppDir |
| 76 | +./linuxdeploy-x86_64.AppImage --appimage-extract-and-run --appdir AppDir --output appimage |
| 77 | + |
| 78 | +#-----------------------------------------------------------------------# |
| 79 | +# Move built AppImage back into original CWD # |
| 80 | +#-----------------------------------------------------------------------# |
| 81 | +mv KeyboardVisualizer*.AppImage "$OLD_CWD" |
| 82 | + |
0 commit comments