From 1d528cd436635bd13ce021ffffb37a93140b7b62 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 1 Sep 2010 13:09:57 +0000 Subject: [PATCH] Bug #588414 - Got "Entry Point Not Found" errors starting GnuCash, but ran OK The problem is caused by leftover files from a previous install. The solution is to uninstall GnuCash before installing a new version in such cases. This commit adds a compatibility test and uninstall step to the windows installer that will automatically uninstall the previous gnucash release if it is considered 'incompatible' with the one to be installed. The user will be warned of this, so he can decide to cancel the installation if he doesn't like the idea of uninstalling his working GnuCash installation. Currently, versions are considered 'incompatible' if their major or minor version components are different, so 2.3.x is incompatible with 2.2.x and will trigger an uninstall. Likewise, a 2.4.x install is incompatible with a 2.3.x and will trigger an uninstall. This is a nice way to remove all testing 'cruft' from the system once the new release comes out. Note that in the future installing 2.3.16+ over 2.4.x will also trigger the uninstall, which is a good thing IMO. An older release can't know about changes made in a newer one, so it's safer to first uninstall the newer one to avoid leftover files. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19528 57a11ea4-9604-0410-9ed3-97b8803252fd --- packaging/win32/gnucash.iss.in | 143 +++++++++++++++++++++++++++++++-- 1 file changed, 138 insertions(+), 5 deletions(-) diff --git a/packaging/win32/gnucash.iss.in b/packaging/win32/gnucash.iss.in index 078d056ce3..1ac0ef4db1 100644 --- a/packaging/win32/gnucash.iss.in +++ b/packaging/win32/gnucash.iss.in @@ -1,4 +1,4 @@ -; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Input configuration for the Inno Setup Compiler ; Copyright (c) 2004-2005 Christian Stimming ; @@ -126,6 +126,13 @@ Root: HKLM; Subkey: "Software\GnuCash\Paths"; ValueType: string; ValueName: "pkg Root: HKLM; Subkey: "Software\GnuCash\Paths"; ValueType: string; ValueName: "sysconfdir"; ValueData: "{app}\etc"; Flags: uninsdeletevalue Root: HKLM; Subkey: "Software\GnuCash\Paths"; ValueType: string; ValueName: "localedir"; ValueData: "{app}\share\locale"; Flags: uninsdeletevalue +; Store the version information +Root: HKLM; Subkey: "Software\GnuCash\Version"; ValueType: none; Flags: uninsdeletekeyifempty +Root: HKLM; Subkey: "Software\GnuCash\Version"; ValueType: string; ValueName: "Version"; ValueData: "@PACKAGE_VERSION@"; Flags: uninsdeletevalue +Root: HKLM; Subkey: "Software\GnuCash\Version"; ValueType: dword; ValueName: "VersionMajor"; ValueData: "@GNUCASH_MAJOR_VERSION@"; Flags: uninsdeletevalue +Root: HKLM; Subkey: "Software\GnuCash\Version"; ValueType: dword; ValueName: "VersionMinor"; ValueData: "@GNUCASH_MINOR_VERSION@"; Flags: uninsdeletevalue +Root: HKLM; Subkey: "Software\GnuCash\Version"; ValueType: dword; ValueName: "VersionMicro"; ValueData: "@GNUCASH_MICRO_VERSION@"; Flags: uninsdeletevalue + ; Additionally, we have to install the paths for gwenhywfar Root: HKLM; Subkey: "Software\Gwenhywfar"; ValueType: none; Flags: uninsdeletekeyifempty Root: HKLM; Subkey: "Software\Gwenhywfar\Paths"; ValueType: none; Flags: uninsdeletekeyifempty @@ -162,12 +169,129 @@ Type: dirifempty; Name: "{app}\etc\gnucash" Type: dirifempty; Name: "{app}\etc" ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; This large section is a Pascal scripting program that will modify -; the gnucash shell script so that it then includes the -; correct values according to our local installation. See -; http://www.remobjects.com/?ps for a syntax reference. +; Perform some additional actions in code that can't be done +; by the installer by default. The code snippets below hook +; into the installer code at specific events. See +; http://www.jrsoftware.org/ishelp/index.php?topic=scriptintro +; for more information on iss scription and a syntax reference. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; [Code] +var + PrevInstDetectedPage : TOutputMsgWizardPage; + PrevAppName, PrevUninstallString : String; + PrevVersionMajor, PrevVersionMinor, PrevVersionMicro : Cardinal; + Uninstallrequired : Boolean; + +// ----------------------------------------------------------- +// Sometimes it's not possible to install a newer version of +// GnuCash over an older one on Windows. This is mostly the +// case when libraries are moved around in the newer version. +// The code below will detect an existing GnuCash installation +// and will remove it (if the user accepts) before installing +// the version the user has selected. +// ----------------------------------------------------------- + +{ Lookup the registry information on a previous installation } +procedure GetPrevInstallInfo(); +var + sUnInstPath, sAppVersionPath: String; + rootKey : Integer; +begin + sAppVersionPath := 'Software\GnuCash\Version'; + sUnInstPath := 'Software\Microsoft\Windows\CurrentVersion\Uninstall\GnuCash_is1'; + + PrevAppName := ''; + PrevUninstallString := ''; + PrevVersionMajor := 0; + PrevVersionMinor := 0; + PrevVersionMicro := 0; + + if RegKeyExists(HKLM, sUnInstPath) then + rootKey := HKLM + else + rootKey := HKCU; + + RegQueryStringValue(rootKey, sUnInstPath, 'UninstallString', PrevUninstallString); + RegQueryStringValue(rootKey, sUnInstPath, 'DisplayName', PrevAppName); + RegQueryDwordValue(rootKey, sAppVersionPath, 'VersionMajor', PrevVersionMajor); + RegQueryDwordValue(rootKey, sAppVersionPath, 'VersionMinor', PrevVersionMinor); + RegQueryDwordValue(rootKey, sAppVersionPath, 'VersionMicro', PrevVersionMicro); +end; + +{ Check if there is another GnuCash currently installed } +{ and whether we can simply install over it or have to remove it first } +{ Versions are considered 'incompatible' if the major or minor } +{ version components are different } +procedure CheckUninstallRequired(); +begin + UninstallRequired := True; + GetPrevInstallInfo; + + if (PrevUninstallString = '') then + UninstallRequired := False + else if (PrevVersionMajor = @GNUCASH_MAJOR_VERSION@) and (PrevVersionMinor = @GNUCASH_MINOR_VERSION@) then + UninstallRequired := False; +end; + +{ Uninstall the current installation } +function UnInstallOldVersion(): Integer; +var + sUnInstallString: String; + iResultCode: Integer; +begin +// Return Values: +// 1 - uninstall string is empty +// 2 - error executing the UnInstallString +// 3 - successfully executed the UnInstallString + + // default return value + Result := 0; + + if PrevUninstallString <> '' then begin + sUnInstallString := RemoveQuotes(PrevUninstallString); + if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then + Result := 3 + else + Result := 2; + end else + Result := 1; +end; + +function GetPrevAppName(Param: String): String; +begin + Result := PrevAppName; +end; + +{ Setup a page to display if a previous (incompatible) GnuCash installation is found } +procedure InitializeWizard; +begin + CheckUninstallRequired; + PrevInstDetectedPage := CreateOutputMsgPage(wpReady, + ExpandConstant('{cm:AIWP_Title}'), + ExpandConstant('{cm:AIWP_Description,{code:GetPrevAppName}}'), + ExpandConstant('{cm:AIWP_Message,{code:GetPrevAppName}}')); +end; + +{ Determine whether the previous installation page should be displayed or not } +function ShouldSkipPage(PageID: Integer): Boolean; +begin + Result := False + if (PageID = PrevInstDetectedPage.ID) and (not UninstallRequired) then + Result := True; +end; + +{ If a previous (incompatible) installation is present start the installation } +{ process with deleting this old installation } +procedure CurStepChanged(CurStep: TSetupStep); +begin + if (CurStep=ssInstall) and (UninstallRequired) then + UnInstallOldVersion(); +end; + +// ------------------------------------------------------------ +// The GnuCash environment file contains paths that have to be +// adapted at install time. The code below does that. +// ------------------------------------------------------------ function MingwBacksl(const S: String): String; begin { Modify the path name S so that it can be used by MinGW } @@ -284,6 +408,11 @@ CreateMenuLink=Create a start menu link RunPrg=Run GnuCash now AdditionalIcons=Create these icons: StatusMsgFirewall=Installing Windows firewall rules... +; *** "Another install" wizard page +; %1 in the following messages will be replaced with the application name and version, like "GnuCash 2.3.15" +AIWP_Title=Another installation has been found +AIWP_Description=%1 is currently installed on this computer +AIWP_Message=This earlier installation has to be removed before continuing.%n%nIf you don't want that, click Cancel now to abort the current installation.%n%nClick Next to remove %1 and continue with the installation.%n%nNote: Only the program will be removed, not your financial data. MainFiles=GnuCash Program TranslFiles=Translation Files @@ -473,6 +602,10 @@ nl.IconComment_InstallFQ=De benodigde perl module Finance Quote om online koerse nl.IconName_Uninstall=GnuCash verwijderen nl.IconComment_Uninstall=Het financieel beheersprogramma GnuCash verwijderen +nl.AIWP_Title=Een eerdere installatie werd gevonden +nl.AIWP_Description=%1 is momenteel op deze computer geïnstalleerd +nl.AIWP_Message=Deze eerdere installatie moet verwijderd worden alvorens verder te gaan.%n%nAls je dat niet wil, klik dan nu op Annuleren om de huidige installatie af te breken.%n%nKlik op Volgende om %1 te verwijderen en de installatie te vervolgen.%n%nOpmerking: enkel het programma zal verwijderd worden, niet je financiële data. + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Brazilian Portuguese translation