#!/bin/bash # ============================================================ # SIP Softphone - AppImage Build-Skript # Erstellt ein komplett unabhängiges AppImage # ============================================================ set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" BUILD_DIR="/tmp/sipwebapp_build" VENV_DIR="/tmp/sipwebapp_build_venv" APPDIR="$BUILD_DIR/SipWebApp.AppDir" PJSUA2_DIR="/tmp/sipwebapp_run" APPIMAGETOOL="/tmp/appimagetool" OUTPUT_DIR="$SCRIPT_DIR/dist" echo "=== SIP Softphone AppImage Builder ===" echo "Quellverzeichnis: $SCRIPT_DIR" echo "Build-Verzeichnis: $BUILD_DIR" echo "" # === 1. Voraussetzungen prüfen === echo "[1/6] Voraussetzungen prüfen..." if [ ! -f "$PJSUA2_DIR/_pjsua2."*".so" ]; then echo "FEHLER: pjsua2 Bindings nicht gefunden in $PJSUA2_DIR" echo "Bitte zuerst die App normal starten, damit die Bindings kopiert werden." exit 1 fi if [ ! -f "$APPIMAGETOOL" ]; then echo "appimagetool herunterladen..." curl -L -o "$APPIMAGETOOL" \ https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage chmod +x "$APPIMAGETOOL" fi # === 2. Build-venv erstellen === echo "[2/6] Python Build-Umgebung..." if [ ! -d "$VENV_DIR" ]; then python3 -m venv "$VENV_DIR" "$VENV_DIR/bin/pip" install -q pyinstaller PySide6 vobject requests fi # pjsua2 + dbus ins venv kopieren SITE_PKG=$("$VENV_DIR/bin/python3" -c "import site; print(site.getsitepackages()[0])") SYS_SITE="/usr/lib/python3.14/site-packages" cp "$PJSUA2_DIR"/pjsua2.py "$SITE_PKG/" cp "$PJSUA2_DIR"/_pjsua2.*.so "$SITE_PKG/" if [ -d "$SYS_SITE/dbus" ]; then cp -r "$SYS_SITE/dbus" "$SITE_PKG/" 2>/dev/null || true cp "$SYS_SITE"/_dbus_bindings*.so "$SITE_PKG/" 2>/dev/null || true cp "$SYS_SITE"/_dbus_glib_bindings*.so "$SITE_PKG/" 2>/dev/null || true fi echo " Python-Deps OK" # === 3. PyInstaller ausführen === echo "[3/6] PyInstaller bündelt Anwendung..." rm -rf "$BUILD_DIR/pyinstaller_build" "$BUILD_DIR/pyinstaller_dist" cd "$SCRIPT_DIR" "$VENV_DIR/bin/pyinstaller" \ --distpath "$BUILD_DIR/pyinstaller_dist" \ --workpath "$BUILD_DIR/pyinstaller_build" \ --noconfirm \ --clean \ sipwebapp.spec echo " PyInstaller fertig" # === 4. AppDir erstellen === echo "[4/6] AppDir aufbauen..." rm -rf "$APPDIR" mkdir -p "$APPDIR/usr/bin" mkdir -p "$APPDIR/usr/lib" mkdir -p "$APPDIR/usr/share/applications" mkdir -p "$APPDIR/usr/share/icons/hicolor/scalable/apps" # PyInstaller-Output kopieren cp -r "$BUILD_DIR/pyinstaller_dist/sipwebapp/"* "$APPDIR/usr/bin/" # .desktop Datei (AppImage-Root + share) cp "$SCRIPT_DIR/resources/sipwebapp.desktop" "$APPDIR/" cp "$SCRIPT_DIR/resources/sipwebapp.desktop" "$APPDIR/usr/share/applications/" # Icon (SVG → AppImage-Root und share) cp "$SCRIPT_DIR/resources/icons/phone.svg" "$APPDIR/sipwebapp.svg" cp "$SCRIPT_DIR/resources/icons/phone.svg" \ "$APPDIR/usr/share/icons/hicolor/scalable/apps/sipwebapp.svg" # === 5. AppRun erstellen === echo "[5/6] AppRun erstellen..." cat > "$APPDIR/AppRun" << 'APPRUN_EOF' #!/bin/bash # AppRun für SIP Softphone # Setzt die nötigen Umgebungsvariablen und startet die App SELF="$(readlink -f "$0")" HERE="${SELF%/*}" APPBIN="$HERE/usr/bin" # Bibliotheken im AppImage finden export LD_LIBRARY_PATH="$APPBIN:$HERE/usr/lib:${LD_LIBRARY_PATH}" # Qt-Plugins im AppImage finden export QT_PLUGIN_PATH="$APPBIN/PySide6/Qt/plugins:${QT_PLUGIN_PATH}" export QML2_IMPORT_PATH="$APPBIN/PySide6/Qt/qml:${QML2_IMPORT_PATH}" # XDG-Integration export XDG_DATA_DIRS="$HERE/usr/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" # PipeWire/PulseAudio erlauben (Audio braucht Host-Zugriff) # Keine Sandbox, weil SIP-Audio direkt über ALSA/PipeWire läuft exec "$APPBIN/sipwebapp" "$@" APPRUN_EOF chmod +x "$APPDIR/AppRun" echo " AppDir komplett" # === 6. AppImage erstellen === echo "[6/6] AppImage packen..." mkdir -p "$OUTPUT_DIR" ARCH=x86_64 "$APPIMAGETOOL" "$APPDIR" \ "$OUTPUT_DIR/SipSoftphone-x86_64.AppImage" 2>&1 | tail -5 chmod +x "$OUTPUT_DIR/SipSoftphone-x86_64.AppImage" echo "" echo "=== FERTIG ===" SIZE=$(du -h "$OUTPUT_DIR/SipSoftphone-x86_64.AppImage" | cut -f1) echo "AppImage: $OUTPUT_DIR/SipSoftphone-x86_64.AppImage ($SIZE)" echo "" echo "Starten mit: $OUTPUT_DIR/SipSoftphone-x86_64.AppImage" echo "Oder: chmod +x SipSoftphone-x86_64.AppImage && ./SipSoftphone-x86_64.AppImage"