Skip to content

Commit 50d3084

Browse files
brsonalexcrichton
authored andcommitted
---
yaml --- r: 150811 b: refs/heads/try2 c: 8f3c2a6 h: refs/heads/master i: 150809: 73cfe8d 150807: f1f187f v: v3
1 parent bf38740 commit 50d3084

File tree

5 files changed

+76
-4
lines changed

5 files changed

+76
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: a5dcbc66db50f338617cb4149c1f8a5cf6b1633c
8+
refs/heads/try2: 8f3c2a6ffdd578eb0213c365fa75e9622167d63e
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/dist.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ PKG_EXE = dist/$(PKG_NAME)-install.exe
118118
%.ico: $(S)src/etc/pkg/%.ico
119119
cp $< $@
120120

121-
$(PKG_EXE): rust.iss modpath.iss LICENSE.txt rust-logo.ico \
121+
$(PKG_EXE): rust.iss modpath.iss upgrade.iss LICENSE.txt rust-logo.ico \
122122
$(CSREQ3_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
123123
dist-prepare-win
124124
$(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py tmp/dist/win/bin

branches/try2/src/etc/pkg/modpath.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ begin
164164
end;
165165
166166
167-
procedure CurStepChanged(CurStep: TSetupStep);
167+
procedure ModPathCurStepChanged(CurStep: TSetupStep);
168168
var
169169
taskname: String;
170170
begin

branches/try2/src/etc/pkg/rust.iss

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,15 @@ begin
4949
setArrayLength(Result, 1)
5050
Result[0] := ExpandConstant('{app}\bin');
5151
end;
52-
#include "modpath.iss"
52+
53+
#include "modpath.iss"
54+
#include "upgrade.iss"
55+
56+
// Both modpath.iss and upgrade.iss want to overload CurStepChanged.
57+
// This version does the overload then delegates to each.
58+
59+
procedure CurStepChanged(CurStep: TSetupStep);
60+
begin
61+
UpgradeCurStepChanged(CurStep);
62+
ModPathCurStepChanged(CurStep);
63+
end;

branches/try2/src/etc/pkg/upgrade.iss

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// The following code taken from https://stackoverflow.com/questions/2000296/innosetup-how-to-automatically-uninstall-previous-installed-version
2+
// It performs upgrades by running the uninstaller before the install
3+
4+
/////////////////////////////////////////////////////////////////////
5+
function GetUninstallString(): String;
6+
var
7+
sUnInstPath: String;
8+
sUnInstallString: String;
9+
begin
10+
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\Rust_is1');
11+
sUnInstallString := '';
12+
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
13+
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
14+
Result := sUnInstallString;
15+
end;
16+
17+
18+
/////////////////////////////////////////////////////////////////////
19+
function IsUpgrade(): Boolean;
20+
begin
21+
Result := (GetUninstallString() <> '');
22+
end;
23+
24+
25+
/////////////////////////////////////////////////////////////////////
26+
function UnInstallOldVersion(): Integer;
27+
var
28+
sUnInstallString: String;
29+
iResultCode: Integer;
30+
begin
31+
// Return Values:
32+
// 1 - uninstall string is empty
33+
// 2 - error executing the UnInstallString
34+
// 3 - successfully executed the UnInstallString
35+
36+
// default return value
37+
Result := 0;
38+
39+
// get the uninstall string of the old app
40+
sUnInstallString := GetUninstallString();
41+
if sUnInstallString <> '' then begin
42+
sUnInstallString := RemoveQuotes(sUnInstallString);
43+
if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
44+
Result := 3
45+
else
46+
Result := 2;
47+
end else
48+
Result := 1;
49+
end;
50+
51+
/////////////////////////////////////////////////////////////////////
52+
procedure UpgradeCurStepChanged(CurStep: TSetupStep);
53+
begin
54+
if (CurStep=ssInstall) then
55+
begin
56+
if (IsUpgrade()) then
57+
begin
58+
UnInstallOldVersion();
59+
end;
60+
end;
61+
end;

0 commit comments

Comments
 (0)