#!/usr/bin/env bash # VoiceGrab — Linux build (produces dist/VoiceGrab- binary; AppImage if linuxdeploy available) # WITH_AI=1 ./installer/build_linux.sh → also bundle torch+demucs (bigger build) set -euo pipefail cd "$(dirname "$0")/.." PY="${PYTHON:-.venv/bin/python}" [ -x "$PY" ] || { echo "Create the venv first: python3 -m venv .venv && .venv/bin/pip install -r requirements.txt"; exit 1; } command -v ffmpeg >/dev/null || { echo "ffmpeg not found in PATH (needed to resolve the binary)"; exit 1; } "$PY" -m pip install pyinstaller if [ "${WITH_AI:-0}" = "1" ]; then echo "Building with AI voice separation (torch+demucs)…" "$PY" -m pip install -r requirements-ai.txt AI_FLAGS=(--collect-all demucs --collect-all torch) else AI_FLAGS=() fi FFMPEG_BIN="$(command -v ffmpeg)" FFPROBE_BIN="$(command -v ffprobe || true)" EXTRA=() if [ -n "${FFPROBE_BIN:-}" ]; then EXTRA+=(--add-binary "$FFPROBE_BIN:.") fi "$PY" -m PyInstaller --noconfirm --onefile --windowed --name VoiceGrab \ --add-binary "$FFMPEG_BIN:." \ "${EXTRA[@]}" \ "${AI_FLAGS[@]}" \ --add-data "assets/icon.png:assets" \ --icon assets/icon.ico \ voicegrab.py echo echo "Binary: dist/VoiceGrab" echo "Test: ./dist/VoiceGrab" # Optional: wrap in an AppImage if command -v linuxdeploy >/dev/null 2>&1; then echo "Building AppImage with linuxdeploy..." linuxdeploy --appimage --input dist/ --output appimage elif command -v appimagetool >/dev/null 2>&1; then echo "linuxdeploy not found; appimagetool present — build a .dir first, then run:" echo " appimagetool dist/VoiceGrab-Dir VoiceGrab-x86_64.AppImage" else echo "Tip: install linuxdeploy (or appimagetool) to produce an AppImage." fi