[patch] 修改nsis安装流程

This commit is contained in:
Gitea Actions Bot
2025-10-11 16:11:26 +08:00
parent 7c0667cb39
commit 468a092fd9
3 changed files with 97 additions and 12 deletions

View File

@@ -158,30 +158,95 @@ jobs:
Write-Host "Step 4.6: Install NSIS";
Write-Host "==========================================";
# Download NSIS 3.09
$nsisUrl = "https://sourceforge.net/projects/nsis/files/NSIS%203/3.09/nsis-3.09-setup.exe/download";
$nsisInstaller = "$env:TEMP\nsis-setup.exe";
# Use current directory for installer to avoid permission issues
$nsisInstaller = "$PWD\nsis-setup.exe";
Write-Host "Downloading NSIS installer...";
Write-Host "Target path: $nsisInstaller";
# Try multiple sources
$downloaded = $false;
# Source 1: Direct download from GitHub mirror
try {
Invoke-WebRequest -Uri $nsisUrl -OutFile $nsisInstaller -UseBasicParsing -TimeoutSec 300;
$nsisUrl = "https://github.com/hsluoyz/NSIS/raw/master/nsis-3.08-setup.exe";
Write-Host "Trying source 1: GitHub mirror...";
Invoke-WebRequest -Uri $nsisUrl -OutFile $nsisInstaller -UseBasicParsing -TimeoutSec 180;
if (Test-Path $nsisInstaller) {
$fileSize = (Get-Item $nsisInstaller).Length / 1MB;
Write-Host "Downloaded successfully: $([math]::Round($fileSize, 2)) MB";
$downloaded = $true;
}
} catch {
Write-Host "Failed to download from SourceForge, trying alternative source...";
$nsisUrl = "https://nsis.sourceforge.io/mediawiki/images/4/4a/Nsis-3.09-setup.exe";
Invoke-WebRequest -Uri $nsisUrl -OutFile $nsisInstaller -UseBasicParsing -TimeoutSec 300;
Write-Host "Source 1 failed: $_";
}
# Source 2: SourceForge
if (-not $downloaded) {
try {
$nsisUrl = "https://sourceforge.net/projects/nsis/files/NSIS%203/3.08/nsis-3.08-setup.exe/download";
Write-Host "Trying source 2: SourceForge...";
Invoke-WebRequest -Uri $nsisUrl -OutFile $nsisInstaller -UseBasicParsing -TimeoutSec 300;
if (Test-Path $nsisInstaller) {
$fileSize = (Get-Item $nsisInstaller).Length / 1MB;
Write-Host "Downloaded successfully: $([math]::Round($fileSize, 2)) MB";
$downloaded = $true;
}
} catch {
Write-Host "Source 2 failed: $_";
}
}
if (-not $downloaded) {
Write-Host "ERROR: All download sources failed";
exit 1;
}
# Verify file exists and is not empty
if (-not (Test-Path $nsisInstaller)) {
Write-Host "ERROR: Installer file not found at $nsisInstaller";
exit 1;
}
$fileSize = (Get-Item $nsisInstaller).Length;
if ($fileSize -lt 1000000) {
Write-Host "ERROR: Installer file too small ($fileSize bytes), download may be incomplete";
exit 1;
}
Write-Host "Installing NSIS silently...";
Start-Process -FilePath $nsisInstaller -ArgumentList "/S" -Wait -NoNewWindow;
# Wait for installation to complete
Start-Sleep -Seconds 5;
# Add NSIS to PATH
$nsisPath = "C:\Program Files (x86)\NSIS";
$env:Path += ";$nsisPath";
if (-not (Test-Path $nsisPath)) {
# Try x64 path
$nsisPath = "C:\Program Files\NSIS";
}
if (Test-Path $nsisPath) {
$env:Path = "$nsisPath;$env:Path";
Write-Host "NSIS path added: $nsisPath";
} else {
Write-Host "ERROR: NSIS installation directory not found";
exit 1;
}
Write-Host "Verifying NSIS installation...";
& makensis /VERSION;
$makensisPath = Join-Path $nsisPath "makensis.exe";
if (Test-Path $makensisPath) {
& $makensisPath /VERSION;
Write-Host "NSIS installed successfully";
} else {
Write-Host "ERROR: makensis.exe not found at $makensisPath";
exit 1;
}
Write-Host "NSIS installed successfully";
# Clean up installer
Remove-Item $nsisInstaller -ErrorAction SilentlyContinue;
Write-Host "";
# Step 4.7: Build NSIS installer
@@ -195,7 +260,11 @@ jobs:
# Ensure NSIS is in PATH
$nsisPath = "C:\Program Files (x86)\NSIS";
$env:Path += ";$nsisPath";
if (-not (Test-Path $nsisPath)) {
$nsisPath = "C:\Program Files\NSIS";
}
$env:Path = "$nsisPath;$env:Path";
Write-Host "Using NSIS from: $nsisPath";
cd installer;
python build_installer.py;