build/windows: Complete 76f174f8 (regarding Installer .ps1 simplification)

This commit is contained in:
Bruno 2024-09-12 21:10:54 -03:00
parent d018dd47fb
commit c229e43744
1 changed files with 42 additions and 58 deletions

View File

@ -30,13 +30,9 @@ Write-Output "(INFO): Installed Inno: $inno_version"
## Get Inno install path
$INNO_PATH = Get-ItemProperty (Resolve-Path Registry::'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup*') | Select-Object -ExpandProperty InstallLocation
#$INNO_PATH = [regex]::Matches((Get-Content ..\innosetup.log | Select-String ISCC.exe), '(?<=filename: ).+?(?=\\ISCC.exe)').Value
Set-Alias iscc "$INNO_PATH\iscc.exe"
## Get Inno install path (fallback)
#$log = Get-Content ..\innosetup.log | Select-String ISCC.exe
#pattern = '(?<=filename: ).+?(?=\\ISCC.exe)'
#$INNO_PATH = [regex]::Matches($log, $pattern).Value
# 2. GET GLOBAL INFO
$CONFIG_PATH = "$BUILD_DIR\config.h"
@ -47,45 +43,42 @@ if (-not (Test-Path "$CONFIG_PATH"))
}
## Get AppVer (GIMP version as we use on Inno)
### AppVer without revision
$gimp_version = Get-Content "$CONFIG_PATH" | Select-String 'GIMP_VERSION' |
Foreach-Object {$_ -replace '#define GIMP_VERSION "',''} | Foreach-Object {$_ -replace '"',''}
$APPVER = $gimp_version
### Revisioned AppVer
if ($CI_PIPELINE_SOURCE -ne 'schedule' -and $GIMP_CI_WIN_INSTALLER -and $GIMP_CI_WIN_INSTALLER -match '[0-9]')
{
Write-Host "(WARNING): The revision is being made on CI, more updated deps than necessary may be packaged." -ForegroundColor yellow
$revision = $GIMP_CI_WIN_INSTALLER
}
if ($revision -ne '0')
{
$APPVER = "$gimp_version.$revision"
}
Write-Output "(INFO): GIMP version: $APPVER"
## FIXME: Our Inno scripts can't construct an one-arch installer
if (-not (Test-Path "$GIMP32"))
$supported_archs = "$GIMP32","$GIMP64","$GIMPA64"
foreach ($bundle in $supported_archs)
{
Write-Host "(ERROR): $GIMP32 bundle not found. You need all the three archs bundles to make the installer." -ForegroundColor red
}
if (-not (Test-Path "$GIMP64"))
{
Write-Host "(ERROR): $GIMP64 bundle not found. You need all the three archs bundles to make the installer." -ForegroundColor red
}
if (-not (Test-Path "$GIMPA64"))
{
Write-Host "(ERROR): $GIMPA64 bundle not found. You need all the three archs bundles to make the installer." -ForegroundColor red
if (-not (Test-Path "$bundle"))
{
Write-Host "(ERROR): $bundle bundle not found. You need all the three archs bundles to make the installer." -ForegroundColor red
}
}
if ((-not (Test-Path "$GIMP32")) -or (-not (Test-Path "$GIMP64")) -or (-not (Test-Path "$GIMPA64")))
{
exit 1
}
Write-Output "(INFO): Arch: universal (x86, x64 and arm64)"
# 3. PREPARE INSTALLER "SOURCE"
## Custom installer strings translations and other assets
## (They are loaded with '-DBUILD_DIR')
if (-not (Test-Path "$BUILD_DIR\build\windows\installer"))
{
Write-Host "(ERROR): Installer assets not found. You can tweak 'build/windows/2_build-gimp-msys2.ps1' or configure GIMP with '-Dwindows-installer=true' to build them." -ForegroundColor red
@ -96,14 +89,13 @@ if (-not (Test-Path "$BUILD_DIR\build\windows\installer"))
#Write-Output "(INFO): downloading Official Inno lang files (not present in a release yet)"
#function download_lang_official ([string]$langfile)
#{
# Invoke-WebRequest -URI "https://raw.githubusercontent.com/jrsoftware/issrc/main/Files/Languages/${langfile}" -OutFile "$INNO_PATH/Languages/${langfile}"
# Invoke-WebRequest https://raw.githubusercontent.com/jrsoftware/issrc/main/Files/Languages/$langfile -OutFile "$INNO_PATH/Languages/$langfile"
#}
## Download unofficial translations (of unknown quality and maintenance)
## Cf. https://jrsoftware.org/files/istrans/
Write-Output "(INFO): downloading unofficial Inno lang files"
New-Item "$INNO_PATH/Languages/Unofficial/" -ItemType Directory -Force | Out-Null
$xmlObject = New-Object XML
$xmlObject.Load("$PWD\build\windows\installer\lang\iso_639_custom.xml")
$langsArray = $xmlObject.iso_639_entries.iso_639_entry |
@ -140,7 +132,6 @@ function fix_msg ([string]$langsdir)
# Set-Content "$langfile" -Encoding UTF8
#}
}
fix_msg $INNO_PATH
fix_msg $INNO_PATH\Languages
fix_msg $INNO_PATH\Languages\Unofficial
@ -148,16 +139,18 @@ fix_msg $INNO_PATH\Languages\Unofficial
# 4. PREPARE GIMP FILES
## Get GIMP versions used in some versioned files and dirs
$gimp_app_version = Get-Content "$CONFIG_PATH" | Select-String 'GIMP_APP_VERSION "' |
Foreach-Object {$_ -replace '#define GIMP_APP_VERSION "',''} | Foreach-Object {$_ -replace '"',''}
$gimp_api_version = Get-Content "$CONFIG_PATH" | Select-String 'GIMP_PKGCONFIG_VERSION' |
Foreach-Object {$_ -replace '#define GIMP_PKGCONFIG_VERSION "',''} | Foreach-Object {$_ -replace '"',''}
## GIMP revision on about dialog (this does the same as '-Drevision' build option)
## FIXME: This should be done with Inno scripting
if ($GITLAB_CI)
foreach ($bundle in $supported_archs)
{
$supported_archs = "$GIMP32","$GIMP64","$GIMPA64"
foreach ($bundle in $supported_archs)
{
(Get-Content "$bundle\share\gimp\*\gimp-release") | Foreach-Object {$_ -replace "revision=0","revision=$revision"} |
Set-Content "$bundle\share\gimp\*\gimp-release"
}
(Get-Content "$bundle\share\gimp\*\gimp-release") | Foreach-Object {$_ -replace "revision=0","revision=$revision"} |
Set-Content "$bundle\share\gimp\*\gimp-release"
}
## Split .debug symbols
@ -169,40 +162,31 @@ bash build/windows/installer/3_dist-gimp-inno_sym.sh | Out-Null
$INSTALLER="gimp-${APPVER}-setup.exe"
Write-Output "(INFO): constructing $INSTALLER installer"
## Get GIMP versions used in some versioned files and dirs
$gimp_app_version = Get-Content "$CONFIG_PATH" | Select-String 'GIMP_APP_VERSION "' |
Foreach-Object {$_ -replace '#define GIMP_APP_VERSION "',''} | Foreach-Object {$_ -replace '"',''}
$gimp_api_version = Get-Content "$CONFIG_PATH" | Select-String 'GIMP_PKGCONFIG_VERSION' |
Foreach-Object {$_ -replace '#define GIMP_PKGCONFIG_VERSION "',''} | Foreach-Object {$_ -replace '"',''}
## Compile installer
Set-Location build\windows\installer
iscc -DGIMP_VERSION="$gimp_version" -DREVISION="$revision" -DGIMP_APP_VERSION="$gimp_app_version" -DGIMP_API_VERSION="$gimp_api_version" -DBUILD_DIR="$BUILD_DIR" -DGIMP_DIR="$GIMP_BASE" -DDIR32="$GIMP32" -DDIR64="$GIMP64" -DDIRA64="$GIMPA64" -DDEPS_DIR="$GIMP_BASE" -DDDIR32="$GIMP32" -DDDIR64="$GIMP64" -DDDIRA64="$GIMPA64" -DDEBUG_SYMBOLS -DPYTHON base_gimp3264.iss | Out-Null
Set-Location $GIMP_BASE
## Test if the installer was created and return success/failure.
if (Test-Path "$GIMP_BASE\$INSTALLER" -PathType Leaf)
## Clean changes in the bundles
foreach ($bundle in $supported_archs)
{
if ($GITLAB_CI)
(Get-Content "$bundle\share\gimp\*\gimp-release") | Foreach-Object {$_ -replace "revision=$revision","revision=0"} |
Set-Content "$bundle\share\gimp\*\gimp-release"
}
if ($GITLAB_CI)
{
# GitLab doesn't support wildcards when using "expose_as" so let's move to a dir
$output_dir = 'build\windows\installer\_Output'
New-Item $output_dir -ItemType Directory | Out-Null
Move-Item $GIMP_BASE\$INSTALLER $output_dir
# Generate checksums
if ($CI_COMMIT_TAG)
{
New-Item _Output -ItemType Directory | Out-Null
Move-Item $GIMP_BASE\$INSTALLER _Output
if ($CI_COMMIT_TAG)
{
Write-Output "(INFO): generating checksums for $INSTALLER"
Get-FileHash _Output\$INSTALLER -Algorithm SHA256 | Out-File _Output\$INSTALLER.SHA256SUMS
Get-FileHash _Output\$INSTALLER -Algorithm SHA512 | Out-File _Output\$INSTALLER.SHA512SUMS
}
Write-Output "(INFO): generating checksums for $INSTALLER"
Get-FileHash $output_dir\$INSTALLER -Algorithm SHA256 | Out-File $output_dir\$INSTALLER.SHA256SUMS
Get-FileHash $output_dir\$INSTALLER -Algorithm SHA512 | Out-File $output_dir\$INSTALLER.SHA512SUMS
}
# Return to git golder
Set-Location $GIMP_BASE
}
else
{
# Return to git golder
Set-Location $GIMP_BASE
exit 1
}