478 lines
17 KiB
Batchfile
478 lines
17 KiB
Batchfile
@echo off
|
|
setlocal EnableDelayedExpansion
|
|
REM =============================================================================
|
|
REM The Goth Cardgame Collection - Multi-Target Build Script (Windows + VBox VMs)
|
|
REM Ablageort: build_scripts\build.bat
|
|
REM Targets: --Win | --Unix | --OSX | --current | --all | --clean
|
|
REM =============================================================================
|
|
|
|
REM --- Konfiguration fuer deine VirtualBox Linux-VM (--Unix) ---
|
|
set "UNIX_VM_NAME=UbuntuClient02"
|
|
set "UNIX_SSH_HOST=192.168.0.126"
|
|
set "UNIX_SSH_PORT=22"
|
|
set "UNIX_SSH_USER=kuro"
|
|
set "UNIX_REMOTE_DIR=~/the_goth_cardgame_collection_build"
|
|
|
|
REM --- Konfiguration fuer deine VirtualBox macOS-VM (--OSX) ---
|
|
set "OSX_VM_NAME=macOS"
|
|
set "OSX_SSH_HOST=192.168.0.158"
|
|
set "OSX_SSH_PORT=22"
|
|
set "OSX_SSH_USER=kuro"
|
|
set "OSX_REMOTE_DIR=~/the_goth_cardgame_collection_build"
|
|
|
|
set "SCRIPT_FILE=%~f0"
|
|
cd /d "%~dp0.."
|
|
set "PROJECT_ROOT=%CD%"
|
|
set "APP_NAME=TheGothCardgameCollection"
|
|
|
|
REM --- Parameter parsen (beliebig kombinierbar, case-insensitive) ---
|
|
set "DO_WIN=0"
|
|
set "DO_UNIX=0"
|
|
set "DO_OSX=0"
|
|
set "DO_CLEAN=0"
|
|
set "IS_ELEVATED=0"
|
|
set "RAW_ARGS="
|
|
|
|
:PARSE_ARGS
|
|
if "%~1"=="" goto :ARGS_DONE
|
|
if /I "%~1"=="--elevated" (
|
|
set "IS_ELEVATED=1"
|
|
shift
|
|
goto :PARSE_ARGS
|
|
)
|
|
set "RAW_ARGS=!RAW_ARGS! %~1"
|
|
if /I "%~1"=="--clean" set "DO_CLEAN=1"
|
|
if /I "%~1"=="--current" set "DO_WIN=1"
|
|
if /I "%~1"=="--win" set "DO_WIN=1"
|
|
if /I "%~1"=="--unix" set "DO_UNIX=1"
|
|
if /I "%~1"=="--linux" set "DO_UNIX=1"
|
|
if /I "%~1"=="--osx" set "DO_OSX=1"
|
|
if /I "%~1"=="--macos" set "DO_OSX=1"
|
|
if /I "%~1"=="--all" (
|
|
set "DO_WIN=1"
|
|
set "DO_UNIX=1"
|
|
set "DO_OSX=1"
|
|
)
|
|
shift
|
|
goto :PARSE_ARGS
|
|
:ARGS_DONE
|
|
|
|
if "%DO_CLEAN%"=="1" (
|
|
if exist "%PROJECT_ROOT%\build" rmdir /s /q "%PROJECT_ROOT%\build"
|
|
if exist "%PROJECT_ROOT%\.venv_build_win" rmdir /s /q "%PROJECT_ROOT%\.venv_build_win"
|
|
del /q "%PROJECT_ROOT%\*.spec" 2>nul
|
|
echo [OK] Temporaere Build-Dateien bereinigt.
|
|
exit /b 0
|
|
)
|
|
|
|
REM Nur wenn GAR KEIN Ziel angegeben wurde -> Standard --Win
|
|
if "%DO_WIN%"=="0" if "%DO_UNIX%"=="0" if "%DO_OSX%"=="0" (
|
|
set "DO_WIN=1"
|
|
set "RAW_ARGS=--Win"
|
|
)
|
|
|
|
REM ----------------------------------------------------
|
|
REM 0. RECHTE- & ABHAENGIGKEITS-PRUEFUNG (nur fuer --Win noetig!)
|
|
REM ----------------------------------------------------
|
|
set "IS_ADMIN=0"
|
|
net session >nul 2>nul
|
|
if not errorlevel 1 set "IS_ADMIN=1"
|
|
|
|
if exist "%PROJECT_ROOT%\.venv_build_win" (
|
|
if not exist "%PROJECT_ROOT%\.venv_build_win\Scripts\python.exe" rmdir /s /q "%PROJECT_ROOT%\.venv_build_win"
|
|
)
|
|
|
|
set "NEEDS_SETUP=0"
|
|
if "%DO_WIN%"=="1" (
|
|
call :FIND_PYTHON
|
|
if "!WIN_PY!"=="" (
|
|
set "NEEDS_SETUP=1"
|
|
) else (
|
|
!WIN_PY! -c "import pip, PIL, pygame, PyInstaller, tkinter" >nul 2>nul
|
|
if errorlevel 1 set "NEEDS_SETUP=1"
|
|
)
|
|
)
|
|
|
|
if "%NEEDS_SETUP%"=="1" if "%IS_ADMIN%"=="0" (
|
|
echo ====================================================
|
|
echo [RECHTE-CHECK] Fehlende Windows-Pakete erkannt!
|
|
echo Fordere Administrator-Rechte ueber Windows-UAC an...
|
|
echo ====================================================
|
|
if "%IS_ELEVATED%"=="1" (
|
|
echo [ERROR] Administrator-Freigabe fehlgeschlagen.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
powershell -NoProfile -Command "Start-Process -FilePath 'cmd.exe' -ArgumentList '/k \"\"%SCRIPT_FILE%\" %RAW_ARGS% --elevated\"' -Verb RunAs"
|
|
exit /b 0
|
|
)
|
|
|
|
echo ====================================================
|
|
echo Starte Build fuer %APP_NAME%
|
|
echo Ziele: Win=%DO_WIN% ^| Unix=%DO_UNIX% ^| OSX=%DO_OSX% ^(Admin: %IS_ADMIN%^)
|
|
echo ====================================================
|
|
|
|
if "%IS_ADMIN%"=="1" (
|
|
for /d %%G in ("C:\Python311\Lib\site-packages\~*") do rmdir /s /q "%%~G" 2>nul
|
|
)
|
|
|
|
REM ----------------------------------------------------
|
|
REM STAMMDATENBANK VORAB FRISCH BAUEN (fuer Win + VM-Tarballs)
|
|
REM ----------------------------------------------------
|
|
set "DB_REBUILT=0"
|
|
call :FIND_PYTHON
|
|
if not "!WIN_PY!"=="" (
|
|
call :REBUILD_INTERNAL_DB
|
|
if errorlevel 1 (
|
|
echo [ERROR] Erstellung von internal_base.db fehlgeschlagen!
|
|
if "%IS_ELEVATED%"=="1" pause
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
REM ====================================================
|
|
REM ZIEL 1: WINDOWS (--Win)
|
|
REM ====================================================
|
|
if "%DO_WIN%"=="1" (
|
|
echo.
|
|
echo ---^> [WIN] Baue Windows Single-File .exe...
|
|
call :FIND_PYTHON
|
|
if "!WIN_PY!"=="" (
|
|
echo [BOOTSTRAP] Installiere Python 3.11 via winget...
|
|
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+ nicht gefunden!
|
|
exit /b 1
|
|
)
|
|
|
|
if "!DB_REBUILT!"=="0" (
|
|
call :REBUILD_INTERNAL_DB
|
|
if errorlevel 1 (
|
|
echo [ERROR] Erstellung von internal_base.db fehlgeschlagen!
|
|
if "%IS_ELEVATED%"=="1" pause
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
!WIN_PY! -m pip --version >nul 2>nul
|
|
if errorlevel 1 !WIN_PY! -m ensurepip --upgrade
|
|
|
|
!WIN_PY! -c "import PIL, pygame, PyInstaller" >nul 2>nul
|
|
if errorlevel 1 (
|
|
echo [BOOTSTRAP] Installiere Pillow, Pygame ^& PyInstaller...
|
|
!WIN_PY! -m pip install --upgrade pip pillow pygame pyinstaller
|
|
if errorlevel 1 exit /b 1
|
|
)
|
|
|
|
set "ICON_ARG="
|
|
if exist "%PROJECT_ROOT%\resources\images\game_icon.ico" (
|
|
set "ICON_ARG=--icon %PROJECT_ROOT%\resources\images\game_icon.ico"
|
|
)
|
|
|
|
!WIN_PY! -m PyInstaller ^
|
|
--noconfirm ^
|
|
--noconsole ^
|
|
--onefile ^
|
|
--clean ^
|
|
--distpath "%PROJECT_ROOT%\dist\windows" ^
|
|
--workpath "%PROJECT_ROOT%\build\windows" ^
|
|
--specpath "%PROJECT_ROOT%\build\windows" ^
|
|
!ICON_ARG! ^
|
|
--add-data "%PROJECT_ROOT%\resources;resources" ^
|
|
--add-data "%PROJECT_ROOT%\games;games" ^
|
|
--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%" ^
|
|
"%PROJECT_ROOT%\main.py"
|
|
|
|
if errorlevel 1 (
|
|
echo [ERROR] Windows-Build fehlgeschlagen!
|
|
if "%IS_ELEVATED%"=="1" pause
|
|
exit /b 1
|
|
)
|
|
if exist "%PROJECT_ROOT%\build\windows" rmdir /s /q "%PROJECT_ROOT%\build\windows"
|
|
echo [OK] Windows-Build fertig: dist\windows\%APP_NAME%.exe
|
|
)
|
|
|
|
REM ====================================================
|
|
REM ZIEL 2: LINUX / UNIX VIA VIRTUALBOX VM (--Unix)
|
|
REM ====================================================
|
|
if "%DO_UNIX%"=="1" (
|
|
echo.
|
|
echo ---^> [UNIX] Baue Linux Executable via VirtualBox VM "%UNIX_VM_NAME%"...
|
|
call :RUN_UNIX_VM_BUILD
|
|
)
|
|
|
|
REM ====================================================
|
|
REM ZIEL 3: MACOS / OSX VIA VIRTUALBOX VM (--OSX)
|
|
REM ====================================================
|
|
if "%DO_OSX%"=="1" (
|
|
echo.
|
|
echo ---^> [OSX] Baue macOS Binary via VirtualBox VM "%OSX_VM_NAME%"...
|
|
call :RUN_OSX_VM_BUILD
|
|
)
|
|
|
|
echo.
|
|
echo ====================================================
|
|
echo BUILD-ZUSAMMENFASSUNG ^(nur angeforderte Ziele^):
|
|
if "%DO_WIN%"=="1" (
|
|
if exist "%PROJECT_ROOT%\dist\windows\%APP_NAME%.exe" (
|
|
echo [WIN] OK: dist\windows\%APP_NAME%.exe
|
|
) else (
|
|
echo [WIN] FEHLGESCHLAGEN
|
|
)
|
|
)
|
|
if "%DO_UNIX%"=="1" (
|
|
if exist "%PROJECT_ROOT%\dist\linux\%APP_NAME%" (
|
|
echo [UNIX] OK: dist\linux\%APP_NAME% ^(+ %APP_NAME%_Linux.tar.gz^)
|
|
) else (
|
|
echo [UNIX] FEHLGESCHLAGEN
|
|
)
|
|
)
|
|
if "%DO_OSX%"=="1" (
|
|
if exist "%PROJECT_ROOT%\dist\macos\%APP_NAME%" (
|
|
echo [OSX] OK: dist\macos\%APP_NAME% ^(+ %APP_NAME%.app + %APP_NAME%_macOS.tar.gz^)
|
|
) else (
|
|
echo [OSX] FEHLGESCHLAGEN
|
|
)
|
|
)
|
|
echo ====================================================
|
|
if "%IS_ELEVATED%"=="1" pause
|
|
endlocal
|
|
exit /b 0
|
|
|
|
|
|
REM ====================================================
|
|
REM HILFSROUTINEN
|
|
REM ====================================================
|
|
:REBUILD_INTERNAL_DB
|
|
set "REBUILD_PY="
|
|
if exist "%PROJECT_ROOT%\build_scripts\rebuild_internal_db.py" (
|
|
set "REBUILD_PY=%PROJECT_ROOT%\build_scripts\rebuild_internal_db.py"
|
|
)
|
|
if exist "%PROJECT_ROOT%\rebuild_internal_db.py" (
|
|
set "REBUILD_PY=%PROJECT_ROOT%\rebuild_internal_db.py"
|
|
)
|
|
if not "!REBUILD_PY!"=="" if exist "%PROJECT_ROOT%\resources\code_res\sql" (
|
|
echo ---^> [DB] Aktualisiere internal_base.db aus modularen SQL-Dateien...
|
|
!WIN_PY! "!REBUILD_PY!"
|
|
if errorlevel 1 exit /b 1
|
|
set "DB_REBUILT=1"
|
|
)
|
|
exit /b 0
|
|
|
|
:FIND_PYTHON
|
|
set "WIN_PY="
|
|
if exist "%PROJECT_ROOT%\.venv\Scripts\python.exe" (
|
|
"%PROJECT_ROOT%\.venv\Scripts\python.exe" -m pip --version >nul 2>nul && (
|
|
set "WIN_PY=%PROJECT_ROOT%\.venv\Scripts\python.exe"
|
|
exit /b 0
|
|
)
|
|
)
|
|
where python >nul 2>nul && (
|
|
python -c "import sys, tkinter; sys.exit(0)" >nul 2>nul && (
|
|
set "WIN_PY=python"
|
|
exit /b 0
|
|
)
|
|
)
|
|
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
|
|
)
|
|
)
|
|
for %%D in ("C:\Python311\python.exe" "C:\Python312\python.exe" "%ProgramFiles%\Python311\python.exe" "%LocalAppData%\Programs\Python\Python311\python.exe") do (
|
|
if exist %%D (
|
|
%%D -c "import sys, tkinter; sys.exit(0)" >nul 2>nul && (
|
|
set "WIN_PY=%%D"
|
|
exit /b 0
|
|
)
|
|
)
|
|
)
|
|
exit /b 0
|
|
|
|
:FIND_VBOX
|
|
set "VBOX_MANAGE="
|
|
where VBoxManage.exe >nul 2>nul && set "VBOX_MANAGE=VBoxManage.exe"
|
|
if "!VBOX_MANAGE!"=="" if exist "%ProgramFiles%\Oracle\VirtualBox\VBoxManage.exe" (
|
|
set "VBOX_MANAGE=%ProgramFiles%\Oracle\VirtualBox\VBoxManage.exe"
|
|
)
|
|
if "!VBOX_MANAGE!"=="" if exist "D:\Program Files\Oracle\VirtualBox\VBoxManage.exe" (
|
|
set "VBOX_MANAGE=D:\Program Files\Oracle\VirtualBox\VBoxManage.exe"
|
|
)
|
|
exit /b 0
|
|
|
|
:RUN_UNIX_VM_BUILD
|
|
call :FIND_VBOX
|
|
if "!VBOX_MANAGE!"=="" (
|
|
echo [SKIP] VBoxManage.exe nicht gefunden - ueberspringe Linux-VM-Build.
|
|
exit /b 1
|
|
)
|
|
|
|
"!VBOX_MANAGE!" showvminfo "%UNIX_VM_NAME%" >nul 2>nul
|
|
if errorlevel 1 (
|
|
echo [ERROR] VirtualBox-VM "%UNIX_VM_NAME%" nicht gefunden!
|
|
exit /b 1
|
|
)
|
|
|
|
set "UNIX_VM_WAS_RUNNING=0"
|
|
"!VBOX_MANAGE!" list runningvms | findstr /I "\"%UNIX_VM_NAME%\"" >nul 2>nul
|
|
if not errorlevel 1 set "UNIX_VM_WAS_RUNNING=1"
|
|
|
|
if "!UNIX_VM_WAS_RUNNING!"=="0" (
|
|
echo [UNIX-VM] Starte VirtualBox-VM "%UNIX_VM_NAME%" im Headless-Modus...
|
|
"!VBOX_MANAGE!" startvm "%UNIX_VM_NAME%" --type headless
|
|
if errorlevel 1 (
|
|
echo [ERROR] Konnte VM "%UNIX_VM_NAME%" nicht starten!
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
echo [UNIX-VM] Warte auf SSH-Verbindung ^(%UNIX_SSH_USER%@%UNIX_SSH_HOST%:%UNIX_SSH_PORT%^)...
|
|
set "UNIX_SSH_READY=0"
|
|
for /L %%I in (1,1,30) do (
|
|
if "!UNIX_SSH_READY!"=="0" (
|
|
ssh -p %UNIX_SSH_PORT% -o BatchMode=yes -o ConnectTimeout=3 -o StrictHostKeyChecking=accept-new %UNIX_SSH_USER%@%UNIX_SSH_HOST% "echo ready" >nul 2>nul
|
|
if not errorlevel 1 (
|
|
set "UNIX_SSH_READY=1"
|
|
) else (
|
|
timeout /t 3 /nobreak >nul
|
|
)
|
|
)
|
|
)
|
|
|
|
if "!UNIX_SSH_READY!"=="0" (
|
|
echo [ERROR] Keine passwortlose SSH-Verbindung zu %UNIX_SSH_USER%@%UNIX_SSH_HOST%:%UNIX_SSH_PORT% moeglich.
|
|
if "!UNIX_VM_WAS_RUNNING!"=="0" "!VBOX_MANAGE!" controlvm "%UNIX_VM_NAME%" acpipowerbutton >nul 2>nul
|
|
exit /b 1
|
|
)
|
|
|
|
echo [UNIX-VM] Aktualisiere Projektquellen in "%UNIX_VM_NAME%"...
|
|
set "TMP_TAR_UNIX=%TEMP%\goth_unix_src.tar.gz"
|
|
if exist "!TMP_TAR_UNIX!" del /q "!TMP_TAR_UNIX!"
|
|
tar -czf "!TMP_TAR_UNIX!" --exclude=".git" --exclude="dist" --exclude="build" --exclude=".venv*" --exclude="__pycache__" -C "%PROJECT_ROOT%" .
|
|
|
|
ssh -p %UNIX_SSH_PORT% %UNIX_SSH_USER%@%UNIX_SSH_HOST% "mkdir -p %UNIX_REMOTE_DIR% && find %UNIX_REMOTE_DIR% -mindepth 1 -maxdepth 1 ! -name '.venv' -exec rm -rf {} +"
|
|
scp -P %UNIX_SSH_PORT% "!TMP_TAR_UNIX!" %UNIX_SSH_USER%@%UNIX_SSH_HOST%:%UNIX_REMOTE_DIR%/src.tar.gz
|
|
del /q "!TMP_TAR_UNIX!" 2>nul
|
|
|
|
echo [UNIX-VM] Kompiliere native Linux-ELF-Binary in der VM...
|
|
ssh -t -p %UNIX_SSH_PORT% %UNIX_SSH_USER%@%UNIX_SSH_HOST% "cd %UNIX_REMOTE_DIR% && tar -xzf src.tar.gz && rm -f src.tar.gz && tr -d '\r' < build_scripts/build.sh > build_scripts/_unix.sh && mv build_scripts/_unix.sh build_scripts/build.sh && chmod +x build_scripts/build.sh && ( [ -d .venv ] || python3 -m venv .venv || (sudo apt-get update -qq && sudo apt-get install -y python3-venv python3-tk python3-pip libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libfreetype6-dev && python3 -m venv .venv) ) && ./build_scripts/build.sh --Unix && tar --warning=no-file-changed -czf dist/%APP_NAME%_Linux.tar.gz -C dist/linux ."
|
|
|
|
if errorlevel 1 (
|
|
echo [ERROR] Linux-Build in der VM fehlgeschlagen!
|
|
if "!UNIX_VM_WAS_RUNNING!"=="0" "!VBOX_MANAGE!" controlvm "%UNIX_VM_NAME%" acpipowerbutton >nul 2>nul
|
|
exit /b 1
|
|
)
|
|
|
|
if exist "%PROJECT_ROOT%\dist\linux" rmdir /s /q "%PROJECT_ROOT%\dist\linux"
|
|
mkdir "%PROJECT_ROOT%\dist\linux"
|
|
|
|
echo [UNIX-VM] Lade fertiges Linux-Build nach dist\linux herunter...
|
|
scp -P %UNIX_SSH_PORT% %UNIX_SSH_USER%@%UNIX_SSH_HOST%:%UNIX_REMOTE_DIR%/dist/%APP_NAME%_Linux.tar.gz "%PROJECT_ROOT%\dist\linux\%APP_NAME%_Linux.tar.gz"
|
|
if errorlevel 1 (
|
|
echo [ERROR] Download des Linux-Artefakts fehlgeschlagen!
|
|
exit /b 1
|
|
)
|
|
tar -xzf "%PROJECT_ROOT%\dist\linux\%APP_NAME%_Linux.tar.gz" -C "%PROJECT_ROOT%\dist\linux"
|
|
|
|
if "!UNIX_VM_WAS_RUNNING!"=="0" (
|
|
echo [UNIX-VM] Fahre Linux-VM wieder sauber herunter...
|
|
"!VBOX_MANAGE!" controlvm "%UNIX_VM_NAME%" acpipowerbutton >nul 2>nul
|
|
)
|
|
echo [OK] Linux-Build fertig unter: dist\linux\
|
|
exit /b 0
|
|
|
|
:RUN_OSX_VM_BUILD
|
|
call :FIND_VBOX
|
|
if "!VBOX_MANAGE!"=="" (
|
|
echo [SKIP] VBoxManage.exe nicht gefunden - ueberspringe macOS-VM-Build.
|
|
exit /b 1
|
|
)
|
|
|
|
"!VBOX_MANAGE!" showvminfo "%OSX_VM_NAME%" >nul 2>nul
|
|
if errorlevel 1 (
|
|
echo [ERROR] VirtualBox-VM "%OSX_VM_NAME%" nicht gefunden!
|
|
exit /b 1
|
|
)
|
|
|
|
set "VM_WAS_RUNNING=0"
|
|
"!VBOX_MANAGE!" list runningvms | findstr /I "\"%OSX_VM_NAME%\"" >nul 2>nul
|
|
if not errorlevel 1 set "VM_WAS_RUNNING=1"
|
|
|
|
if "!VM_WAS_RUNNING!"=="0" (
|
|
echo [OSX-VM] Starte VirtualBox-VM "%OSX_VM_NAME%" im Headless-Modus...
|
|
"!VBOX_MANAGE!" startvm "%OSX_VM_NAME%" --type headless
|
|
if errorlevel 1 (
|
|
echo [ERROR] Konnte VM "%OSX_VM_NAME%" nicht starten!
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
echo [OSX-VM] Warte auf SSH-Verbindung ^(%OSX_SSH_USER%@%OSX_SSH_HOST%:%OSX_SSH_PORT%^)...
|
|
set "SSH_READY=0"
|
|
for /L %%I in (1,1,30) do (
|
|
if "!SSH_READY!"=="0" (
|
|
ssh -p %OSX_SSH_PORT% -o BatchMode=yes -o ConnectTimeout=3 -o StrictHostKeyChecking=accept-new %OSX_SSH_USER%@%OSX_SSH_HOST% "echo ready" >nul 2>nul
|
|
if not errorlevel 1 (
|
|
set "SSH_READY=1"
|
|
) else (
|
|
timeout /t 4 /nobreak >nul
|
|
)
|
|
)
|
|
)
|
|
|
|
if "!SSH_READY!"=="0" (
|
|
echo [ERROR] Keine passwortlose SSH-Verbindung zu %OSX_SSH_USER%@%OSX_SSH_HOST%:%OSX_SSH_PORT% moeglich.
|
|
if "!VM_WAS_RUNNING!"=="0" "!VBOX_MANAGE!" controlvm "%OSX_VM_NAME%" acpipowerbutton >nul 2>nul
|
|
exit /b 1
|
|
)
|
|
|
|
echo [OSX-VM] Aktualisiere Projektquellen in der macOS-VM ^(.venv_build_macos bleibt gecached!^)...
|
|
set "TMP_TAR=%TEMP%\goth_osx_src.tar.gz"
|
|
if exist "!TMP_TAR!" del /q "!TMP_TAR!"
|
|
tar -czf "!TMP_TAR!" --exclude=".git" --exclude="dist" --exclude="build" --exclude=".venv*" --exclude="__pycache__" -C "%PROJECT_ROOT%" .
|
|
|
|
ssh -p %OSX_SSH_PORT% %OSX_SSH_USER%@%OSX_SSH_HOST% "mkdir -p %OSX_REMOTE_DIR% && find %OSX_REMOTE_DIR% -mindepth 1 -maxdepth 1 ! -name '.venv_build_macos' -exec rm -rf {} +"
|
|
scp -P %OSX_SSH_PORT% "!TMP_TAR!" %OSX_SSH_USER%@%OSX_SSH_HOST%:%OSX_REMOTE_DIR%/src.tar.gz
|
|
del /q "!TMP_TAR!" 2>nul
|
|
|
|
echo [OSX-VM] Kompiliere native macOS-Binary + .app Bundle in der VM...
|
|
ssh -p %OSX_SSH_PORT% %OSX_SSH_USER%@%OSX_SSH_HOST% "export PATH=/Library/Frameworks/Python.framework/Versions/3.11/bin:/opt/homebrew/bin:/usr/local/bin:$PATH; cd %OSX_REMOTE_DIR% && tar -xzf src.tar.gz && rm -f src.tar.gz && tr -d '\r' < build_scripts/build.sh > build_scripts/_osx.sh && mv build_scripts/_osx.sh build_scripts/build.sh && chmod +x build_scripts/build.sh && ./build_scripts/build.sh --OSX && tar -czf dist/macos/%APP_NAME%_macOS.tar.gz -C dist/macos ."
|
|
if errorlevel 1 (
|
|
echo [ERROR] macOS-Build in der VM fehlgeschlagen!
|
|
if "!VM_WAS_RUNNING!"=="0" "!VBOX_MANAGE!" controlvm "%OSX_VM_NAME%" acpipowerbutton >nul 2>nul
|
|
exit /b 1
|
|
)
|
|
|
|
if exist "%PROJECT_ROOT%\dist\macos" rmdir /s /q "%PROJECT_ROOT%\dist\macos"
|
|
mkdir "%PROJECT_ROOT%\dist\macos"
|
|
|
|
echo [OSX-VM] Lade fertiges macOS-Build nach dist\macos herunter...
|
|
scp -P %OSX_SSH_PORT% %OSX_SSH_USER%@%OSX_SSH_HOST%:%OSX_REMOTE_DIR%/dist/macos/%APP_NAME%_macOS.tar.gz "%PROJECT_ROOT%\dist\macos\%APP_NAME%_macOS.tar.gz"
|
|
if errorlevel 1 (
|
|
echo [ERROR] Download des macOS-Artefakts fehlgeschlagen!
|
|
exit /b 1
|
|
)
|
|
tar -xzf "%PROJECT_ROOT%\dist\macos\%APP_NAME%_macOS.tar.gz" -C "%PROJECT_ROOT%\dist\macos"
|
|
|
|
if "!VM_WAS_RUNNING!"=="0" (
|
|
echo [OSX-VM] Fahre macOS-VM wieder sauber herunter...
|
|
"!VBOX_MANAGE!" controlvm "%OSX_VM_NAME%" acpipowerbutton >nul 2>nul
|
|
)
|
|
echo [OK] macOS-Build fertig unter: dist\macos\
|
|
exit /b 0
|