-
Notifications
You must be signed in to change notification settings - Fork 2
/
installer.iss
597 lines (506 loc) · 20.8 KB
/
installer.iss
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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
#include <.\idp\idp.iss>
#define PremiumizerInstallerVersion "v1.4"
#define AppId "{{26BFCD27-29AC-4FB0-B0A2-5484E0CDAB5B}"
#define AppName "Premiumizer"
#define AppVersion "master"
#define AppPublisher "Premiumizer"
#define AppURL "https://github.com/neox387/premiumizer"
#define AppServiceName AppName
#define AppServiceDescription "Cloud Downloader Premiumize.me"
#define ServiceStartIcon "{group}\Start " + AppName + " Service"
#define ServiceStopIcon "{group}\Stop " + AppName + " Service"
#define InstallerVersion 1040
#define InstallerSeedUrl "https://raw.github.com/neox387/PremiumizerInstaller/master/seed.ini"
#define AppRepoUrl "https://github.com/neox387/premiumizer.git"
#define nzbtomediaRepoUrl "https://github.com/clinton-hall/nzbToMedia.git"
[Setup]
AppId={#AppId}
AppName={#AppName}
AppVersion={#AppVersion}
AppVerName={#AppName} ({#AppVersion})
AppPublisher={#AppPublisher}
AppPublisherURL={#AppURL}
AppSupportURL={#AppURL}
AppUpdatesURL={#AppURL}
DefaultDirName={sd}\{#AppName}
DefaultGroupName={#AppName}
AllowNoIcons=yes
ArchitecturesInstallIn64BitMode=x64
UninstallDisplayIcon={app}\Installer\prem.ico
OutputBaseFilename={#AppName}Installer
UninstallFilesDir={app}\Installer
ExtraDiskSpaceRequired=350000000
SetupIconFile=assets\prem.ico
InternalCompressLevel=max
SolidCompression=True
SetupLogging=yes
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "utils\VC_redist.x64.exe"; Flags: dontcopy
Source: "assets\github.ico"; DestDir: "{app}\Installer"
Source: "assets\prem.ico"; DestDir: "{app}\Installer"
Source: "utils\nssm64.exe"; DestDir: "{app}\Installer"; DestName: "nssm.exe"
[Icons]
Name: "{group}\{#AppName}"; Filename: "http://127.0.0.1:5000/"; IconFilename: "{app}\Installer\prem.ico"
Name: "{commondesktop}\{#AppName}"; Filename: "http://127.0.0.1:5000/"; IconFilename: "{app}\Installer\prem.ico"; Tasks: desktopicon
Name: "{group}\{#AppName} on GitHub"; Filename: "{#AppRepoUrl}"; IconFilename: "{app}\Installer\github.ico"; Flags: excludefromshowinnewinstall
Name: "{#ServiceStartIcon}"; Filename: "{app}\Installer\nssm.exe"; Parameters: "start ""{#AppServiceName}"""; Flags: excludefromshowinnewinstall
Name: "{#ServiceStopIcon}"; Filename: "{app}\Installer\nssm.exe"; Parameters: "stop ""{#AppServiceName}"""; Flags: excludefromshowinnewinstall
Name: "{group}\Edit {#AppName} Service"; Filename: "{app}\Installer\nssm.exe"; Parameters: "edit ""{#AppServiceName}"""; AfterInstall: ModifyServiceLinks; Flags: excludefromshowinnewinstall
[Run]
Filename: "{app}\Git\cmd\git.exe"; Parameters: "clone {#AppRepoUrl} {app}\{#AppName}"; StatusMsg: "Installing {#AppName}..."
Filename: "{app}\Git\cmd\git.exe"; Parameters: "clone {#NzbToMediaRepoUrl} {app}\{#AppName}\nzbtomedia"; StatusMsg: "Installing NzbTomedia..."
Filename: "{tmp}\VC_redist.x64.exe"; Parameters: "/install /quiet /norestart"; StatusMsg: "Installing Visual C++..."
Filename: "{app}\Python\python.exe"; Parameters: "-m pip install --upgrade pip"; StatusMsg: "Upgrading pip..."
Filename: "{app}\Python\python.exe"; Parameters: "-m pip install pywin32"; StatusMsg: "Installing Pywin32..."
Filename: "{app}\Python\python.exe"; Parameters: "-m pip install -r {app}\{#AppName}\requirements.txt"; StatusMsg: "Installing Premiumizer dependencies"
Filename: "{app}\Installer\nssm.exe"; Parameters: "start ""{#AppServiceName}"""; Flags: runhidden; BeforeInstall: CreateService; StatusMsg: "Starting {#AppName} service..."
Filename: "{sys}\services.msc"; WorkingDir: {sys}; Flags: shellexec postinstall; Description: "Open Services.msc to change user log on for Premiumizer to your account"
Filename: "notepad"; Parameters: "{app}\{#AppName}\nzbtomedia\autoProcessMedia.cfg.spec"; Flags: postinstall shellexec; Description: "Open NzbToMedia config file SAVE IT AS autoProcessMedia.cfg"
Filename: "http://127.0.0.1:5000/"; Flags: postinstall shellexec unchecked; Description: "Open {#AppName} in browser"
[UninstallRun]
Filename: "{app}\Installer\nssm.exe"; Parameters: "remove ""{#AppServiceName}"" confirm"; Flags: runhidden
[UninstallDelete]
Type: filesandordirs; Name: "{app}\{#AppName}"
Type: filesandordirs; Name: "{app}\Installer"
Type: dirifempty; Name: "{app}"
[Messages]
WelcomeLabel2=This will install [name/ver] on your computer.%n%nYou will need Internet connectivity in order to download the required packages.
AboutSetupNote=PremiumizerInstaller {#PremiumizerInstallerVersion}
BeveledLabel=PremiumizerInstaller {#PremiumizerInstallerVersion}
[Code]
type
TDependency = record
Name: String;
URL: String;
Filename: String;
Size: Integer;
SHA1: String;
end;
IShellLinkW = interface(IUnknown)
'{000214F9-0000-0000-C000-000000000046}'
procedure Dummy;
procedure Dummy2;
procedure Dummy3;
function GetDescription(pszName: String; cchMaxName: Integer): HResult;
function SetDescription(pszName: String): HResult;
function GetWorkingDirectory(pszDir: String; cchMaxPath: Integer): HResult;
function SetWorkingDirectory(pszDir: String): HResult;
function GetArguments(pszArgs: String; cchMaxPath: Integer): HResult;
function SetArguments(pszArgs: String): HResult;
function GetHotkey(var pwHotkey: Word): HResult;
function SetHotkey(wHotkey: Word): HResult;
function GetShowCmd(out piShowCmd: Integer): HResult;
function SetShowCmd(iShowCmd: Integer): HResult;
function GetIconLocation(pszIconPath: String; cchIconPath: Integer;
out piIcon: Integer): HResult;
function SetIconLocation(pszIconPath: String; iIcon: Integer): HResult;
function SetRelativePath(pszPathRel: String; dwReserved: DWORD): HResult;
function Resolve(Wnd: HWND; fFlags: DWORD): HResult;
function SetPath(pszFile: String): HResult;
end;
IPersist = interface(IUnknown)
'{0000010C-0000-0000-C000-000000000046}'
function GetClassID(var classID: TGUID): HResult;
end;
IPersistFile = interface(IPersist)
'{0000010B-0000-0000-C000-000000000046}'
function IsDirty: HResult;
function Load(pszFileName: String; dwMode: Longint): HResult;
function Save(pszFileName: String; fRemember: BOOL): HResult;
function SaveCompleted(pszFileName: String): HResult;
function GetCurFile(out pszFileName: String): HResult;
end;
IShellLinkDataList = interface(IUnknown)
'{45E2B4AE-B1C3-11D0-B92F-00A0C90312E1}'
procedure Dummy;
procedure Dummy2;
procedure Dummy3;
function GetFlags(out dwFlags: DWORD): HResult;
function SetFlags(dwFlags: DWORD): HResult;
end;
const
WM_CLOSE = $0010;
GENERIC_WRITE = $40000000;
GENERIC_READ = $80000000;
OPEN_EXISTING = 3;
INVALID_HANDLE_VALUE = $FFFFFFFF;
SLDF_RUNAS_USER = $00002000;
CLSID_ShellLink = '{00021401-0000-0000-C000-000000000046}';
var
// This lets AbortInstallation() terminate setup without prompting the user
CancelWithoutPrompt: Boolean;
ErrorMessage, LocalFilesDir: String;
SeedDownloadPageId, DependencyDownloadPageId: Integer;
PythonDep, GitDep: TDependency;
InstallDepPage: TOutputProgressWizardPage;
// Import some Win32 functions
function CreateFile(
lpFileName: String;
dwDesiredAccess: LongWord;
dwSharedMode: LongWord;
lpSecurityAttributes: LongWord;
dwCreationDisposition: LongWord;
dwFlagsAndAttributes: LongWord;
hTemplateFile: LongWord): LongWord;
external 'CreateFileW@kernel32.dll stdcall';
function CloseHandle(hObject: LongWord): Boolean;
external 'CloseHandle@kernel32.dll stdcall';
procedure AbortInstallation(ErrorMessage: String);
begin
MsgBox(ErrorMessage + #13#10#13#10 'Setup will now terminate.', mbError, 0)
CancelWithoutPrompt := True
PostMessage(WizardForm.Handle, WM_CLOSE, 0, 0);
end;
procedure CheckInstallerVersion(SeedFile: String);
var
InstallerVersion, CurrentVersion: Integer;
DownloadUrl: String;
begin
InstallerVersion := StrToInt(ExpandConstant('{#InstallerVersion}'))
CurrentVersion := GetIniInt('Installer', 'Version', 0, 0, MaxInt, SeedFile)
if CurrentVersion = 0 then begin
AbortInstallation('Unable to parse configuration.')
end;
if CurrentVersion > InstallerVersion then begin
DownloadUrl := GetIniString('Installer', 'DownloadUrl', ExpandConstant('{#AppURL}'), SeedFile)
AbortInstallation(ExpandConstant('This is an old version of the {#AppName} installer. Please get the latest version at:') + #13#10#13#10 + DownloadUrl)
end;
end;
procedure ParseDependency(var Dependency: TDependency; Name, SeedFile: String);
var
LocalFile: String;
begin
Dependency.Name := Name;
Dependency.URL := GetIniString(Name, 'url', '', SeedFile)
Dependency.Filename := Dependency.URL
Dependency.Size := GetIniInt(Name, 'size', 0, 0, MaxInt, SeedFile)
Dependency.SHA1 := GetIniString(Name, 'sha1', '', SeedFile)
if (Dependency.URL = '') or (Dependency.Size = 0) or (Dependency.SHA1 = '') then begin
AbortInstallation('Error parsing dependency information for ' + Name + '.')
end;
while Pos('/', Dependency.Filename) <> 0 do begin
Delete(Dependency.Filename, 1, Pos('/', Dependency.Filename))
end;
if LocalFilesDir <> '' then begin
LocalFile := LocalFilesDir + '\' + Dependency.Filename
end;
if (LocalFile <> '') and (FileExists(LocalFile)) then begin
FileCopy(LocalFile, ExpandConstant('{tmp}\') + Dependency.Filename, True)
end else begin
idpAddFileSize(Dependency.URL, ExpandConstant('{tmp}\') + Dependency.Filename, Dependency.Size)
end
end;
procedure ParseSeedFile();
var
SeedFile: String;
DownloadPage: TWizardPage;
begin
SeedFile := ExpandConstant('{tmp}\installer.ini')
// Make sure we're running the latest version of the installer
CheckInstallerVersion(SeedFile)
ParseDependency(PythonDep, 'Python.x64' , SeedFile)
ParseDependency(GitDep, 'Git.x64' , SeedFile)
DependencyDownloadPageId := idpCreateDownloadForm(wpPreparing)
DownloadPage := PageFromID(DependencyDownloadPageId)
DownloadPage.Caption := 'Downloading Dependencies'
DownloadPage.Description := ExpandConstant('Setup is downloading {#AppName} dependencies...')
idpSetOption('DetailedMode', '1')
idpSetOption('DetailsButton', '0')
idpConnectControls()
end;
procedure InitializeSeedDownload();
var
DownloadPage: TWizardPage;
Seed: String;
IsRemote: Boolean;
begin
IsRemote := True
Seed := ExpandConstant('{param:SEED}')
if (Lowercase(Copy(Seed, 1, 7)) <> 'http://') and (Lowercase(Copy(Seed, 1, 8)) <> 'https://') then begin
if Seed = '' then begin
Seed := ExpandConstant('{#InstallerSeedUrl}')
end else begin
if FileExists(Seed) then begin
IsRemote := False
end else begin
MsgBox('Invalid SEED specified: ' + Seed, mbError, 0)
Seed := ExpandConstant('{#InstallerSeedUrl}')
end;
end;
end;
if not IsRemote then begin
FileCopy(Seed, ExpandConstant('{tmp}\installer.ini'), False)
ParseSeedFile()
end else begin
// Download the installer seed INI file
// I'm adding a dummy size here otherwise the installer crashes (divide by 0)
// when runnning in silent mode, a bug in IDP maybe?
idpAddFileSize(Seed, ExpandConstant('{tmp}\installer.ini'), 1024)
SeedDownloadPageId := idpCreateDownloadForm(wpWelcome)
DownloadPage := PageFromID(SeedDownloadPageId)
DownloadPage.Caption := 'Downloading Installer Configuration'
DownloadPage.Description := 'Setup is downloading it''s configuration file...'
idpConnectControls()
end;
end;
function CheckFileInUse(Filename: String): Boolean;
var
FileHandle: LongWord;
begin
if not FileExists(Filename) then begin
Result := False
exit
end;
FileHandle := CreateFile(Filename, GENERIC_READ or GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0)
if (FileHandle <> 0) and (FileHandle <> INVALID_HANDLE_VALUE) then begin
CloseHandle(FileHandle)
Result := False
end else begin
Result := True
end;
end;
procedure CreateService();
var
Nssm: String;
ResultCode: Integer;
OldProgressString: String;
begin
Nssm := ExpandConstant('{app}\Installer\nssm.exe')
OldProgressString := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := ExpandConstant('Installing {#AppName} service...')
Exec(Nssm, ExpandConstant('install "{#AppServiceName}" "{app}\Python\python.exe" """{app}\{#AppName}\premiumizer\Premiumizer.py""" --windows'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
Exec(Nssm, ExpandConstant('set "{#AppServiceName}" AppDirectory "{app}\{#AppName}"'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
Exec(Nssm, ExpandConstant('set "{#AppServiceName}" Description "{#AppServiceDescription}"'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
Exec(Nssm, ExpandConstant('set "{#AppServiceName}" AppStopMethodSkip 6'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
Exec(Nssm, ExpandConstant('set "{#AppServiceName}" AppStopMethodConsole 20000'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
Exec(Nssm, ExpandConstant('set "{#AppServiceName}" AppRestartDelay 2000'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
Exec(Nssm, ExpandConstant('set "{#AppServiceName}" AppEnvironmentExtra "PATH={app}\Git\cmd;%PATH%" "PATH={app}\Python;%PATH%"'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
WizardForm.StatusLabel.Caption := OldProgressString;
end;
procedure StopService();
var
Nssm: String;
ResultCode: Integer;
Retries: Integer;
OldProgressString: String;
begin
Retries := 30
OldProgressString := UninstallProgressForm.StatusLabel.Caption;
UninstallProgressForm.StatusLabel.Caption := ExpandConstant('Stopping {#AppName} service...')
Nssm := ExpandConstant('{app}\Installer\nssm.exe')
Exec(Nssm, ExpandConstant('stop "{#AppServiceName}"'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
while (Retries > 0) and (CheckFileInUse(Nssm)) do begin
UninstallProgressForm.StatusLabel.Caption := ExpandConstant('Waiting for {#AppName} service to stop (') + IntToStr(Retries) + ')...'
Sleep(1000)
Retries := Retries - 1
end;
UninstallProgressForm.StatusLabel.Caption := OldProgressString;
end;
procedure CleanPython();
var
PythonPath: String;
begin
PythonPath := ExpandConstant('{app}\Python')
DelTree(PythonPath + '\*.msi', False, True, False)
DelTree(PythonPath + '\Doc', True, True, True)
DelTree(PythonPath + '\Lib\test\*.*', False, True, True)
DelTree(PythonPath + '\tcl', True, True, True)
DelTree(PythonPath + '\Tools', True, True, True)
end;
procedure InstallPython();
var
ResultCode: Integer;
begin
InstallDepPage.SetText('Installing Python...', '')
Exec(ExpandConstantEx('{tmp}\{filename}', 'filename', PythonDep.Filename), ExpandConstant('TargetDir="{app}\Python" /quiet Include_launcher=0 Include_test=0'), '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
CleanPython();
ExtractTemporaryFile('VC_redist.x64.exe');
InstallDepPage.SetProgress(InstallDepPage.ProgressBar.Position+1, InstallDepPage.ProgressBar.Max)
end;
procedure InstallGit();
var
ResultCode: Integer;
begin
InstallDepPage.SetText('Installing Git...', '')
Exec(ExpandConstantEx('{tmp}\{filename}', 'filename', GitDep.Filename), ExpandConstant('/DIR="{app}\Git" /VERYSILENT'), '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
InstallDepPage.SetProgress(InstallDepPage.ProgressBar.Position+1, InstallDepPage.ProgressBar.Max)
end;
function VerifyDependency(Dependency: TDependency): Boolean;
begin
Result := True
InstallDepPage.SetText('Verifying dependency files...', Dependency.Filename)
if GetSHA1OfFile(ExpandConstant('{tmp}\') + Dependency.Filename) <> Dependency.SHA1 then begin
MsgBox('SHA1 hash of ' + Dependency.Filename + ' does not match.', mbError, 0)
Result := False
end;
InstallDepPage.SetProgress(InstallDepPage.ProgressBar.Position+1, InstallDepPage.ProgressBar.Max)
end;
function VerifyDependencies(): Boolean;
begin
Result := True
Result := Result and VerifyDependency(PythonDep)
Result := Result and VerifyDependency(GitDep)
end;
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
if ErrorMessage <> '' then begin
Result := ErrorMessage
end;
end;
procedure InstallDependencies();
begin
try
InstallDepPage.Show
InstallDepPage.SetProgress(0, 6)
InstallPython()
InstallGit()
finally
InstallDepPage.Hide
end;
end;
procedure InitializeWizard();
begin
InitializeSeedDownload()
idpInitMessages()
InstallDepPage := CreateOutputProgressPage('Installing Dependencies', ExpandConstant('Setup is installing {#AppName} dependencies...'));
end;
function ShellLinkRunAsAdmin(LinkFilename: String): Boolean;
var
Obj: IUnknown;
SL: IShellLinkW;
PF: IPersistFile;
DL: IShellLinkDataList;
Flags: DWORD;
begin
try
Obj := CreateComObject(StringToGuid(CLSID_ShellLink));
SL := IShellLinkW(Obj);
PF := IPersistFile(Obj);
// Load the ShellLink
OleCheck(PF.Load(LinkFilename, 0));
// Set the SLDF_RUNAS_USER flag
DL := IShellLinkDataList(Obj);
OleCheck(DL.GetFlags(Flags))
OleCheck(DL.SetFlags(Flags or SLDF_RUNAS_USER))
// Save the ShellLink
OleCheck(PF.Save(LinkFilename, True));
Result := True
except
Result := False
end;
end;
procedure ModifyServiceLinks();
begin
ShellLinkRunAsAdmin(ExpandConstant('{#ServiceStartIcon}.lnk'))
ShellLinkRunAsAdmin(ExpandConstant('{#ServiceStopIcon}.lnk'))
end;
function InitializeSetup(): Boolean;
begin
CancelWithoutPrompt := False
LocalFilesDir := ExpandConstant('{param:LOCALFILES}')
if (LocalFilesDir <> '') and (not DirExists(LocalFilesDir)) then begin
MsgBox('Invalid LOCALFILES specified: ' + LocalFilesDir, mbError, 0)
LocalFilesDir := ''
end;
// Don't allow installations over top
begin
Result := True
end;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True
if CurPageID = SeedDownloadPageId then begin
ParseSeedFile()
end;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm := not CancelWithoutPrompt;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then begin
// Stop service
StopService()
end;
end;
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo,
MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
begin
Result := MemoDirInfo + NewLine + NewLine + \
MemoGroupInfo + NewLine + NewLine + \
'Download and install dependencies:' + NewLine + \
Space + 'Git' + NewLine + \
Space + 'Python'
if MemoTasksInfo <> '' then begin
Result := Result + NewLine + NewLine + MemoTasksInfo
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then begin
InstallDependencies()
end;
end;
function GetAppID():string;
begin
result := ExpandConstant('{#SetupSetting("AppID")}');
end;
function GetAppUninstallRegKey():string;
begin
result := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\' + GetAppID + '_is1'); //Get the Uninstall search path from the Registry
end;
function IsAppInstalled():boolean;
var Key : string; //Registry path to details about the current installation (uninstall info)
begin
Key := GetAppUninstallRegKey;
result := RegValueExists(HKEY_LOCAL_MACHINE, Key, 'UninstallString');
end;
//Return the install path used by the existing installation.
function GetInstalledPath():string;
var Key : string;
begin
Key := GetAppUninstallRegKey;
RegQueryStringValue(HKEY_LOCAL_MACHINE, Key, 'InstallLocation', result);
end;
function MoveLogfileToLogDir():boolean;
var
logfilepathname, logfilename, newfilepathname: string;
begin
logfilepathname := expandconstant('{log}');
//If logfile is disabled then logfilepathname is empty
if logfilepathname = '' then begin
result := false;
exit;
end;
logfilename := ExtractFileName(logfilepathname);
try
//Get the install path by first checking for existing installation thereafter by GUI settings
if IsAppInstalled then
newfilepathname := GetInstalledPath + '\Installer\'
else
newfilepathname := expandconstant('{app}\Installer\');
except
//This exception is raised if {app} is invalid i.e. if canceled is pressed on the Welcome page
try
newfilepathname := WizardDirValue + '\Installer\';
except
//This exception is raised if WizardDirValue i s invalid i.e. if canceled is pressed on the Mutex check message dialog.
result := false;
end;
end;
result := ForceDirectories(newfilepathname); //Make sure the destination path exists.
newfilepathname := newfilepathname + logfilename; //Add filename
//if copy successful then delete logfilepathname
result := filecopy(logfilepathname, newfilepathname, false);
if result then
result := DeleteFile(logfilepathname);
end;
//Called just before Setup terminates. Note that this function is called even if the user exits Setup before anything is installed.
procedure DeinitializeSetup();
begin
MoveLogfileToLogDir;
end;