-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller.iss
More file actions
185 lines (158 loc) · 4.78 KB
/
Copy pathinstaller.iss
File metadata and controls
185 lines (158 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
[Setup]
AppName=Golt Runtime
AppVersion=1.0.3
AppPublisher=Aztekode
AppPublisherURL=https://github.com/Aztekode/golt
AppId={{A4F7B7A7-9E0D-4C0D-9DA7-1C7C4C8C2F35}
DefaultDirName={autopf}\Golt
DefaultGroupName=Golt
DisableProgramGroupPage=yes
OutputBaseFilename=GoltSetup_v1.0.3_windows_amd64
Compression=lzma
SolidCompression=yes
PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=dialog
ChangesEnvironment=yes
UninstallDisplayIcon={app}\golt.exe
SetupIconFile=assets\installer\golt.ico
WizardImageFile=assets\installer\wizard.bmp
WizardSmallImageFile=assets\installer\wizard-small.bmp
#define GoltPfxPath GetEnv("GOLT_PFX_PATH")
#define GoltPfxPass GetEnv("GOLT_PFX_PASSWORD")
#define GoltTimestampUrl GetEnv("GOLT_TIMESTAMP_URL")
#define GoltSigningEnabled (GoltPfxPath != "") && (GoltPfxPass != "")
#if GoltSigningEnabled
SignTool=signtool
SignedUninstaller=yes
#endif
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
[Tasks]
Name: "envPath"; Description: "Add Golt to the PATH (Recommended)"; GroupDescription: "System Integration:"
Name: "examples"; Description: "Install examples"; GroupDescription: "Extras:"
Name: "desktopicon"; Description: "Create a desktop icon"; GroupDescription: "Shortcuts:"
[Files]
#if GoltSigningEnabled
Source: "golt.exe"; DestDir: "{app}"; Flags: ignoreversion; SignTool: signtool
#else
Source: "golt.exe"; DestDir: "{app}"; Flags: ignoreversion
#endif
Source: "examples\*"; DestDir: "{app}\examples"; Flags: ignoreversion recursesubdirs; Tasks: examples
[Icons]
Name: "{group}\Golt Runtime"; Filename: "{app}\golt.exe"
Name: "{group}\Uninstall Golt Runtime"; Filename: "{uninstallexe}"
Name: "{commondesktop}\Golt Runtime"; Filename: "{app}\golt.exe"; Tasks: desktopicon
[Code]
function GetPathRootKey(): Integer;
begin
if IsAdminInstallMode() then
Result := HKEY_LOCAL_MACHINE
else
Result := HKEY_CURRENT_USER;
end;
function GetPathSubkey(): string;
begin
if IsAdminInstallMode() then
Result := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
else
Result := 'Environment';
end;
function GetAppRegSubkey(): string;
begin
Result := 'Software\Aztekode\Golt';
end;
procedure WriteAddedToPathFlag();
begin
RegWriteStringValue(GetPathRootKey(), GetAppRegSubkey(), 'AddedToPath', '1');
end;
function WasAddedToPath(): Boolean;
var
Value: string;
begin
if RegQueryStringValue(GetPathRootKey(), GetAppRegSubkey(), 'AddedToPath', Value) then
Result := Value = '1'
else
Result := False;
end;
function NormalizePathList(Value: string): string;
begin
Result := Trim(Value);
while Pos(';;', Result) > 0 do
StringChangeEx(Result, ';;', ';', True);
while (Length(Result) > 0) and (Copy(Result, 1, 1) = ';') do
Delete(Result, 1, 1);
while (Length(Result) > 0) and (Copy(Result, Length(Result), 1) = ';') do
Delete(Result, Length(Result), 1);
end;
function ReadPathValue(): string;
var
OrigPath: string;
begin
if RegQueryStringValue(GetPathRootKey(), GetPathSubkey(), 'Path', OrigPath) then
Result := OrigPath
else
Result := '';
end;
procedure WritePathValue(Value: string);
begin
RegWriteExpandStringValue(GetPathRootKey(), GetPathSubkey(), 'Path', Value);
end;
function HasPathEntry(PathValue: string; Entry: string): Boolean;
begin
Result := Pos(';' + Lowercase(Entry) + ';', ';' + Lowercase(PathValue) + ';') > 0;
end;
procedure AddToPath(Entry: string);
var
OrigPath: string;
NewPath: string;
begin
OrigPath := NormalizePathList(ReadPathValue());
if HasPathEntry(OrigPath, Entry) then
exit;
if OrigPath = '' then
NewPath := Entry
else
NewPath := OrigPath + ';' + Entry;
WritePathValue(NewPath);
end;
procedure RemoveFromPath(Entry: string);
var
OrigPath: string;
WorkPath: string;
Needle: string;
begin
OrigPath := NormalizePathList(ReadPathValue());
WorkPath := ';' + OrigPath + ';';
Needle := ';' + Entry + ';';
StringChangeEx(WorkPath, Needle, ';', True);
WorkPath := NormalizePathList(WorkPath);
WritePathValue(WorkPath);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
if WizardIsTaskSelected('envPath') then
begin
AddToPath(ExpandConstant('{app}'));
WriteAddedToPathFlag();
end;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
begin
if WasAddedToPath() then
RemoveFromPath(ExpandConstant('{app}'));
end;
end;
[SignTool]
#if GoltSigningEnabled
#if GoltTimestampUrl != ""
Name: "signtool"; Parameters: "sign /fd sha256 /td sha256 /f ""{#GoltPfxPath}"" /p ""{#GoltPfxPass}"" /tr ""{#GoltTimestampUrl}"" ""$f"""
#else
Name: "signtool"; Parameters: "sign /fd sha256 /td sha256 /f ""{#GoltPfxPath}"" /p ""{#GoltPfxPass}"" ""$f"""
#endif
#endif