#!/bin/sh # SPDX-License-Identifier: MIT # Builds OpenPU--.AppImage (GTK interface + openpu-cli) with linuxdeploy and its GTK # plugin, in the current directory. Runs on x86_64 and aarch64; no FUSE needed. # # usage: tools/appimage.sh [build-dir] # The linuxdeploy tools are downloaded once into $OPENPU_APPIMAGE_TOOLS (default ~/.cache/openpu-appimage). set -eu SRC=$(cd "$(dirname "$0")/.." && pwd) BUILD=${1:-$SRC/../build-openpu/appimage} OUT=$(pwd) ARCH=$(uname -m) TOOLS=${OPENPU_APPIMAGE_TOOLS:-$HOME/.cache/openpu-appimage} LINUXDEPLOY=$TOOLS/linuxdeploy-$ARCH.AppImage GTK_PLUGIN=$TOOLS/linuxdeploy-plugin-gtk.sh mkdir -p "$TOOLS" fetch() { # url file [ -s "$2" ] || { curl -fsSL -o "$2.part" "$1" && mv "$2.part" "$2"; } chmod +x "$2" } fetch "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-$ARCH.AppImage" "$LINUXDEPLOY" fetch "https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh" "$GTK_PLUGIN" cmake -S "$SRC" -B "$BUILD" -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr \ -DOPENPU_UI_GTK=ON -DOPENPU_BUILD_TESTS=OFF cmake --build "$BUILD" APPDIR=$BUILD/AppDir rm -rf "$APPDIR" DESTDIR=$APPDIR cmake --install "$BUILD" --strip VERSION=$("$APPDIR/usr/bin/openpu-cli" --version | awk '{print $2}') ID=io.github.openpu.OpenPU cd "$OUT" # linuxdeploy finds its plugins next to itself or in PATH. PATH=$TOOLS:$PATH APPIMAGE_EXTRACT_AND_RUN=1 DEPLOY_GTK_VERSION=4 LINUXDEPLOY_OUTPUT_VERSION=$VERSION \ "$LINUXDEPLOY" --appdir "$APPDIR" --plugin gtk --output appimage \ --executable "$APPDIR/usr/bin/openpu" --executable "$APPDIR/usr/bin/openpu-cli" \ --desktop-file "$APPDIR/usr/share/applications/$ID.desktop" \ --icon-file "$APPDIR/usr/share/icons/hicolor/256x256/apps/$ID.png" ls -l "$OUT"/OpenPU-*.AppImage