From cbe2f6bec2174af42fab3fb6cfed5b9889e61602 Mon Sep 17 00:00:00 2001 From: Bruno Lopes Date: Sat, 22 Mar 2025 16:59:05 -0300 Subject: [PATCH] build/windows: Make Installer aware of Install, Reinstall and Update modes Closes #12998. On Install mode, we correctly allow users to customize the installation. This is the expected use case of the "Customize" button: the first user be able to decide if the installation will be system-wide or on local user, to see the license, to choose the install dir, to select components etc. On Reinstall and Update mode, however, some options choosen byf the first user can't be undone, mainly components, since Inno never had support to "modify" installs (it can only not install the unchecked components). So, in our current scenario (before this commit): - If python support was installed but on the update the user uncheck it, the old python and all old gimp python plug-ins will remain installed - The same applies for postscript (.ps) component and 32-bit TWAIN So, the chances of breaking the install are very high. Inno knows that and displays a built-in warning, but even that dialog have limitations. So, let's not keep that false impression of being able to modify the install, let's fix that by hidding "Customize" on Reinstall and Update. --- build/windows/installer/base_gimp3264.iss | 60 ++++++++++++++++++- build/windows/installer/lang/setup.isl.xml.in | 6 ++ 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/build/windows/installer/base_gimp3264.iss b/build/windows/installer/base_gimp3264.iss index a30f4d299b..25e824494b 100644 --- a/build/windows/installer/base_gimp3264.iss +++ b/build/windows/installer/base_gimp3264.iss @@ -483,6 +483,7 @@ const var //pgSimple: TWizardPage; + InstallType: String; InstallMode: (imNone, imSimple, imCustom, imRebootContinue); ConfigOverride: (coUndefined, coOverride, coDontOverride); Force32bitInstall: Boolean; @@ -600,6 +601,47 @@ begin Result := True; end; +//Check what type of installation is being done +procedure CheckInstallType; +var + isInstalled: String; + InstallLocation: String; + Installed_AppVersion: String; + Installed_AppVersionInt: Int64; + Installer_AppVersionInt: Int64; +begin + isInstalled := 'notInstalled'; + if RegQueryStringValue(HKCU, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\GIMP-{#GIMP_MUTEX_VERSION}_is1', + 'DisplayVersion', Installed_AppVersion) then begin + RegQueryStringValue(HKCU, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\GIMP-{#GIMP_MUTEX_VERSION}_is1', + 'InstallLocation', InstallLocation); + StrToVersion(Installed_AppVersion, Installed_AppVersionInt); + isInstalled := 'Installed'; + end; + if RegQueryStringValue(HKLM, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\GIMP-{#GIMP_MUTEX_VERSION}_is1', + 'DisplayVersion', Installed_AppVersion) then begin + RegQueryStringValue(HKLM, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\GIMP-{#GIMP_MUTEX_VERSION}_is1', + 'InstallLocation', InstallLocation); + StrToVersion(Installed_AppVersion, Installed_AppVersionInt); + isInstalled := 'Installed'; + end; + + StrToVersion('{#FULL_GIMP_VERSION}', Installer_AppVersionInt); + + if (isInstalled = 'Installed') and (not DirExists(InstallLocation)) then begin + InstallType := 'itRepair'; + end else if isInstalled = 'notInstalled' then begin + InstallType := 'itInstall'; + end else if ComparePackedVersion(Installer_AppVersionInt, Installed_AppVersionInt) = 0 then begin + InstallType := 'itReinstall'; + end else if ComparePackedVersion(Installer_AppVersionInt, Installed_AppVersionInt) > 0 then begin + InstallType := 'itUpdate'; + end else begin + InstallType := 'itDowngrade'; + end; + DebugMsg('CheckInstallType','Installed GIMP {#GIMP_MUTEX_VERSION} is: ' + Installed_AppVersion + ', installer is: {#FULL_GIMP_VERSION}. So Install type is: ' + InstallType); +end; + function InitializeSetup(): Boolean; #if (Defined(GIMP_UNSTABLE) && GIMP_UNSTABLE != "") || (Defined(GIMP_RC_VERSION) && GIMP_RC_VERSION != "") || Defined(DEVEL_WARNING) var Message,Buttons: TArrayOfString; @@ -715,7 +757,9 @@ begin btnInstall.Visible := True; btnInstall.TabOrder := 1; - btnCustomize.Visible := True; + if InstallType = 'itInstall' then begin + btnCustomize.Visible := True; + end; WizardForm.Bevel.Visible := False; WizardForm.WelcomeLabel1.Visible := False; @@ -729,7 +773,9 @@ procedure CleanUpCustomWelcome(); begin WizardForm.NextButton.Visible := True; btnInstall.Visible := False; - btnCustomize.Visible := False; + if InstallType = 'itInstall' then begin + btnCustomize.Visible := False; + end; WizardForm.Bevel.Visible := True; WelcomeBitmapBottom.Visible := False; @@ -771,7 +817,14 @@ begin Height := WizardForm.NextButton.Height; Left := WizardForm.NextButton.Left; Top := WizardForm.NextButton.Top; - Caption := CustomMessage('Install'); + CheckInstallType; + if InstallType = 'itInstall' then begin + Caption := CustomMessage('Install'); + end else if InstallType = 'itReinstall' then begin + Caption := CustomMessage('Reinstall'); + end else if InstallType = 'itUpdate' then begin + Caption := CustomMessage('Update'); + end; Default := True; Visible := False; @@ -810,6 +863,7 @@ begin end; MeasureLabel.Free; + end; diff --git a/build/windows/installer/lang/setup.isl.xml.in b/build/windows/installer/lang/setup.isl.xml.in index a06614f6f3..0c48ff723c 100644 --- a/build/windows/installer/lang/setup.isl.xml.in +++ b/build/windows/installer/lang/setup.isl.xml.in @@ -50,6 +50,12 @@ &Install + + &Reinstall + + + &Update + &Customize