184 lines
6.4 KiB
PowerShell
184 lines
6.4 KiB
PowerShell
Write-Host "AZA Desktop EXE Build gestartet..."
|
|
|
|
$projectRoot = $PSScriptRoot
|
|
$specFile = Join-Path $projectRoot "aza_desktop.spec"
|
|
|
|
Set-Location $projectRoot
|
|
|
|
# --- Pre-Build-Validierung: Produktivwerte pruefen ---
|
|
Write-Host ""
|
|
Write-Host "Pre-Build-Validierung..."
|
|
|
|
$urlFile = Join-Path $projectRoot "backend_url.txt"
|
|
if (-not (Test-Path $urlFile)) {
|
|
Write-Error "ABBRUCH: backend_url.txt nicht gefunden. Datei muss die produktive Backend-URL enthalten."
|
|
exit 1
|
|
}
|
|
$urlContent = (Get-Content $urlFile -Raw).Trim()
|
|
if ($urlContent -match "127\.0\.0\.1|localhost|0\.0\.0\.0") {
|
|
Write-Error "ABBRUCH: backend_url.txt enthaelt eine lokale Adresse ($urlContent). Bitte auf die produktive URL setzen (z.B. https://api.aza-medwork.ch)."
|
|
exit 1
|
|
}
|
|
if (-not $urlContent) {
|
|
Write-Error "ABBRUCH: backend_url.txt ist leer. Bitte die produktive Backend-URL eintragen."
|
|
exit 1
|
|
}
|
|
Write-Host " backend_url.txt OK: $urlContent"
|
|
|
|
$tokenFile = Join-Path $projectRoot "backend_token.txt"
|
|
if (-not (Test-Path $tokenFile)) {
|
|
Write-Error "ABBRUCH: backend_token.txt nicht gefunden. Datei muss den produktiven API-Token enthalten."
|
|
exit 1
|
|
}
|
|
$tokenContent = (Get-Content $tokenFile -Raw).Trim()
|
|
if (-not $tokenContent) {
|
|
Write-Error "ABBRUCH: backend_token.txt ist leer. Bitte den produktiven API-Token eintragen."
|
|
exit 1
|
|
}
|
|
if ($tokenContent -match "CHANGE_ME") {
|
|
Write-Error "ABBRUCH: backend_token.txt enthaelt einen Platzhalter ($tokenContent). Bitte den echten produktiven Token eintragen."
|
|
exit 1
|
|
}
|
|
Write-Host " backend_token.txt OK (Token vorhanden, kein Platzhalter)"
|
|
Write-Host ""
|
|
|
|
Write-Host "Build-Stamp erzeugen (_build_info.py)..."
|
|
python (Join-Path $projectRoot "aza_build_stamp.py")
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Warning "Build-Stamp konnte nicht erzeugt werden - fahre trotzdem fort."
|
|
}
|
|
|
|
Write-Host "version.json aus aza_version.py + _build_info.py synchronisieren..."
|
|
python -c @"
|
|
import json
|
|
from pathlib import Path
|
|
root = Path(r'$projectRoot')
|
|
info = {}
|
|
exec((root / '_build_info.py').read_text(encoding='utf-8'), info)
|
|
from aza_version import APP_VERSION, APP_CHANNEL
|
|
payload = {
|
|
'version': APP_VERSION,
|
|
'build': info.get('BUILD_TIMESTAMP', ''),
|
|
'channel': APP_CHANNEL,
|
|
'app': 'AZA Desktop',
|
|
}
|
|
(root / 'version.json').write_text(json.dumps(payload, indent=2) + '\n', encoding='utf-8')
|
|
print(' version.json ->', payload['version'], payload['build'])
|
|
"@
|
|
|
|
Write-Host "PyInstaller Installation pruefen..."
|
|
pip install pyinstaller --quiet
|
|
|
|
Write-Host "Alte Build-Artefakte werden bereinigt..."
|
|
if (Test-Path (Join-Path $projectRoot "build")) {
|
|
Remove-Item (Join-Path $projectRoot "build") -Recurse -Force
|
|
}
|
|
if (Test-Path (Join-Path $projectRoot "dist\aza_desktop")) {
|
|
Remove-Item (Join-Path $projectRoot "dist\aza_desktop") -Recurse -Force
|
|
}
|
|
|
|
Write-Host "EXE wird aus aza_desktop.spec gebaut..."
|
|
pyinstaller --noconfirm $specFile
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "PyInstaller Build fehlgeschlagen."
|
|
exit 1
|
|
}
|
|
|
|
$exePath = Join-Path $projectRoot "dist\aza_desktop\aza_desktop.exe"
|
|
if (-not (Test-Path $exePath)) {
|
|
Write-Error "Build wurde beendet, aber die EXE wurde nicht gefunden: $exePath"
|
|
exit 1
|
|
}
|
|
|
|
$distRoot = Join-Path $projectRoot "dist\aza_desktop"
|
|
|
|
Write-Host "Empfang Web-Shell (AZA_EmpfangShell.exe) bauen..."
|
|
$shellSpec = Join-Path $projectRoot "AZA_EmpfangShell.spec"
|
|
pyinstaller --noconfirm $shellSpec
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "PyInstaller Build AZA_EmpfangShell fehlgeschlagen."
|
|
exit 1
|
|
}
|
|
$shellExeBuilt = Join-Path $projectRoot "dist\AZA_EmpfangShell.exe"
|
|
if (-not (Test-Path $shellExeBuilt)) {
|
|
Write-Error "AZA_EmpfangShell.exe nicht gefunden: $shellExeBuilt"
|
|
exit 1
|
|
}
|
|
Copy-Item $shellExeBuilt (Join-Path $distRoot "AZA_EmpfangShell.exe") -Force
|
|
Write-Host " AZA_EmpfangShell.exe -> dist\aza_desktop\ kopiert"
|
|
|
|
Write-Host "AzA Startpanel (aza_start_panel.exe) bauen..."
|
|
$panelSpec = Join-Path $projectRoot "aza_start_panel.spec"
|
|
pyinstaller --noconfirm $panelSpec
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "PyInstaller Build aza_start_panel fehlgeschlagen."
|
|
exit 1
|
|
}
|
|
$panelExeBuilt = Join-Path $projectRoot "dist\aza_start_panel.exe"
|
|
if (-not (Test-Path $panelExeBuilt)) {
|
|
Write-Error "aza_start_panel.exe nicht gefunden: $panelExeBuilt"
|
|
exit 1
|
|
}
|
|
Copy-Item $panelExeBuilt (Join-Path $distRoot "aza_start_panel.exe") -Force
|
|
Write-Host " aza_start_panel.exe -> dist\aza_desktop\ kopiert"
|
|
|
|
Write-Host "AZA Updater (aza_updater.exe) bauen..."
|
|
$updaterSpec = Join-Path $projectRoot "aza_updater.spec"
|
|
pyinstaller --noconfirm $updaterSpec
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "PyInstaller Build aza_updater fehlgeschlagen."
|
|
exit 1
|
|
}
|
|
$updaterExeBuilt = Join-Path $projectRoot "dist\aza_updater.exe"
|
|
if (-not (Test-Path $updaterExeBuilt)) {
|
|
Write-Error "aza_updater.exe nicht gefunden: $updaterExeBuilt"
|
|
exit 1
|
|
}
|
|
Copy-Item $updaterExeBuilt (Join-Path $distRoot "aza_updater.exe") -Force
|
|
Write-Host " aza_updater.exe -> dist\aza_desktop\ kopiert"
|
|
|
|
$versionJson = Join-Path $projectRoot "version.json"
|
|
if (Test-Path $versionJson) {
|
|
Copy-Item $versionJson (Join-Path $distRoot "version.json") -Force
|
|
Write-Host " version.json -> dist\aza_desktop\ kopiert"
|
|
}
|
|
|
|
$assetsSrc = Join-Path $projectRoot "assets"
|
|
$assetsDest = Join-Path $distRoot "assets"
|
|
if (Test-Path $assetsSrc) {
|
|
if (Test-Path $assetsDest) {
|
|
Remove-Item $assetsDest -Recurse -Force
|
|
}
|
|
Copy-Item $assetsSrc $assetsDest -Recurse -Force
|
|
Write-Host " assets\ -> dist\aza_desktop\ kopiert"
|
|
}
|
|
|
|
# backend_url.txt und backend_token.txt auch im dist-Root ablegen (neben der EXE),
|
|
# damit Installer und Runtime sie zuverlaessig finden.
|
|
$internalDir = Join-Path $distRoot "_internal"
|
|
foreach ($cfgFile in @("backend_url.txt", "backend_token.txt")) {
|
|
$src = Join-Path $internalDir $cfgFile
|
|
$dst = Join-Path $distRoot $cfgFile
|
|
if ((Test-Path $src) -and -not (Test-Path $dst)) {
|
|
Copy-Item $src $dst -Force
|
|
Write-Host " $cfgFile -> dist\aza_desktop\ kopiert"
|
|
}
|
|
}
|
|
|
|
# Build-Info als lesbares Textfile neben die EXE legen
|
|
$buildInfoPy = Join-Path $projectRoot "_build_info.py"
|
|
if (Test-Path $buildInfoPy) {
|
|
$biDst = Join-Path $distRoot "BUILD_INFO.txt"
|
|
$biContent = Get-Content $buildInfoPy -Raw
|
|
$biContent | Out-File -FilePath $biDst -Encoding utf8
|
|
Write-Host " BUILD_INFO.txt -> dist\aza_desktop\ kopiert"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "Build fertig."
|
|
Write-Host "Die Desktop-App liegt in:"
|
|
Write-Host $distRoot
|
|
Write-Host "EXE:"
|
|
Write-Host $exePath
|