#!/bin/bash # SPDX-License-Identifier: AGPL-3.0-or-later # Copyright (c) 2025-2026 Cristian Cezar Moisés # Build zupt-gui AppImage. Since the GUI is pure Python + Qt, the AppDir # bundles only the Python source and metadata; it relies on system # python3 + PyQt6/PySide6 at runtime. This keeps the AppImage tiny # (~50 KB) and lets it work on any Linux with Qt6 Python bindings. # # For a true self-contained AppImage with bundled Python interpreter, # use python-appimage (https://github.com/niess/python-appimage) on # the build host — it produces a ~80 MB AppImage. The portable variant # below is the better tradeoff for most distributions. set -e cd "$(dirname "$0")/.." VERSION="${VERSION:-1.2.0}" APPDIR="/tmp/vaptvupt-gui.AppDir" rm -rf "$APPDIR" mkdir -p "$APPDIR/usr/bin" \ "$APPDIR/usr/lib/vaptvupt-gui" \ "$APPDIR/usr/share/applications" \ "$APPDIR/usr/share/icons/hicolor/256x256/apps" # Python source install -m 644 gui/src/zupt_gui.py "$APPDIR/usr/lib/vaptvupt-gui/" # Wrapper cat > "$APPDIR/usr/bin/vaptvupt-gui" <<'WRAP' #!/bin/sh exec python3 "$(dirname "$0")/../lib/vaptvupt-gui/zupt_gui.py" "$@" WRAP chmod 755 "$APPDIR/usr/bin/vaptvupt-gui" # Desktop file cat > "$APPDIR/vaptvupt-gui.desktop" <<'DESKTOP' [Desktop Entry] Type=Application Name=VaptVupt GUI GenericName=Backup and Compression Utility Comment=Post-quantum backup with HKDF combiner, key commitment, HPKE binding Exec=vaptvupt-gui %f Icon=vaptvupt-gui Terminal=false Categories=Utility;Archiving;Compression;Security; StartupNotify=true DESKTOP cp "$APPDIR/vaptvupt-gui.desktop" "$APPDIR/usr/share/applications/" # Icon if [ -f gui/assets/zupt-icon.png ]; then cp gui/assets/zupt-icon.png "$APPDIR/vaptvupt-gui.png" cp gui/assets/zupt-icon.png "$APPDIR/usr/share/icons/hicolor/256x256/apps/vaptvupt-gui.png" else python3 -c " import struct, zlib def png(w, h, color): raw = b''.join(b'\\0' + bytes(color) * w for _ in range(h)) def chunk(t, d): return struct.pack('>I', len(d)) + t + d + struct.pack('>I', zlib.crc32(t+d) & 0xffffffff) return b'\\x89PNG\\r\\n\\x1a\\n' + chunk(b'IHDR', struct.pack('>IIBBBBB', w, h, 8, 2, 0, 0, 0)) + chunk(b'IDAT', zlib.compress(raw)) + chunk(b'IEND', b'') open('$APPDIR/zupt-gui.png','wb').write(png(256, 256, (88, 92, 215))) " cp "$APPDIR/vaptvupt-gui.png" "$APPDIR/usr/share/icons/hicolor/256x256/apps/vaptvupt-gui.png" fi # AppRun — sets PATH so zupt-gui finds the bundled wrapper, falls # back to system zupt CLI if not present in /usr/bin alongside. cat > "$APPDIR/AppRun" <<'APPRUN' #!/bin/sh HERE="$(dirname "$(readlink -f "$0")")" export PATH="$HERE/usr/bin:$PATH" # Pre-flight check: is python3 available? Is a Qt6 binding installed? if ! command -v python3 >/dev/null 2>&1; then cat >&2 </dev/null \ && ! python3 -c 'import PySide6.QtWidgets' 2>/dev/null; then cat >&2 </dev/null 2>&1 && ! command -v zupt >/dev/null 2>&1; then cat >&2 </dev/null 2>&1; then ARCH=x86_64 appimagetool "$APPDIR" "/tmp/VaptVupt-GUI-$VERSION-x86_64.AppImage" 2>&1 | tail -5 echo "Built: /tmp/VaptVupt-GUI-$VERSION-x86_64.AppImage" else cd /tmp rm -f "VaptVupt-GUI-$VERSION-x86_64.AppDir.tar.gz" tar -czf "VaptVupt-GUI-$VERSION-x86_64.AppDir.tar.gz" vaptvupt-gui.AppDir cd - >/dev/null echo "appimagetool unavailable; portable AppDir tarball at:" echo " /tmp/VaptVupt-GUI-$VERSION-x86_64.AppDir.tar.gz" echo "Run via: tar -xzf ... && ./vaptvupt-gui.AppDir/AppRun" echo "Convert to AppImage on a host with appimagetool:" echo " ARCH=x86_64 appimagetool vaptvupt-gui.AppDir VaptVupt-GUI-$VERSION-x86_64.AppImage" fi