|
| 1 | + |
| 2 | +param( |
| 3 | + [string]$BuildDir = "build_stage", |
| 4 | + [string]$StagingDir = "Installer_Staging", |
| 5 | + [string]$OutputPath = "OpenSalamander_v5.exe" |
| 6 | +) |
| 7 | + |
| 8 | +if (Test-Path $StagingDir) { Remove-Item $StagingDir -Recurse -Force } |
| 9 | +New-Item -ItemType Directory -Path $StagingDir |
| 10 | +New-Item -ItemType Directory -Path "$StagingDir\plugins" |
| 11 | +New-Item -ItemType Directory -Path "$StagingDir\lang" |
| 12 | +New-Item -ItemType Directory -Path "$StagingDir\convert" |
| 13 | +New-Item -ItemType Directory -Path "$StagingDir\toolbars" |
| 14 | + |
| 15 | +# 1. Copy base installer files |
| 16 | +Copy-Item "Installer\setup.exe" "$StagingDir\" |
| 17 | +Copy-Item "Installer\LICENSE" "$StagingDir\" |
| 18 | +Copy-Item "Installer\x64" "$StagingDir\" |
| 19 | + |
| 20 | +# 2. Copy main executables (from Release_x64) |
| 21 | +Copy-Item "src\vcxproj\salamander\Release_x64\salamand.exe" "$StagingDir\" |
| 22 | +Copy-Item "src\vcxproj\salmon\salamander\Release_x64\utils\salmon.exe" "$StagingDir\" |
| 23 | +Copy-Item "$BuildDir\remove\Release_x64\remove.exe" "$StagingDir\" |
| 24 | + |
| 25 | +# 3. Copy lang (main app) |
| 26 | +Copy-Item "Installer\lang\*" "$StagingDir\lang\" -Recurse |
| 27 | + |
| 28 | +# 4. Copy convert |
| 29 | +Copy-Item "convert\*" "$StagingDir\convert\" -Recurse |
| 30 | + |
| 31 | +# 5. Copy toolbars |
| 32 | +Copy-Item "src\res\toolbars\*" "$StagingDir\toolbars\" -Recurse |
| 33 | + |
| 34 | +# 6. Copy plugins |
| 35 | +# Find all .spl files in Release_x64 directories |
| 36 | +$splFiles = Get-ChildItem -Path "src\plugins" -Recurse -Filter "*.spl" | Where-Object { $_.FullName -match "Release_x64" } |
| 37 | +foreach ($file in $splFiles) { |
| 38 | + # Extract plugin name from path (usually ...\plugins\<name>\<name>.spl) |
| 39 | + $pluginName = $file.Directory.Name |
| 40 | + $pluginDestDir = New-Item -ItemType Directory -Path "$StagingDir\plugins\$pluginName" -Force |
| 41 | + Copy-Item $file.FullName "$pluginDestDir\" |
| 42 | + |
| 43 | + # Copy plugin's lang files (only .slg, exclude Intermediate) |
| 44 | + $pluginLangDir = Join-Path $file.DirectoryName "lang" |
| 45 | + if (Test-Path $pluginLangDir) { |
| 46 | + $stagedLangDir = New-Item -ItemType Directory -Path "$pluginDestDir\lang" -Force |
| 47 | + Get-ChildItem -Path $pluginLangDir -Filter "*.slg" | Copy-Item -Destination "$stagedLangDir\" |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +# 7. Generate setup.inf |
| 52 | +$setupInf = @" |
| 53 | +[Private] |
| 54 | +ApplicationName=Open Salamander 5.0 |
| 55 | +ApplicationNameVer=Open Salamander 5.0 |
| 56 | +DefaultDirectory=%4%\Open Salamander 5.0 |
| 57 | +LicenseFile=LICENSE |
| 58 | +SkipChooseDirectory=0 |
| 59 | +SaveRemoveLog=%1%\uninstall.log |
| 60 | +UninstallRunProgramQuietPath=%1%\remove.exe |
| 61 | +
|
| 62 | +[CopyFiles] |
| 63 | +salamand.exe,%1\salamand.exe,0 |
| 64 | +salmon.exe,%1\salmon.exe,0 |
| 65 | +remove.exe,%1\remove.exe,0 |
| 66 | +"@ |
| 67 | + |
| 68 | +# Function to add files to setup.inf |
| 69 | +function Add-ToSetupInf($path) { |
| 70 | + $files = Get-ChildItem -Path "$StagingDir\$path" -File -Recurse |
| 71 | + foreach ($f in $files) { |
| 72 | + $relPath = $f.FullName.Substring((Get-Item $StagingDir).FullName.Length + 1) |
| 73 | + # Check if the file is in an Intermediate directory (shouldn't be there, but just in case) |
| 74 | + if ($relPath -notmatch "\\Intermediate\\") { |
| 75 | + $script:setupInf += "`n$relPath,%1\$relPath,0" |
| 76 | + } |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +Add-ToSetupInf "lang" |
| 81 | +Add-ToSetupInf "convert" |
| 82 | +Add-ToSetupInf "toolbars" |
| 83 | +Add-ToSetupInf "plugins" |
| 84 | + |
| 85 | +$setupInf += @" |
| 86 | +
|
| 87 | +[CreateShortcuts] |
| 88 | +0,Open Salamander 5.0,%1\salamand.exe, |
| 89 | +1,Open Salamander 5.0,%1\salamand.exe, |
| 90 | +"@ |
| 91 | + |
| 92 | +$setupInf | Out-File -FilePath "$StagingDir\setup.inf" -Encoding utf8 |
| 93 | + |
| 94 | +# 8. Create SFX using the existing tool |
| 95 | +$ScriptRoot = Split-Path $MyInvocation.MyCommand.Path |
| 96 | +$SfxTool = Join-Path $ScriptRoot "Create-Sfx.ps1" |
| 97 | + |
| 98 | +powershell.exe -File "$SfxTool" -SourceDir "$StagingDir" -OutputPath "$OutputPath" |
| 99 | + |
| 100 | +Write-Host "Installer created: $OutputPath" |
0 commit comments