-
Notifications
You must be signed in to change notification settings - Fork 326
Expand file tree
/
Copy pathinstaller.iss
More file actions
407 lines (368 loc) · 15.8 KB
/
installer.iss
File metadata and controls
407 lines (368 loc) · 15.8 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
#define RetroBarName "RetroBar"
#define RetroBarPublisher "Sam Johnson"
#define RetroBarURL "https://github.com/dremin/RetroBar"
#define RetroBarReleasesURL RetroBarURL + "/releases"
#define RetroBarExeName "RetroBar.exe"
#define DotNetVersionDownload "6.0.36"
#define DotNetVersionMinimum "6.0.2"
#define DotNetVersionMaximum "6.1.0"
#define DotNetInstallerExe "RetroBar_DotNetRuntimeInstaller.exe"
#define DotNetInstallerTitle "Microsoft .NET 6 Desktop Runtime"
#define TargetFramework "net6.0-windows"
#define ReleasePath "RetroBar\bin\Release\" + TargetFramework
#define Excludes "Languages,Themes,Resources,System.Diagnostics.EventLog.Messages.dll"
#define Major
#define Minor
#define Revision
#define RetroBarVersion GetVersionComponents(ReleasePath + "\publish-x64\" + RetroBarExeName, Major, Minor, Revision, null), Str(Major) + "." + Str(Minor) + "." + Str(Revision)
#define VersionURL "https://dremin.github.io/updates/retrobar.json"
[Setup]
AppId={{574527FE-00A4-4F85-92AD-B4B8B4077D73}
AppMutex={#RetroBarName}
AppName={#RetroBarName}
AppVersion={#RetroBarVersion}
AppVerName={#RetroBarName} {#RetroBarVersion}
AppPublisher={#RetroBarPublisher}
AppPublisherURL={#RetroBarURL}
AppSupportURL={#RetroBarURL}
AppUpdatesURL={#RetroBarURL}
DefaultDirName={autopf}\{#RetroBarName}
UninstallDisplayIcon={app}\{#RetroBarExeName}
SetupMutex={#RetroBarName}Installer
SetupIconFile=RetroBar\Resources\retrobar.ico
ArchitecturesInstallIn64BitMode=x64compatible or arm64
DisableProgramGroupPage=yes
PrivilegesRequired=lowest
OutputBaseFilename=RetroBarInstaller
OutputDir=bin
Compression=lzma2
SolidCompression=yes
WizardStyle=modern
LicenseFile=DistLicense.txt
WizardImageFile=compiler:WizClassicImage.bmp
WizardSmallImageFile=compiler:WizClassicSmallImage.bmp
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "armenian"; MessagesFile: "compiler:Languages\Armenian.isl"
Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
Name: "bulgarian"; MessagesFile: "compiler:Languages\Bulgarian.isl"
Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl"
Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
Name: "korean"; MessagesFile: "compiler:Languages\Korean.isl"
Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
Name: "slovak"; MessagesFile: "compiler:Languages\Slovak.isl"
Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
Name: "swedish"; MessagesFile: "compiler:Languages\Swedish.isl"
Name: "tamil"; MessagesFile: "compiler:Languages\Tamil.isl"
Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"
[LangOptions]
spanish.LanguageName=español
polish.LanguageName=polski
russian.LanguageName=русский
french.LanguageName=français
[Messages]
spanish.StopDownload=¿Desea detener la descarga?
spanish.ExitSetupTitle=Salir de la instalación
spanish.SelectLanguageTitle=Seleccione el idioma de la instalación
spanish.WizardSelectTasks=Seleccione las tareas adicionales
spanish.WizardSelectDir=Seleccione la carpeta de destino
spanish.BrowseDialogTitle=Instalar: elegir una carpeta
spanish.WizardReady=Listo para instalar
spanish.WizardPreparing=Preparando la instalación
spanish.ConfirmUninstall=¿Seguro que desea desinstalar {#RetroBarName}?
spanish.WizardUninstalling=Estado de la desinstalación
spanish.TranslatorNote=Updated Spanish translation courtesy of Amaro Martínez for {#RetroBarPublisher}.
spanish.WizardLicense=Acuerdo de licencia
spanish.WizardSelectComponents=Seleccione los componentes
spanish.FullInstallation=Instalación completa
spanish.CompactInstallation=Instalación compacta
spanish.CustomInstallation=Instalación personalizada
spanish.NoUninstallWarningTitle=Componentes encontrados
spanish.ReadyMemoTasks=Tareas adicionales:
spanish.DirExistsTitle=La carpeta ya existe
spanish.DirExists=La carpeta "%1" ya existe. ¿Desea realizar la instalación en esa carpeta de todos modos?
[CustomMessages]
DependenciesMessage=Setup will also download and install required dependencies:
UpdateAvailableMessage=A new version of RetroBar is available!%n%nCurrent version: %s%nNew version: %s%n%nWould you like to visit the download page to get the latest version?
ConfirmDeleteSettingsMessage=Do you want to delete the RetroBar user settings?
InstallingDotNetRuntime=Installing {#DotNetInstallerTitle}...
spanish.DependenciesMessage=La instalación también descargará e instalará las dependencias necesarias:
spanish.UpdateAvailableMessage=¡Una nueva versión de RetroBar está disponible!%n%nVersión actual: %s%nNueva versión: %s%n%n¿Desea visitar la página de descarga para obtener la última versión?
spanish.ConfirmDeleteSettingsMessage=¿Desea eliminar su configuración de usuario de RetroBar?
spanish.InstallingDotNetRuntime=Instalando {#DotNetInstallerTitle}...
german.DependenciesMessage=Das Setup wird auch die erforderlichen Zusätze (Abhängigkeiten) herunterladen und installieren:
polish.DependenciesMessage=Instalator pobierze i zainstaluje także następujące składniki dodatkowe:
russian.DependenciesMessage=Установщик также загрузит и установит следующие дополнительные компоненты:
french.DependenciesMessage=Le programme d'installation téléchargera et installera également les dépendances requises:
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "autostart"; Description: "{cm:AutoStartProgram,{#RetroBarName}}"; GroupDescription: "{cm:AutoStartProgramGroupDescription}"; Flags: unchecked
[Files]
Source: "{#ReleasePath}\publish-ARM64\*"; DestDir: "{app}"; Check: PreferArm64Files; Flags: ignoreversion recursesubdirs; Excludes: "{#Excludes}"
Source: "{#ReleasePath}\publish-x64\*"; DestDir: "{app}"; Check: PreferX64Files; Flags: solidbreak ignoreversion recursesubdirs; Excludes: "{#Excludes}"
Source: "{#ReleasePath}\publish-x86\*"; DestDir: "{app}"; Check: PreferX86Files; Flags: solidbreak ignoreversion recursesubdirs; Excludes: "{#Excludes}"
Source: "{#ReleasePath}\publish-x64\System.Diagnostics.EventLog.Messages.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#ReleasePath}\publish-x64\Languages\*"; DestDir: "{app}\Languages"; Flags: ignoreversion recursesubdirs
Source: "{#ReleasePath}\publish-x64\Themes\*"; DestDir: "{app}\Themes"; Flags: ignoreversion recursesubdirs
Source: "{#ReleasePath}\publish-x64\Resources\*"; DestDir: "{app}\Resources"; Flags: ignoreversion recursesubdirs
[UninstallDelete]
Type: filesandordirs; Name: "{localappdata}\RetroBar\Logs"
Type: dirifempty; Name: "{localappdata}\RetroBar"
[Icons]
Name: "{autoprograms}\{#RetroBarName}"; Filename: "{app}\{#RetroBarExeName}"
Name: "{autodesktop}\{#RetroBarName}"; Filename: "{app}\{#RetroBarExeName}"; Tasks: desktopicon
[Registry]
Root: HKA; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueName: "RetroBar"; ValueType: string; ValueData: "{app}\{#RetroBarExeName}"; Tasks: autostart; Flags: uninsdeletevalue
[Run]
Filename: "{tmp}\{#DotNetInstallerExe}"; StatusMsg: "{cm:InstallingDotNetRuntime}"; Parameters:"/install /norestart"; Description: "{cm:LaunchProgram,{#RetroBarName}}"; Check: DotNetRuntimeIsMissing; Flags: skipifdoesntexist
Filename: "{app}\{#RetroBarExeName}"; Description: "{cm:LaunchProgram,{#RetroBarName}}"; Flags: nowait postinstall skipifsilent
[Code]
var
DownloadPage: TDownloadWizardPage;
DotNetChecked: boolean;
DotNetMissing: boolean;
function PreferArm64Files: Boolean;
begin
Result := IsArm64;
end;
function PreferX64Files: Boolean;
begin
Result := not PreferArm64Files and IsX64Compatible;
end;
function PreferX86Files: Boolean;
begin
Result := not PreferArm64Files and not PreferX64Files;
end;
// Version check courtesy https://engy.us/blog/2021/02/28/installing-net-5-runtime-automatically-with-inno-setup/
function CompareVersion(V1, V2: string): Integer;
var
P, N1, N2: Integer;
begin
Result := 0;
while (Result = 0) and ((V1 <> '') or (V2 <> '')) do
begin
P := Pos('.', V1);
if P > 0 then
begin
N1 := StrToInt(Copy(V1, 1, P - 1));
Delete(V1, 1, P);
end
else
if V1 <> '' then
begin
N1 := StrToInt(V1);
V1 := '';
end
else
begin
N1 := 0;
end;
P := Pos('.', V2);
if P > 0 then
begin
N2 := StrToInt(Copy(V2, 1, P - 1));
Delete(V2, 1, P);
end
else
if V2 <> '' then
begin
N2 := StrToInt(V2);
V2 := '';
end
else
begin
N2 := 0;
end;
if N1 < N2 then Result := -1
else
if N1 > N2 then Result := 1;
end;
end;
procedure CheckForUpdates;
var
LatestVersion: string;
CurrentVersion: string;
JSONStr: AnsiString;
PosStart, PosEnd: Integer;
MsgResult: Integer;
begin
CurrentVersion := '{#RetroBarVersion}';
try
DownloadTemporaryFile('{#VersionURL}', 'retrobar.json', '', nil);
except
Log('Failed to download update information: ' + GetExceptionMessage);
Exit;
end;
if LoadStringFromFile(ExpandConstant('{tmp}\retrobar.json'), JSONStr) then
begin
PosStart := Pos('"version": "', JSONStr) + Length('"version": "');
PosEnd := Pos('"', Copy(JSONStr, PosStart, Length(JSONStr))) + PosStart - 1;
LatestVersion := Copy(JSONStr, PosStart, PosEnd - PosStart);
case CompareVersion(CurrentVersion, LatestVersion) of
-1: begin
Log(Format('CheckForUpdates: Current version %s is older than latest version %s', [CurrentVersion, LatestVersion]));
MsgResult := MsgBox(Format(CustomMessage('UpdateAvailableMessage'), [CurrentVersion, LatestVersion]),
mbInformation, MB_YESNO);
if MsgResult = IDYES then
ShellExec('open', '{#RetroBarReleasesURL}', '', '', SW_SHOW, ewNoWait, MsgResult);
end;
0: Log(Format('CheckForUpdates: Current version %s matches latest version %s', [CurrentVersion, LatestVersion]));
1: Log(Format('CheckForUpdates: Current version %s is newer than latest version %s', [CurrentVersion, LatestVersion]));
end;
end
else
begin
Log('Failed to read the version information file.');
end;
end;
function DotNetRuntimeIsMissing(): Boolean;
var
runtimes: TArrayOfString;
registryKey: string;
I: Integer;
meetsMinimumVersion: Boolean;
meetsMaximumVersion: Boolean;
begin
Result := True;
if DotNetChecked then
begin
Result := DotNetMissing;
Exit;
end;
DotNetChecked := True;
DotNetMissing := True;
if PreferArm64Files() then
registryKey := 'SOFTWARE\WOW6432Node\dotnet\Setup\InstalledVersions\arm64\sharedfx\Microsoft.WindowsDesktop.App'
else if PreferX64Files() then
registryKey := 'SOFTWARE\WOW6432Node\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.WindowsDesktop.App'
else if PreferX86Files() then
registryKey := 'SOFTWARE\dotnet\Setup\InstalledVersions\x86\sharedfx\Microsoft.WindowsDesktop.App';
if RegGetValueNames(HKLM, registryKey, runtimes) then
begin
for I := 0 to GetArrayLength(runtimes)-1 do
begin
meetsMinimumVersion := not (CompareVersion(runtimes[I], '{#DotNetVersionMinimum}') = -1);
meetsMaximumVersion := CompareVersion(runtimes[I], '{#DotNetVersionMaximum}') = -1;
if meetsMinimumVersion and meetsMaximumVersion then
begin
Log(Format('[.NET] Selecting %s', [runtimes[I]]));
DotNetMissing := False;
Result := False;
Exit;
end;
end;
end;
end;
// To be used if we switch to a version that actually gets updates
// function DownloadDotNetVersion(baseVersion: String): Boolean;
// begin
// DownloadPage.Clear;
// DownloadPage.Add(Format('https://dotnetcli.azureedge.net/dotnet/WindowsDesktop/%s/latest.version', [baseVersion]), '{#DotNetVersionFile}', '');
// DownloadPage.Show;
// try
// try
// DownloadPage.Download; // This downloads the files to {tmp}
// Result := True;
// except
// if DownloadPage.AbortedByUser then
// Log('Aborted by user.')
// else
// SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
// Result := False;
// end;
// finally
// DownloadPage.Hide;
// end;
// end;
function DownloadDotNetRuntime(version: AnsiString): Boolean;
var
baseUrl: String;
begin
baseUrl := Format('https://dotnetcli.azureedge.net/dotnet/WindowsDesktop/%s/windowsdesktop-runtime-%s', [version, version]);
DownloadPage.Clear;
if PreferArm64Files() then
DownloadPage.Add(Format('%s-win-arm64.exe', [baseUrl]), '{#DotNetInstallerExe}', '')
else if PreferX64Files() then
DownloadPage.Add(Format('%s-win-x64.exe', [baseUrl]), '{#DotNetInstallerExe}', '')
else if PreferX86Files() then
DownloadPage.Add(Format('%s-win-x86.exe', [baseUrl]), '{#DotNetInstallerExe}', '');
DownloadPage.Show;
try
try
DownloadPage.Download; // This downloads the files to {tmp}
Result := True;
except
if DownloadPage.AbortedByUser then
Log('Aborted by user.')
else
SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
Result := False;
end;
finally
DownloadPage.Hide;
end;
end;
function OnDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean;
begin
if Progress = ProgressMax then
Log(Format('Successfully downloaded file to {tmp}: %s', [FileName]));
Result := True;
end;
// run CheckForUpdates
function InitializeSetup: Boolean;
begin
CheckForUpdates;
Result := True;
end;
procedure InitializeWizard;
begin
DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress);
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
if CurPageID = wpReady then begin
if not DotNetRuntimeIsMissing() then Exit;
// To be used if we switch to a version that actually gets updates
// if not DownloadDotNetVersion('6.0') then Exit;
// if not LoadStringFromFile(ExpandConstant('{tmp}\{#DotNetVersionFile}'), downloadVersion) then Exit;
// Allow the install to proceed even if the download fails
// The user will be prompted again when they launch RetroBar
DownloadDotNetRuntime('{#DotNetVersionDownload}');
end;
end;
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
begin
if DotNetRuntimeIsMissing() then Result := CustomMessage('DependenciesMessage') + NewLine + Space + '{#DotNetInstallerTitle}' + NewLine + NewLine;
Result := Result + MemoTasksInfo;
end;
// ask if user wants to delete the settings.json file
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
settingsPath: string;
begin
if CurUninstallStep <> usPostUninstall then
Exit;
settingsPath := ExpandConstant('{localappdata}\RetroBar\settings.json');
if FileExists(settingsPath) and
(MsgBox(CustomMessage('ConfirmDeleteSettingsMessage'), mbConfirmation, MB_YESNO) = IDYES) then
begin
if not DeleteFile(settingsPath) then
Log('Warning: Could not delete user settings file: ' + settingsPath);
end;
end;