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/file_version_info.txt | 40 +++++++++++++++++++++ installer_scripts/template.iss | 64 ++++++++++++++++++++++++++++----- 2 files changed, 95 insertions(+), 9 deletions(-) create mode 100755 installer_scripts/file_version_info.txt (limited to 'installer_scripts') diff --git a/installer_scripts/file_version_info.txt b/installer_scripts/file_version_info.txt new file mode 100755 index 00000000..4b912e23 --- /dev/null +++ b/installer_scripts/file_version_info.txt @@ -0,0 +1,40 @@ +VSVersionInfo( + ffi=FixedFileInfo( + # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4) + # Set not needed items to zero 0. + filevers=(3, 2, 1, 0), + prodvers=(3, 2, 1, 0), + # Contains a bitmask that specifies the valid bits 'flags'r + mask=0x0, + # Contains a bitmask that specifies the Boolean attributes of the file. + flags=0x0, + # The operating system for which this file was designed. + # 0x4 - NT and there is no need to change it. + OS=0x40004, + # The general type of file. + # 0x1 - the file is an application. + fileType=0x1, + # The function of the file. + # 0x0 - the function is not defined for this fileType + subtype=0x0, + # Creation date and time stamp. + date=(0, 0) + ), + kids=[ + StringFileInfo( + [ + StringTable( + u'040904E4', + [StringStruct(u'Comments', u'Published under the GNU GPL'), + StringStruct(u'CompanyName', u'Ink/Stitch project'), + StringStruct(u'FileDescription', u'An open-source machine embroidery design platform based on Inkscape.'), + StringStruct(u'FileVersion', u'1.1.1'), + StringStruct(u'InternalName', u'Inkstitch '), + StringStruct(u'LegalCopyright', u'© 1234 Inkstitch Open Source Community'), + StringStruct(u'OriginalFilename', u'inkstitch.exe'), + StringStruct(u'ProductName', u'Inkstitch'), + StringStruct(u'ProductVersion', u'1.1.1')]) + ]), + VarFileInfo([VarStruct(u'Translation', [1033, 1252])]) + ] +) 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