199 lines
6.0 KiB
PowerShell
199 lines
6.0 KiB
PowerShell
$projectRoot = $PSScriptRoot
|
|
$innoScript = Join-Path $projectRoot "installer\aza_installer.iss"
|
|
$setupOutput = Join-Path $projectRoot "dist\installer\aza_desktop_setup.exe"
|
|
$versionMetaDir = Join-Path $projectRoot "dist\installer_meta"
|
|
$versionMetaFile = Join-Path $versionMetaDir "aza_version_info.txt"
|
|
$azaVersionPy = Join-Path $projectRoot "aza_version.py"
|
|
|
|
function Find-InnoSetup {
|
|
$candidates = @(
|
|
"${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe",
|
|
"${env:ProgramFiles}\Inno Setup 6\ISCC.exe",
|
|
"C:\Program Files (x86)\Inno Setup 6\ISCC.exe",
|
|
"C:\Program Files\Inno Setup 6\ISCC.exe",
|
|
"${env:LOCALAPPDATA}\Programs\Inno Setup 6\ISCC.exe"
|
|
)
|
|
|
|
foreach ($path in $candidates) {
|
|
if ($path -and (Test-Path $path)) {
|
|
return $path
|
|
}
|
|
}
|
|
|
|
$regPaths = @(
|
|
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1",
|
|
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1",
|
|
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1"
|
|
)
|
|
|
|
foreach ($regPath in $regPaths) {
|
|
try {
|
|
$installLocation = (Get-ItemProperty $regPath -ErrorAction SilentlyContinue).InstallLocation
|
|
if ($installLocation) {
|
|
$iscc = Join-Path $installLocation "ISCC.exe"
|
|
if (Test-Path $iscc) {
|
|
return $iscc
|
|
}
|
|
}
|
|
} catch {}
|
|
}
|
|
|
|
$isccInPath = Get-Command "ISCC.exe" -ErrorAction SilentlyContinue
|
|
if ($isccInPath) {
|
|
return $isccInPath.Source
|
|
}
|
|
|
|
return $null
|
|
}
|
|
|
|
function Install-InnoSetup {
|
|
$innoUrl = "https://jrsoftware.org/download.php/is.exe"
|
|
$installerPath = Join-Path $env:TEMP "innosetup6_installer.exe"
|
|
|
|
Write-Host ""
|
|
Write-Host "Inno Setup 6 wird automatisch heruntergeladen und installiert..."
|
|
Write-Host "Quelle: $innoUrl"
|
|
|
|
try {
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
Invoke-WebRequest -Uri $innoUrl -OutFile $installerPath -UseBasicParsing
|
|
} catch {
|
|
Write-Error "Download von Inno Setup fehlgeschlagen: $_"
|
|
return $false
|
|
}
|
|
|
|
if (-not (Test-Path $installerPath)) {
|
|
Write-Error "Inno Setup Installer wurde nicht heruntergeladen."
|
|
return $false
|
|
}
|
|
|
|
Write-Host "Installiere Inno Setup 6 (silent)..."
|
|
$process = Start-Process -FilePath $installerPath -ArgumentList "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART" -Wait -PassThru
|
|
|
|
if ($process.ExitCode -ne 0) {
|
|
Write-Error "Inno Setup Installation fehlgeschlagen (Exit Code: $($process.ExitCode))."
|
|
return $false
|
|
}
|
|
|
|
Write-Host "Inno Setup 6 wurde erfolgreich installiert."
|
|
return $true
|
|
}
|
|
|
|
# --- Voraussetzungen pruefen ---
|
|
|
|
if (-not (Test-Path $innoScript)) {
|
|
Write-Error "Installer-Script nicht gefunden: $innoScript"
|
|
exit 1
|
|
}
|
|
|
|
if (-not (Test-Path $azaVersionPy)) {
|
|
Write-Error "aza_version.py nicht gefunden: $azaVersionPy"
|
|
exit 1
|
|
}
|
|
|
|
if (-not (Test-Path (Join-Path $projectRoot "dist\aza_desktop\aza_desktop.exe"))) {
|
|
Write-Error "Desktop-Build nicht gefunden. Bitte zuerst build_exe.ps1 ausfuehren."
|
|
exit 1
|
|
}
|
|
|
|
# --- Inno Setup finden oder automatisch installieren ---
|
|
|
|
$innoCompiler = Find-InnoSetup
|
|
|
|
if (-not $innoCompiler) {
|
|
$installed = Install-InnoSetup
|
|
if ($installed) {
|
|
$innoCompiler = Find-InnoSetup
|
|
}
|
|
|
|
if (-not $innoCompiler) {
|
|
Write-Host ""
|
|
Write-Error "Inno Setup 6 konnte nicht gefunden oder installiert werden."
|
|
Write-Host ""
|
|
Write-Host "Bitte Inno Setup 6 manuell installieren:"
|
|
Write-Host " https://jrsoftware.org/isdl.php"
|
|
Write-Host ""
|
|
Write-Host "Danach dieses Script erneut ausfuehren."
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
Write-Host "Inno Setup Compiler: $innoCompiler"
|
|
|
|
# --- Version lesen ---
|
|
|
|
if (-not (Test-Path $versionMetaDir)) {
|
|
New-Item -ItemType Directory -Path $versionMetaDir | Out-Null
|
|
}
|
|
|
|
Write-Host "Lese zentrale AZA-Version aus aza_version.py..."
|
|
$versionContent = Get-Content $azaVersionPy -Raw
|
|
if ($versionContent -match 'APP_VERSION\s*=\s*"([^"]+)"') {
|
|
$appVersion = $matches[1].Trim()
|
|
} else {
|
|
$appVersion = $null
|
|
}
|
|
|
|
if (-not $appVersion) {
|
|
Write-Error "Konnte APP_VERSION nicht aus aza_version.py lesen."
|
|
exit 1
|
|
}
|
|
|
|
Set-Content -Path $versionMetaFile -Value $appVersion -Encoding ASCII
|
|
|
|
# --- Build-Zeitstempel lesen ---
|
|
|
|
$buildTimestamp = ""
|
|
$buildInfoPy = Join-Path $projectRoot "_build_info.py"
|
|
if (Test-Path $buildInfoPy) {
|
|
$biContent = Get-Content $buildInfoPy -Raw
|
|
if ($biContent -match 'BUILD_TIMESTAMP\s*=\s*"([^"]+)"') {
|
|
$buildTimestamp = $matches[1].Trim()
|
|
}
|
|
}
|
|
if (-not $buildTimestamp) {
|
|
$buildTimestamp = (Get-Date -Format "yyyyMMdd_HHmmss")
|
|
}
|
|
|
|
# --- Ausgabe-Ordner sicherstellen ---
|
|
|
|
$outputDir = Join-Path $projectRoot "dist\installer"
|
|
if (-not (Test-Path $outputDir)) {
|
|
New-Item -ItemType Directory -Path $outputDir | Out-Null
|
|
}
|
|
|
|
# --- Installer bauen ---
|
|
|
|
Write-Host "Baue AZA Installer (Version $appVersion, Build $buildTimestamp)..."
|
|
& $innoCompiler "/DMyAppVersion=$appVersion" $innoScript
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "Installer-Build fehlgeschlagen."
|
|
exit 1
|
|
}
|
|
|
|
if (-not (Test-Path $setupOutput)) {
|
|
Write-Error "Installer wurde nicht gefunden: $setupOutput"
|
|
exit 1
|
|
}
|
|
|
|
# Installer mit Zeitstempel umbenennen
|
|
$stampedName = "aza_desktop_setup_${buildTimestamp}.exe"
|
|
$stampedPath = Join-Path $outputDir $stampedName
|
|
Copy-Item $setupOutput $stampedPath -Force
|
|
Write-Host " Installer mit Zeitstempel: $stampedName"
|
|
|
|
# BUILD_INFO.txt neben den Installer legen
|
|
$distBuildInfo = Join-Path $projectRoot "dist\aza_desktop\BUILD_INFO.txt"
|
|
if (Test-Path $distBuildInfo) {
|
|
Copy-Item $distBuildInfo (Join-Path $outputDir "BUILD_INFO.txt") -Force
|
|
Write-Host " BUILD_INFO.txt -> dist\installer\ kopiert"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "Installer erfolgreich erstellt:"
|
|
Write-Host " Standard: $setupOutput"
|
|
Write-Host " Zeitstempel: $stampedPath"
|
|
Write-Host "Verwendete Version:"
|
|
Write-Host " $appVersion (Build $buildTimestamp)"
|