chore: untrack local release build scripts

This commit is contained in:
thw 2026-11-15 01:39:43 +01:00
parent 5929831402
commit 6ef4067bf7
3 changed files with 9 additions and 488 deletions

10
.gitignore vendored
View File

@ -164,4 +164,12 @@ ehthumbs.db
Thumbs.db
# Lokale Spielstand-Datenbank (wichtig, damit Spielstände nicht ins Git geraten)
user_data.db
user_data.db
# Lokale Release- & Cross-Build-Skripte
build_scripts/
dist/
build/
*.spec
.venv*/

View File

@ -1,221 +0,0 @@
@echo off
setlocal EnableDelayedExpansion
REM =============================================================================
REM The Goth Cardgame Collection - One-File Build Script (Windows + WSL)
REM Output: dist\windows\TheGothCardgameCollection.exe
REM Usage: build_scripts\build.bat [--current | --all | --clean]
REM =============================================================================
set "SCRIPT_FILE=%~f0"
cd /d "%~dp0.."
set "PROJECT_ROOT=%CD%"
set "APP_NAME=TheGothCardgameCollection"
set "MAIN_FILE=main.py"
set "RES_DIR=resources"
set "GAMES_DIR=games"
set "MODE=%~1"
if "%MODE%"=="" set "MODE=--current"
if /I "%MODE%"=="--clean" (
if exist "build" rmdir /s /q "build"
if exist ".venv_build_win" rmdir /s /q ".venv_build_win"
del /q "*.spec" 2>nul
echo [OK] Temporaere Build-Dateien bereinigt.
exit /b 0
)
REM ----------------------------------------------------
REM 0. ADMIN-RECHTE PRUEFEN (net session)
REM ----------------------------------------------------
set "IS_ADMIN=0"
net session >nul 2>nul
if not errorlevel 1 set "IS_ADMIN=1"
REM Kaputte Altlast-Venvs vorab bereinigen
if exist ".venv_build_win" (
if not exist ".venv_build_win\Scripts\python.exe" rmdir /s /q ".venv_build_win"
)
REM Vorhandenes Python ermitteln
call :FIND_PYTHON
REM Pruefen, ob System-Installationen noetig sind (Python fehlt oder WSL-Distro fehlt bei --all)
set "NEEDS_ADMIN=0"
if "%WIN_PY%"=="" set "NEEDS_ADMIN=1"
set "WSL_DISTRO="
if /I "%MODE%"=="--all" (
call :FIND_WSL_DISTRO
if "!WSL_DISTRO!"=="" set "NEEDS_ADMIN=1"
)
REM Falls etwas auf Systemebene installiert werden muss und KEINE Admin-Rechte vorliegen -> UAC anfordern!
if "%NEEDS_ADMIN%"=="1" if "%IS_ADMIN%"=="0" (
if /I "%~2"=="--elevated" (
echo [ERROR] Administrator-Rechte wurden verweigert oder konnten nicht erlangt werden!
echo Bitte starte die Konsole / PowerShell explizit "Als Administrator".
pause
exit /b 1
)
echo [ADMIN] Fehlende Systemkomponenten erkannt ^(Python oder WSL^).
echo Fordere Administrator-Rechte ueber Windows-UAC an...
powershell -NoProfile -Command "Start-Process -FilePath 'cmd.exe' -ArgumentList '/k \"\"%SCRIPT_FILE%\" %MODE% --elevated\"' -Verb RunAs"
exit /b 0
)
echo ====================================================
echo Starte Build fuer %APP_NAME% ^(Modus: %MODE% ^| Admin: %IS_ADMIN%^)
echo ====================================================
REM Falls Python fehlte -> jetzt mit garantierten Admin-Rechten systemweit installieren
if "%WIN_PY%"=="" (
echo [BOOTSTRAP] Installiere Python 3.11 via winget ^(Administrator^)...
winget install -e --id Python.Python.3.11 --scope machine --accept-source-agreements --accept-package-agreements
for %%P in (
"%ProgramFiles%\Python311"
"%LocalAppData%\Programs\Python\Python311"
"C:\Python311"
) do (
if exist "%%~P\python.exe" set "PATH=%%~P;%%~P\Scripts;!PATH!"
)
call :FIND_PYTHON
)
if "%WIN_PY%"=="" (
echo [ERROR] Python 3.11+ konnte nicht gefunden oder installiert werden!
exit /b 1
)
REM ----------------------------------------------------
REM TEIL 1: WINDOWS .EXE BAUEN
REM ----------------------------------------------------
echo.
echo ---^> [1] Baue Windows .exe mit %WIN_PY%...
REM Ohne Admin-Rechte & ausserhalb einer Venv installieren wir Pakete sauber mit --user
set "PIP_EXTRA="
if "%IS_ADMIN%"=="0" if "%USING_VENV%"=="0" set "PIP_EXTRA=--user"
%WIN_PY% -m pip install --upgrade pip
%WIN_PY% -m pip install %PIP_EXTRA% --upgrade pillow pygame pyinstaller
if errorlevel 1 (
echo [ERROR] Konnte Python-Pakete ^(PyInstaller/Pillow/Pygame^) nicht installieren!
exit /b 1
)
set "ICON_ARG="
if exist "resources\images\game_icon.ico" set "ICON_ARG=--icon resources\images\game_icon.ico"
%WIN_PY% -m PyInstaller ^
--noconfirm ^
--noconsole ^
--onefile ^
--clean ^
--distpath "dist\windows" ^
--workpath "build\windows" ^
--specpath "build\windows" ^
%ICON_ARG% ^
--add-data "%RES_DIR%;%RES_DIR%" ^
--add-data "%GAMES_DIR%;%GAMES_DIR%" ^
--collect-submodules games ^
--collect-submodules controller ^
--collect-submodules models ^
--collect-submodules view ^
--collect-submodules resources ^
--hidden-import tkinter ^
--hidden-import tkinter.ttk ^
--hidden-import tkinter.font ^
--hidden-import sqlite3 ^
--hidden-import PIL._tkinter_finder ^
--name "%APP_NAME%" ^
"%MAIN_FILE%"
if errorlevel 1 (
echo [ERROR] Windows-Build fehlgeschlagen!
exit /b 1
)
if exist "build\windows" rmdir /s /q "build\windows"
echo [OK] Windows-Build fertig: dist\windows\%APP_NAME%.exe
REM ----------------------------------------------------
REM TEIL 2: LINUX EXECUTABLE VIA WSL (nur bei --all)
REM ----------------------------------------------------
if /I "%MODE%"=="--all" (
echo.
echo ---^> [2] Baue Linux Executable ^(via WSL^)...
call :FIND_WSL_DISTRO
if "!WSL_DISTRO!"=="" (
echo [BOOTSTRAP] Keine Linux-Distribution in WSL gefunden. Installiere Ubuntu ^(als Administrator^)...
wsl.exe --install -d Ubuntu --no-launch
call :FIND_WSL_DISTRO
if "!WSL_DISTRO!"=="" (
echo [HINWEIS] WSL/Ubuntu wurde vorbereitet. Windows erfordert einmalig einen System-Neustart,
echo bevor Linux-Builds in WSL ausgefuehrt werden koennen!
goto :SUMMARY
)
)
echo [WSL] Nutze Distribution: !WSL_DISTRO! ^(als root fuer Paket-Rechte^)
set "WSL_PROJ_PATH="
for /f "usebackq delims=" %%P in (`wsl.exe -d "!WSL_DISTRO!" -u root -- wslpath -a "%PROJECT_ROOT%" 2^>nul`) do (
set "WSL_PROJ_PATH=%%P"
)
if "!WSL_PROJ_PATH!"=="" (
echo [ERROR] Konnte Projektpfad "%PROJECT_ROOT%" in WSL nicht aufloesen.
exit /b 1
)
REM Fuehrt build.sh in WSL direkt als root (-u root) aus -> keine Passwort-Abfrage & volle apt-Rechte!
wsl.exe -d "!WSL_DISTRO!" -u root -- bash -lc "cd '!WSL_PROJ_PATH!' && sed -i 's/\r$//' build_scripts/build.sh && chmod +x build_scripts/build.sh && ./build_scripts/build.sh --current"
if errorlevel 1 (
echo [ERROR] Linux-Build in WSL fehlgeschlagen!
exit /b 1
)
)
:SUMMARY
echo.
echo ====================================================
echo BUILD ABGESCHLOSSEN!
if exist "dist\windows\%APP_NAME%.exe" echo Windows: dist\windows\%APP_NAME%.exe
if exist "dist\linux\%APP_NAME%" echo Linux: dist\linux\%APP_NAME%
echo ====================================================
endlocal
exit /b 0
REM ====================================================
REM HILFSROUTINEN
REM ====================================================
:FIND_PYTHON
set "WIN_PY="
set "USING_VENV=0"
if exist ".venv\Scripts\python.exe" (
".venv\Scripts\python.exe" -m pip --version >nul 2>nul && (
set "WIN_PY=.venv\Scripts\python.exe"
set "USING_VENV=1"
)
)
if "%WIN_PY%"=="" (
where python >nul 2>nul && (
python -c "import sys, tkinter; sys.exit(0)" >nul 2>nul && set "WIN_PY=python"
)
)
if "%WIN_PY%"=="" (
where py >nul 2>nul && (
py -3 -c "import sys, tkinter; sys.exit(0)" >nul 2>nul && set "WIN_PY=py -3"
)
)
exit /b 0
:FIND_WSL_DISTRO
set "WSL_DISTRO="
where wsl.exe >nul 2>nul
if errorlevel 1 exit /b 0
for /f "usebackq delims=" %%L in (`powershell -NoProfile -Command "$d = (wsl.exe -l -q 2>$null) -replace '\x00','' | ForEach-Object { $_.Trim() } | Where-Object { $_ -and $_ -notmatch '^docker-desktop' }; if ($d) { $d | Select-Object -First 1 }"`) do (
if "!WSL_DISTRO!"=="" set "WSL_DISTRO=%%L"
)
exit /b 0

View File

@ -1,266 +0,0 @@
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
# =============================================================================
# The Goth Cardgame Collection - One-File Build Script (Linux / ChromeOS / macOS)
# Output: dist/<os>/TheGothCardgameCollection
# Usage: ./build_scripts/build.sh [--current | --all | --clean]
# =============================================================================
set -e
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${PROJECT_ROOT}"
APP_NAME="TheGothCardgameCollection"
MAIN_FILE="main.py"
RES_DIR="resources"
GAMES_DIR="games"
ICON_FILE="resources/images/game_icon.ico"
MODE="${1:---current}"
if [ "$MODE" = "--clean" ]; then
echo "🧹 Räume temporäre Build-Ordner auf..."
rm -rf build .venv_build_* *.spec
exit 0
fi
UNAME_OUT="$(uname -s)"
case "${UNAME_OUT}" in
Linux*) OS_NAME="linux" ;;
Darwin*) OS_NAME="macos" ;;
*) echo "❌ Unbekanntes Unix-System: ${UNAME_OUT}"; exit 1 ;;
esac
# ----------------------------------------------------
# 0. ROOT / SUDO RECHTE-CHECK FÜR SYSTEM-INSTALLATIONEN
# ----------------------------------------------------
NEEDS_SYS_INSTALL=0
if ! command -v python3 &>/dev/null || ! python3 -c "import tkinter" &>/dev/null; then
NEEDS_SYS_INSTALL=1
fi
if [ "$MODE" = "--all" ] && [ "$OS_NAME" = "linux" ] && ! command -v wine &>/dev/null; then
NEEDS_SYS_INSTALL=1
fi
if [ "$OS_NAME" = "linux" ] && [ "$NEEDS_SYS_INSTALL" -eq 1 ]; then
if [ "${EUID:-$(id -u)}" -ne 0 ]; then
echo "🔒 Es fehlen Systempakete (z.B. python3-tk oder wine), für deren Installation Root-Rechte nötig sind."
if command -v sudo &>/dev/null; then
echo "🔑 Fordere Root-Rechte via sudo an und starte Skript neu..."
exec sudo -E bash "$SCRIPT_PATH" "$@"
else
echo "❌ FEHLER: Keine Root-Rechte (EUID != 0) und 'sudo' ist nicht installiert!"
echo " Bitte führe das Skript als root aus: su -c '$SCRIPT_PATH $MODE'"
exit 1
fi
fi
fi
# Echten User ermitteln (wichtig, falls Skript via sudo/root läuft, damit Wine & Dateirechte stimmen!)
if [ "${EUID:-$(id -u)}" -eq 0 ] && [ -n "${SUDO_USER:-}" ]; then
REAL_USER="$SUDO_USER"
REAL_HOME="$(getent passwd "$SUDO_USER" | cut -d: -f6)"
WINE_RUNNER=(sudo -u "$REAL_USER" HOME="$REAL_HOME")
else
REAL_USER="$(whoami)"
REAL_HOME="$HOME"
WINE_RUNNER=()
fi
echo "===================================================="
echo " 🦇 Starte Build für $APP_NAME (OS: $OS_NAME | Modus: $MODE)"
echo "===================================================="
# ----------------------------------------------------
# SYSTEMPAKETE INSTALLIEREN (läuft garantiert als root!)
# ----------------------------------------------------
install_linux_pkgs() {
if command -v apt-get &>/dev/null; then
apt-get update -qq
apt-get install -y "$@"
elif command -v dnf &>/dev/null; then
dnf install -y "$@"
elif command -v yum &>/dev/null; then
yum install -y "$@"
elif command -v zypper &>/dev/null; then
zypper --non-interactive install "$@"
elif command -v pacman &>/dev/null; then
pacman -Sy --noconfirm --needed "$@"
else
echo "❌ Kein unterstützter Paketmanager (apt/dnf/yum/zypper/pacman) gefunden!"
exit 1
fi
}
if [ "$OS_NAME" = "linux" ] && { ! command -v python3 &>/dev/null || ! python3 -c "import tkinter" &>/dev/null; }; then
echo "⚙️ Installiere fehlende Python-/Tkinter-Systempakete..."
if command -v apt-get &>/dev/null; then
install_linux_pkgs python3 python3-pip python3-venv python3-tk wget
elif command -v dnf &>/dev/null || command -v yum &>/dev/null; then
install_linux_pkgs python3 python3-pip python3-tkinter wget
elif command -v zypper &>/dev/null; then
install_linux_pkgs python3 python3-pip python3-tk wget
elif command -v pacman &>/dev/null; then
install_linux_pkgs python python-pip tk wget
fi
elif [ "$OS_NAME" = "macos" ] && { ! command -v python3 &>/dev/null || ! python3 -c "import tkinter" &>/dev/null; }; then
if [ "${EUID:-$(id -u)}" -eq 0 ]; then
echo "❌ Unter macOS darf Homebrew nicht als root ausgeführt werden. Bitte ohne sudo starten."
exit 1
fi
if command -v brew &>/dev/null; then
brew install python@3.11 python-tk@3.11
else
echo "❌ Python3/Tkinter fehlt und Homebrew ist nicht installiert."
exit 1
fi
fi
# ----------------------------------------------------
# TEIL 1: LINUX / MACOS EXECUTABLE BAUEN
# ----------------------------------------------------
echo ""
echo "---> [1] Baue ${OS_NAME} Executable..."
# Defekte Venvs automatisch bereinigen
for VDIR in ".venv_build_${OS_NAME}" ".venv" "venv"; do
if [ -d "$VDIR" ] && [ ! -x "$VDIR/bin/python3" ]; then
echo "🧹 Entferne defektes Venv: $VDIR"
rm -rf "$VDIR"
fi
done
if [ -x ".venv/bin/python3" ]; then
LINUX_PY=".venv/bin/python3"
elif [ -x "venv/bin/python3" ]; then
LINUX_PY="venv/bin/python3"
else
LINUX_PY="python3"
fi
# Falls wir nicht root sind und kein Venv nutzen, pip mit --user ausführen, damit es keine Permission-Errors gibt
PIP_USER_FLAG=()
if [ "$LINUX_PY" = "python3" ] && [ "${EUID:-$(id -u)}" -ne 0 ]; then
PIP_USER_FLAG=(--user)
fi
$LINUX_PY -m pip install "${PIP_USER_FLAG[@]}" --upgrade pillow pygame pyinstaller --break-system-packages 2>/dev/null \
|| $LINUX_PY -m pip install "${PIP_USER_FLAG[@]}" --upgrade pillow pygame pyinstaller
ICON_ARG=()
[ -f "$ICON_FILE" ] && ICON_ARG=(--icon "$ICON_FILE")
$LINUX_PY -m PyInstaller \
--noconfirm \
--noconsole \
--onefile \
--clean \
--distpath "dist/${OS_NAME}" \
--workpath "build/${OS_NAME}" \
--specpath "build/${OS_NAME}" \
"${ICON_ARG[@]}" \
--add-data "${RES_DIR}:${RES_DIR}" \
--add-data "${GAMES_DIR}:${GAMES_DIR}" \
--collect-submodules games \
--collect-submodules controller \
--collect-submodules models \
--collect-submodules view \
--collect-submodules resources \
--hidden-import tkinter \
--hidden-import tkinter.ttk \
--hidden-import tkinter.font \
--hidden-import sqlite3 \
--hidden-import PIL._tkinter_finder \
--name "${APP_NAME}" \
"$MAIN_FILE"
chmod +x "dist/${OS_NAME}/${APP_NAME}"
rm -rf "build/${OS_NAME}"
echo "✔ ${OS_NAME}-Build fertig: dist/${OS_NAME}/${APP_NAME}"
# ----------------------------------------------------
# TEIL 2: WINDOWS .EXE BAUEN VIA WINE (nur bei --all unter Linux)
# ----------------------------------------------------
if [ "$MODE" = "--all" ] && [ "$OS_NAME" = "linux" ]; then
echo ""
echo "---> [2] Baue Windows .exe (via Wine)..."
if ! command -v wine &>/dev/null; then
echo "⚙️ Installiere 'wine' und 'wget' (Root-Rechte bereits geprüft)..."
if command -v apt-get &>/dev/null; then
dpkg --add-architecture amd64 2>/dev/null || true
install_linux_pkgs wine wget
else
install_linux_pkgs wine wget
fi
fi
if ! command -v wine &>/dev/null; then
echo "❌ 'wine' konnte nicht installiert werden!"
exit 1
fi
WINE_DRIVE_C="${REAL_HOME}/.wine/drive_c"
WINE_PY=$(find "$WINE_DRIVE_C" -iname "python.exe" 2>/dev/null | grep -i "Python3" | head -n 1 || true)
if [ -z "$WINE_PY" ]; then
echo "⚙️ Windows-Python in Wine (${WINE_DRIVE_C}) nicht gefunden. Installiere Python 3.11.9 automatisch..."
INSTALLER="/tmp/python-3.11.9-amd64.exe"
if [ ! -f "$INSTALLER" ]; then
wget -O "$INSTALLER" https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe
fi
"${WINE_RUNNER[@]}" wine "$INSTALLER" /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
"${WINE_RUNNER[@]}" wineserver -w || true
rm -f "$INSTALLER"
WINE_PY=$(find "$WINE_DRIVE_C" -iname "python.exe" 2>/dev/null | grep -i "Python3" | head -n 1 || true)
fi
if [ -z "$WINE_PY" ]; then
echo "❌ Konnte python.exe in ${WINE_DRIVE_C} nicht finden!"
exit 1
fi
echo "✔ Nutze Wine-Python: $WINE_PY"
"${WINE_RUNNER[@]}" wine "$WINE_PY" -m pip install --upgrade pip pillow pygame pyinstaller
"${WINE_RUNNER[@]}" wine "$WINE_PY" -m PyInstaller \
--noconfirm \
--noconsole \
--onefile \
--clean \
--distpath "dist/windows" \
--workpath "build/windows" \
--specpath "build/windows" \
"${ICON_ARG[@]}" \
--add-data "${RES_DIR};${RES_DIR}" \
--add-data "${GAMES_DIR};${GAMES_DIR}" \
--collect-submodules games \
--collect-submodules controller \
--collect-submodules models \
--collect-submodules view \
--collect-submodules resources \
--hidden-import tkinter \
--hidden-import tkinter.ttk \
--hidden-import tkinter.font \
--hidden-import sqlite3 \
--hidden-import PIL._tkinter_finder \
--name "${APP_NAME}" \
"$MAIN_FILE"
rm -rf "build/windows"
echo "✔ Windows-Build fertig: dist/windows/${APP_NAME}.exe"
fi
# Falls via sudo gestartet, Besitzrechte von dist/ wieder auf den normalen User übertragen
if [ "${EUID:-$(id -u)}" -eq 0 ] && [ -n "${SUDO_USER:-}" ]; then
chown -R "$SUDO_USER:$SUDO_USER" dist/ 2>/dev/null || true
fi
echo ""
echo "===================================================="
echo " ✅ BUILD ERFOLGREICH ABGESCHLOSSEN!"
[ -f "dist/${OS_NAME}/${APP_NAME}" ] && echo " 🐧 ${OS_NAME}-Version: dist/${OS_NAME}/${APP_NAME}"
[ -f "dist/windows/${APP_NAME}.exe" ] && echo " 🪟 Windows-Version: dist/windows/${APP_NAME}.exe"
echo "===================================================="