From f2208a88fe4bb4bae20a1f821dd175880c2905d5 Mon Sep 17 00:00:00 2001 From: rejbasket <39080670+rejbasket@users.noreply.github.com> Date: Mon, 28 Feb 2022 16:30:40 +0100 Subject: installer updates (#1565) * * build zip versions for macOS and windows * set application version macOS and Windows * automatically uninstall previous version in Windows * add zip to upload Co-authored-by: rejbasket --- installer_scripts/template.iss | 64 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 9 deletions(-) (limited to 'installer_scripts/template.iss') diff --git a/installer_scripts/template.iss b/installer_scripts/template.iss index aab1e912..a2654c36 100755 --- a/installer_scripts/template.iss +++ b/installer_scripts/template.iss @@ -32,6 +32,7 @@ VersionInfoCompany={#URL} VersionInfoCopyright=Copyright (C) {#COPYRIGHT} VersionInfoDescription=An open-source machine embroidery design platform based on Inkscape. VersionInfoTextVersion={#VERSION} +VersionInfoVersion=1.0 WizardStyle=modern ShowLanguageDialog=no @@ -68,17 +69,62 @@ Name: "English"; Description: "English"; Source: "{#PATHTODIST}\inkstitch\*"; DestDir: "{app}\inkstitch\inkstitch"; Flags: ignoreversion recursesubdirs createallsubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Code] +// SOURCE: https://stackoverflow.com/questions/2000296/inno-setup-how-to-automatically-uninstall-previous-installed-version +{ ///////////////////////////////////////////////////////////////////// } +function GetUninstallString(): String; +var + sUnInstPath: String; + sUnInstallString: String; +begin + sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1'); + sUnInstallString := ''; + if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then + RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString); + Result := sUnInstallString; +end; + + +{ ///////////////////////////////////////////////////////////////////// } +function IsUpgrade(): Boolean; +begin + Result := (GetUninstallString() <> ''); +end; + -function InitializeSetup(): Boolean; +{ ///////////////////////////////////////////////////////////////////// } +function UnInstallOldVersion(): Integer; +var + sUnInstallString: String; + iResultCode: Integer; begin - Result := True; - if RegKeyExists(HKEY_LOCAL_MACHINE, - 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') or - RegKeyExists(HKEY_CURRENT_USER, - 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') then +{ Return Values: } +{ 1 - uninstall string is empty } +{ 2 - error executing the UnInstallString } +{ 3 - successfully executed the UnInstallString } + + { default return value } + Result := 0; + + { get the uninstall string of the old app } + sUnInstallString := GetUninstallString(); + if sUnInstallString <> '' then begin + sUnInstallString := RemoveQuotes(sUnInstallString); + if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then + Result := 3 + else + Result := 2; + end else + Result := 1; +end; + +{ ///////////////////////////////////////////////////////////////////// } +procedure CurStepChanged(CurStep: TSetupStep); +begin + if (CurStep=ssInstall) then begin - MsgBox('The application is installed already.', mbInformation, MB_OK); - Result := False; + if (IsUpgrade()) then + begin + UnInstallOldVersion(); + end; end; end; - -- cgit v1.2.3