-
Notifications
You must be signed in to change notification settings - Fork 11
/
dart_x64_stable_setup.iss
222 lines (202 loc) · 7.5 KB
/
dart_x64_stable_setup.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
#define MyAppName "Dart"
#define MyAppVersion "stable 64-bit"
#define MyAppPublisher "Gekorm"
#define MyAppURL "https://www.dartlang.org/"
#define MyAppExeName "dart.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{E30EFA88-E6EE-4149-860C-049E4F1A1CFC}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
ArchitecturesInstallIn64BitMode=x64
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableDirPage=auto
DisableProgramGroupPage=auto
AllowNoIcons=yes
LicenseFile=assets\LICENSE.txt
InfoBeforeFile=assets\INFO.txt
InfoAfterFile=assets\AFTER.txt
OutputDir=bin
OutputBaseFilename=Dart_x64 stable setup
SetupIconFile=assets\dart-icon.ico
Compression=lzma
SolidCompression=yes
; Tell Windows Explorer to reload the environment
ChangesEnvironment=yes
; Size of files to download:
ExtraDiskSpaceRequired=409994662
UninstallDisplayIcon={app}\dart-icon.ico
WizardImageFile=assets\dart-logo-wordmark.bmp
WizardSmallImageFile=assets\dart-small.bmp
WizardImageStretch=no
#include <idp.iss>
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "assets\7za.exe"; DestDir: "{tmp}\"; Flags: dontcopy
Source: "bin\updater-stable\Dart Update.exe"; DestDir: "{app}\"; Flags: ignoreversion overwritereadonly
Source: "assets\dart-icon.ico"; DestDir: "{app}\"; Flags: ignoreversion overwritereadonly
Source: "{tmp}\dart-sdk\*"; DestDir: "{app}\dart-sdk"; Flags: ignoreversion recursesubdirs createallsubdirs external
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName} Update"; Filename: "{app}\Dart Update.exe"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\dart-sdk\bin"; Check: NeedsAddPath('{app}\dart-sdk\bin')
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "DART_SDK"; ValueData: "{app}\dart-sdk";
[CustomMessages]
DartLatestVersion=The latest stable version will be installed: %1
[Code]
// SO: http://stackoverflow.com/questions/3304463/
function NeedsAddPath(Param: string): Boolean;
var
OrigPath: string;
ParamExpanded: string;
begin
// Expand the setup constants like {app} from Param
ParamExpanded := ExpandConstant(Param);
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'Path', OrigPath) then
begin
Result := TRUE;
Exit;
end;
// Look for the path with leading and trailing semicolon and with or without \ ending
// Pos() returns 0 if not found
Result := Pos(';' + UpperCase(ParamExpanded) + ';', ';' + UpperCase(OrigPath) + ';') = 0;
if Result = TRUE then
Result := Pos(';' + UpperCase(ParamExpanded) + '\;', ';' + UpperCase(OrigPath) + ';') = 0;
end;
// Internet latest version
function GetCurVersion(Param: string): string;
var
FormattedRevision: string;
Index: Integer;
begin
FormattedRevision := Param;
Index := Pos('version', Param);
Index := Index +11;
Delete(FormattedRevision, 1, Index - 1);
Index := Pos('"', FormattedRevision);
Delete(FormattedRevision, Index, 4);
Index := Pos('"', FormattedRevision);
Delete(FormattedRevision, Index, 400);
Result := FormattedRevision;
Exit;
end;
procedure InitializeWizard;
begin
// Only tell the plugin when we want to start downloading
// Add the files to the list; at this time, the {app} directory is known
idpSetOption('ConnectTimeout', '90000');
idpSetOption('SendTimeout', '90000');
idpSetOption('ReceiveTimeout', '90000');
idpAddFile('https://storage.googleapis.com/dart-archive/channels/stable/release/latest/sdk/dartsdk-windows-x64-release.zip', ExpandConstant('{tmp}\dart-sdk.zip'));
idpDownloadAfter(wpReady);
end;
procedure DoUnzip(Source: string; targetdir: string);
var
unzipTool: string;
ReturnCode: Integer;
begin
// Source contains tmp constant, so resolve it to path name
Source := ExpandConstant(Source);
unzipTool := ExpandConstant('{tmp}\7za.exe');
if not FileExists(unzipTool) then
MsgBox('UnzipTool not found: ' + unzipTool, mbError, MB_OK)
else if not FileExists(Source) then
MsgBox('File was not found while trying to unzip: ' + Source, mbError, MB_OK)
else
begin
if Exec(unzipTool, ' x "' + Source + '" -o"' + targetdir + '" -y',
'', SW_HIDE, ewWaitUntilTerminated, ReturnCode) = FALSE then
begin
MsgBox('Unzip failed:' + Source, mbError, MB_OK);
end;
end;
end;
function TryGetFirstSubfolder(const Path: string; out Folder: string): Boolean;
var
S: string;
FindRec: TFindRec;
begin
Result := FALSE;
if FindFirst(ExpandConstant(AddBackslash(Path) + '*'), FindRec) then
try
repeat
if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and
(FindRec.Name <> '.') and (FindRec.Name <> '..') then
begin
Result := TRUE;
Folder := AddBackslash(Path) + FindRec.Name;
Exit;
end;
until not FindNext(FindRec);
finally
FindClose(FindRec);
end;
end;
procedure CurPageChanged(CurPageID: Integer);
var
S: string;
SilUpdate: string;
CurrentVersion: string;
Page: TWizardPage;
LatestLabel: TNewStaticText;
begin
// If the user just reached the installing page, then...
if CurPageID = wpInstalling then
begin
// Extract 7za to temp folder
ExtractTemporaryFile('7za.exe');
// Extract the zip to the temp folder (when included in the installer)
// Skip this, when the file is downloaded with IDP to the temp folder
// ExtractTemporaryFile('app.zip);
// Unzip the Dart SDK zip in the tempfolder to your temp target path
DoUnzip(ExpandConstant('{tmp}\') + 'dart-sdk.zip', ExpandConstant('{tmp}'));
end;
// If the user just reached the Ready page, then...
if CurPageID = wpReady then
begin
// Download VERSION text file
if idpDownloadFile('https://storage.googleapis.com/dart-archive/channels/stable/release/latest/VERSION', ExpandConstant('{tmp}\VERSION.txt')) then
begin
// Version fetched
// Read the file
LoadStringFromFile(ExpandConstant('{tmp}\VERSION.txt'), SilUpdate);
CurrentVersion := GetCurVersion(SilUpdate);
Page := PageFromID(wpReady);
LatestLabel := TNewStaticText.Create(WizardForm);
LatestLabel.Parent := Page.Surface;
LatestLabel.Caption := FmtMessage(CustomMessage('DartLatestVersion'), [CurrentVersion]);
if Wizardform.ReadyMemo.Lines.Count > 0 then
begin
WizardForm.ReadyLabel.Caption := '';
end
else
begin
WizardForm.ReadyLabel.Top := LatestLabel.Top + WizardForm.ReadyLabel.Height + 16;
end
end
end;
// If the user just reached the Installing page, then...
if CurPageID = wpInstalling then
begin
// Extract 7za to temp folder
ExtractTemporaryFile('7za.exe');
// Extract the zip to the temp folder (when included in the installer)
// Skip this, when the file is downloaded with IDP to the temp folder
// ExtractTemporaryFile('app.zip);
// Unzip the Dart SDK zip in the tempfolder to your temp target path
DoUnzip(ExpandConstant('{tmp}\') + 'dart-sdk.zip', ExpandConstant('{tmp}'));
end;
end;