Logic changes to installer:

* Protect more code with try/except blocks, hoping to crash less in some strange circumstances we haven't been able to reproduce, including the KIS 8 problem. (Updates #925. ON ERROR RESUME NEXT)
 * Instead of deleting an old Aegisub.exe, rename it to aegisub32.exe to teach Windows Distributed Link Tracking thingy that it's in fact the same thing, just with a new name.

Originally committed to SVN as r3738.
This commit is contained in:
Niels Martin Hansen 2009-10-27 00:55:23 +00:00
parent 9682009b24
commit 3849ab0ebd
2 changed files with 101 additions and 72 deletions

View File

@ -310,10 +310,15 @@ begin
// Check for uninstall entry for runtimes, don't bother installing if it can be uninstalled now
// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A25302D-30C0-39D9-BD6F-21E6EC160475}
// Check: DisplayVersion = "9.0.30729"
try
DisplayVersion := '';
Result := RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A25302D-30C0-39D9-BD6F-21E6EC160475}',
'DisplayVersion', DisplayVersion);
Result := Result and (DisplayVersion = '9.0.30729');
except
// If the check fails take the safe route
Result := False;
end;
Result := not Result;
end;
@ -369,20 +374,26 @@ end;
function InitializeSetup: Boolean;
begin
LegacyStartMenuFolder := 'Aegisub';
LegacyInstallFolder := ExpandConstant('{pf}\Aegisub');
LegacyVersionNumber := '1.x';
try
HasLegacyVersion := RegValueExists(HKLM, 'SOFTWARE\Aegisub\info', 'InstVer');
Log(Format('Legacy version found: %s', [BoolToStr(HasLegacyVersion)]));
LegacyStartMenuFolder := 'Aegisub';
if RegQueryStringValue(HKLM, 'SOFTWARE\Aegisub\info', 'StartMenuDir', LegacyStartMenuFolder) then
LegacyStartMenuFolder := ExpandConstant('{userprograms}\') + LegacyStartMenuFolder;
Log(Format('Legacy version Start menu folder: %s', [LegacyStartMenuFolder]));
LegacyInstallFolder := ExpandConstant('{pf}\Aegisub');
RegQueryStringValue(HKLM, 'SOFTWARE\Aegisub\info', 'InstallDir', LegacyInstallFolder);
Log(Format('Legacy version install folder: %s', [LegacyInstallFolder]));
LegacyVersionNumber := '1.x';
RegQueryStringValue(HKLM, 'SOFTWARE\Aegisub\info', 'InstVer', LegacyVersionNumber);
except
Log('An exception occurred while trying to detect a legacy installation of Aegisub. Assuming there isn''t one.');
HasLegacyVersion := False;
end;
Result := True;
if HasLegacyVersion then
@ -396,6 +407,7 @@ var
NewCatalogDir: string;
search: TFindRec;
begin
try
// Upgrade an 1.x style-catalog by moving it to {appdata}
OldCatalogDir := OldInstallFolder('') + '\Catalog\';
Log('-- Migrate style catalogs --');
@ -423,6 +435,9 @@ begin
end
else
Log('No existing style catalog collection found');
except
Log('An exception occurred while trying to migrate style catalogues.');
end;
end;
@ -520,6 +535,9 @@ begin
page.SetText('Uninstallation complete', '');
page.SetProgress(totalitems, totalitems);
except
Log('An exception occurred while trying to uninstall a legacy version');
finally
shortcut_list.Free;
file_list.Free;
@ -565,8 +583,10 @@ begin
dir_list := TStringList.Create;
dir_list.LoadFromFile(ExpandConstant('{tmp}\old_dirlist.txt'));
itemsdone := 0;
totalitems := file_list.Count + dir_list.Count + shortcut_list.Count + locale_list.Count + 1;
// One extra for the start menu folder
totalitems := file_list.Count + dir_list.Count + shortcut_list.Count + locale_list.Count + 2;
// Two extra:
// - Start menu folder
// - Renaming Aegisub.exe to aegiub32.exe
StartMenuFolder := ExpandConstant('{commonprograms}\Aegisub\');
for i := 0 to shortcut_list.Count-1 do
@ -596,6 +616,13 @@ begin
itemsdone := itemsdone + 1;
end;
// This moving is done to help Windows' link tracking code be able to fix shortcuts
page.SetText('Moving EXE file to new name', 'Aegisub.exe');
page.SetProgress(itemsdone, totalitems);
Log('Rename Aegisub.exe to aegisub32.exe');
RenameFile(InstallFolder+'Aegisub.exe', InstallFolder+'aegisub32.exe');
itemsdone := itemsdone + 1;
for i := 0 to locale_list.Count-1 do
begin
curname := InstallFolder + locale_list.Strings[i];
@ -619,6 +646,9 @@ begin
page.SetText('Uninstallation complete', '');
page.SetProgress(totalitems, totalitems);
except
Log('An exception occurred while trying to clean up an older version');
finally
shortcut_list.Free;
file_list.Free;
@ -637,7 +667,7 @@ begin
begin
MigrateStyleCatalogs;
UninstallLegacyVersion;
end
end;
CleanUpOldVersion;
end;
end;

View File

@ -1,4 +1,3 @@
Aegisub.exe
Aegisub.pdb
aegisub32.exe
aegisub32.pdb