This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathElixirWeb.iss
263 lines (230 loc) · 10.2 KB
/
ElixirWeb.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
; ElixirWeb.iss - Elixir Web Installer
; Copyright (c) Chris Hyndman
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; "Elixir" and the Elixir logo are copyright (c) 2012 Plataformatec.
#define COMPAT_MASK 1
#define ELIXIR_CSV_URL 'https://elixir-lang.org/elixir.csv'
#define ERLANG_CSV_URL 'https://elixir-lang.org/erlang.csv'
[Setup]
AppName=Elixir
AppVersion=2.4
OutputBaseFilename=elixir-websetup
SolidCompression=yes
; This installer doesn't install anything itself, it just runs other installers
CreateAppDir=no
Uninstallable=no
; The user will see the offline installer's finished page instead
DisableFinishedPage=yes
; Visual
SetupIconFile=assets\drop.ico
WizardImageFile=assets\drop_banner.bmp
WizardSmallImageFile=assets\null.bmp
DisableWelcomePage=no
[CustomMessages]
; The version string shouldn't show the version of this installer (AppVersion)
NameAndVersion=%1
[Files]
; Offline installer files
Source: "Elixir.iss"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "assets\drop.ico"; DestDir: "{tmp}\assets"; Flags: deleteafterinstall
Source: "assets\drop_banner.bmp"; DestDir: "{tmp}\assets"; Flags: deleteafterinstall
Source: "assets\null.bmp"; DestDir: "{tmp}\assets"; Flags: deleteafterinstall
Source: "src\Util.iss"; DestDir: "{tmp}\src"; Flags: deleteafterinstall
Source: "src\Path.iss"; DestDir: "{tmp}\src"; Flags: deleteafterinstall
Source: "src\ErlangInstall.iss"; DestDir: "{tmp}\src"; Flags: deleteafterinstall
; 7-Zip portable extractor
Source: "bin\7za.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
; Compiler files
Source: "compiler:Default.isl"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "compiler:ISCC.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "compiler:ISCmplr.dll"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "compiler:islzma.dll"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "compiler:ISPP.dll"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "compiler:ISPPBuiltins.iss"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "compiler:Setup.e32"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "compiler:SetupLdr.e32"; DestDir: "{tmp}"; Flags: deleteafterinstall
[Run]
; Run the Erlang installer if task is selected
Filename: "{tmp}\{code:GetScriptString|ErlangExe32}"; Flags: hidewizard; StatusMsg: "Installing {code:GetScriptString|ErlangName32}..."; Tasks: erlang\32
Filename: "{tmp}\{code:GetScriptString|ErlangExe64}"; Flags: hidewizard; StatusMsg: "Installing {code:GetScriptString|ErlangName64}..."; Tasks: erlang\64
; Extract the downloaded Precompiled.zip archive
Filename: "{tmp}\7za.exe"; Parameters: "x -oelixir Precompiled.zip"; WorkingDir: "{tmp}"; StatusMsg: "Extracting Precompiled.zip archive..."
; Compile the offline installer
Filename: "{tmp}\ISCC.exe"; Parameters: "/dSkipWelcome /dNoCompression Elixir.iss"; WorkingDir: "{tmp}"; StatusMsg: "Compiling Elixir installer..."; Tasks: not defer
; Use standard options for deferred install
Filename: "{tmp}\ISCC.exe"; Parameters: "Elixir.iss"; WorkingDir: "{tmp}"; StatusMsg: "Compiling Elixir installer..."; Tasks: defer
; Run the offline installer
Filename: "{tmp}\Output\elixir-v{code:GetScriptString|ElixirVersion}-setup.exe"; Flags: nowait postinstall; StatusMsg: "Starting Elixir installer..."; Tasks: not defer
; Or copy offline installer to same folder as web installer
Filename: "Robocopy.exe"; Parameters: "{tmp}\Output {src} elixir-v{code:GetScriptString|ElixirVersion}-setup.exe /IS"; Tasks: defer
[Tasks]
Name: "unins_previous"; Description: "Uninstall previous version at {code:GetScriptString|ElixirPreviousPath} (Recommended)"; Check: CheckPreviousVersionExists
Name: "erlang"; Description: "Install Erlang"; Flags: unchecked
Name: "erlang\32"; Description: "{code:GetScriptString|ErlangName32}"; Flags: exclusive unchecked
Name: "erlang\64"; Description: "{code:GetScriptString|ErlangName64}"; Flags: exclusive unchecked; Check: IsWin64
Name: "defer"; Description: "Defer installation (advanced)"; Flags: unchecked
[Code]
#include "src\Util.iss"
#include "src\Path.iss"
#include "src\TErlangData.iss"
#include "src\TElixirRelease.iss"
#include "src\ErlangInstall.iss"
#include "src\ElixirInstall.iss"
var
GlobalPageSelRelease: TInputOptionWizardPage;
GlobalPageDownload: TDownloadWizardPage;
GlobalElixirReleases: array of TElixirRelease;
GlobalErlangData: TErlangData;
GlobalElixirCSVFilePath: String;
GlobalErlangCSVFilePath: String;
CacheSelectedRelease: TElixirRelease;
function GetScriptString(Param: String): String;
begin
Result := '';
case (Param) of
'ErlangExe32': Result := GlobalErlangData.Exe32;
'ErlangExe64': Result := GlobalErlangData.Exe64;
'ErlangName32': Result := GlobalErlangData.Name32;
'ErlangName64': Result := GlobalErlangData.Name64;
'ElixirVersion': Result := CacheSelectedRelease.Version;
'ElixirPreviousPath': Result := GetPreviousAppPath();
end;
end;
procedure CurPageChanged(CurPageID: Integer);
var
_int: Integer;
begin
if CurPageID = wpPreparing then begin
// We're on the page after the "Ready To Install" page but before [Files] and [Run] are processed
if WizardIsTaskSelected('unins_previous') then
ExecAsOriginalUser(GetPreviousUninsExe, '/SILENT', '', SW_SHOW, ewWaitUntilTerminated, _int);
end else if CurPageID = wpSelectTasks then begin
if GetLatestErlangPath = '' then begin
WizardSelectTasks('erlang');
if IsWin64 then begin
WizardSelectTasks('erlang\64');
end;
end;
end;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
i: Integer;
begin
Result := True;
if CurPageID = GlobalPageSelRelease.ID then begin
// Search for the selected release
for i := 0 to GlobalPageSelRelease.CheckListBox.Items.Count - 1 do begin
if GlobalPageSelRelease.CheckListBox.Checked[i] then begin
CacheSelectedRelease := GlobalElixirReleases[i];
break;
end;
end;
end else if CurPageID = wpReady then begin
GlobalPageDownload.Clear;
with GlobalErlangData do begin
if WizardIsTaskSelected('erlang\32') then
// 32-bit OTP needs to be downloaded before it's installed
GlobalPageDownload.Add(URL32, Exe32, '');
if WizardIsTaskSelected('erlang\64') then
// 64-bit OTP needs to be downloaded before it's installed
GlobalPageDownload.Add(URL64, Exe64, '');
end;
// Download the Precompiled.zip archive for the selected release
GlobalPageDownload.Add(CacheSelectedRelease.URL, 'Precompiled.zip', '');
// Run page
GlobalPageDownload.Show;
try
try
GlobalPageDownload.Download;
except
MsgBox(GetExceptionMessage, mbCriticalError, MB_OK);
Result := False;
end
finally
GlobalPageDownload.Hide;
end;
end;
end;
procedure InitializeWizard();
var
latest: Boolean;
i: Integer;
begin
// Define the custom release selection page
GlobalPageSelRelease := CreateInputOptionPage(
wpWelcome,
'Select Elixir release',
'Setup will download and install the Elixir release you select.',
'All releases available to install are listed below, from newest to oldest.',
True, True // (Use Radio Buttons), (Put them in a scrollable list box)
);
latest := True;
// Use the global Elixir release array to populate the custom Elixir release list box
for i := 0 to GetArrayLength(GlobalElixirReleases) - 1 do begin
with GlobalElixirReleases[i] do begin
GlobalPageSelRelease.CheckListBox.AddRadioButton(
'Elixir version ' + Version, // Label next to radio button
ReleaseType, // Label right-justified in list box
0, // All choices on the same level
(latest) and (ReleaseType = 'release'), // Radio button selected by default if it's the latest release
(ReleaseType <> 'incompatible'), // Incompatible releases can't be selected
Nil
);
if ReleaseType = 'release' then
latest := False;
end
end;
GlobalPageDownload := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), Nil);
end;
function InitializeSetup(): Boolean;
begin
Result := True;
// Store the paths to elixir.csv, erlang.csv in global variables
GlobalElixirCSVFilePath := Tmp(GetURLFilePart('{#ELIXIR_CSV_URL}'));
GlobalErlangCSVFilePath := Tmp(GetURLFilePart('{#ERLANG_CSV_URL}'));
// Download elixir.csv; show an error message and exit the installer if downloading fails
try
DownloadTemporaryFile('{#ELIXIR_CSV_URL}', GetURLFilePart('{#ELIXIR_CSV_URL}'), '', Nil);
except
MsgBox('{#ELIXIR_CSV_URL} - ' + GetExceptionMessage + '. Setup cannot continue.', mbInformation, MB_OK);
Result := False;
exit;
end;
// Download erlang.csv; show an error message and exit the installer if downloading fails
try
DownloadTemporaryFile('{#ERLANG_CSV_URL}', GetURLFilePart('{#ERLANG_CSV_URL}'), '', Nil);
except
MsgBox('{#ERLANG_CSV_URL} - ' + GetExceptionMessage + '. Setup cannot continue.', mbInformation, MB_OK);
Result := False;
exit;
end;
// Create an array of TElixirRelease records from elixir.csv and store them in a global variable
GlobalElixirReleases := CSVToElixirReleases(GlobalElixirCSVFilePath);
// Check if above didn't work
if GetArrayLength(GlobalElixirReleases) = 0 then begin
MsgBox('Error: Parsing {#ELIXIR_CSV_URL} failed. Setup cannot continue.', mbInformation, MB_OK);
Result := False;
exit;
end;
// Create an TErlangData from erlang.csv record and store it in a global variable
GlobalErlangData := CSVToErlangData(GlobalErlangCSVFilePath);
// Check if above didn't work
if GlobalErlangData.OTPVersion = '' then begin
MsgBox('Error: Parsing {#ERLANG_CSV_URL} failed. Setup cannot continue.', mbInformation, MB_OK);
Result := False;
exit;
end;
end;