-
Notifications
You must be signed in to change notification settings - Fork 27
/
setup.iss
242 lines (190 loc) · 8.79 KB
/
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#define AppName "SakuraFrp 启动器"
#define AppVersion ""
#define RealVersion GetFileVersion("_publish\SakuraLibrary\SakuraLibrary.dll")
#define MainExecutable "SakuraLauncher.exe"
#define LibraryNameNet ".NET Framework 4.8"
[Setup]
; Basics
AppId=SakuraFrpLauncher
AppName={#AppName}
AppVersion={#AppVersion}
AppVerName={#AppName} v{#RealVersion}
AppCopyright=Copyright © iDea Leaper 2020-2022
AppPublisher=SakuraFrp
AppPublisherURL=https://www.natfrp.com/
AppSupportURL=https://www.natfrp.com/
VersionInfoVersion={#RealVersion}
; Wizard
WizardStyle=modern
LicenseFile=LICENSE
ShowComponentSizes=yes
AlwaysShowDirOnReadyPage=yes
UninstallDisplayName={#AppName}
ArchitecturesAllowed=x86 x64 arm64
ArchitecturesInstallIn64BitMode=x64 arm64
DefaultDirName={autopf}\SakuraFrpLauncher
DefaultGroupName={#AppName}
DisableDirPage=yes
DisableProgramGroupPage=yes
; Output
OutputDir=bin
OutputBaseFilename=SakuraLauncher
; Compression
Compression=lzma2
SolidCompression=yes
LZMANumBlockThreads=18
LZMAUseSeparateProcess=yes
[Languages]
Name: "ChineseSimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
[Types]
Name: "default"; Description: "默认设置";
Name: "custom"; Description: "自定义"; Flags: iscustom;
[Components]
Name: "frpc"; Description: "frpc"; Types: default custom; Flags: fixed
Name: "frpc\x86"; Description: "frpc (32 位)"; Check: IsX86; Types: default custom; Flags: exclusive fixed
Name: "frpc\x64"; Description: "frpc (64 位)"; Check: IsX64; Types: default custom; Flags: exclusive fixed
Name: "frpc\arm64"; Description: "frpc (ARM64, 实验性)"; Check: IsARM64; Types: default custom; Flags: exclusive fixed
Name: "launcher"; Description: "守护进程"; Types: default custom; Flags: fixed
Name: "launcher\service"; Description: "安装为系统服务";
Name: "launcher_ui"; Description: "用户界面"; Types: default custom; Flags: fixed
Name: "launcher_ui\wpf"; Description: "WPF 界面"; Types: default; Flags: exclusive
Name: "launcher_ui\legacy"; Description: "传统界面 (不推荐)"; Types: custom; Flags: exclusive
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkedonce
[Files]
Source: "_publish\sign\frpc_windows_386_gui.exe"; DestDir: "{app}"; DestName: "frpc.exe"; Flags: ignoreversion; Components: "frpc\x86"
Source: "_publish\sign\frpc_windows_386_gui.exe.sig"; DestDir: "{app}"; DestName: "frpc.exe.sig"; Flags: ignoreversion; Components: "frpc\x86"
Source: "_publish\sign\frpc_windows_amd64_gui.exe"; DestDir: "{app}"; DestName: "frpc.exe"; Flags: ignoreversion; Components: "frpc\x64"
Source: "_publish\sign\frpc_windows_amd64_gui.exe.sig"; DestDir: "{app}"; DestName: "frpc.exe.sig"; Flags: ignoreversion; Components: "frpc\x64"
Source: "_publish\sign\frpc_windows_arm64_gui.exe"; DestDir: "{app}"; DestName: "frpc.exe"; Flags: ignoreversion; Components: "frpc\arm64"
Source: "_publish\sign\frpc_windows_arm64_gui.exe.sig"; DestDir: "{app}"; DestName: "frpc.exe.sig"; Flags: ignoreversion; Components: "frpc\arm64"
Source: "_publish\SakuraLibrary\*"; DestDir: "{app}"; Flags: ignoreversion; Components: "launcher"
Source: "_publish\SakuraFrpService\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: "launcher"
Source: "_publish\SakuraLauncher\*"; DestDir: "{app}"; Flags: ignoreversion; Components: "launcher_ui\wpf"
Source: "_publish\LegacyLauncher\*"; DestDir: "{app}"; Flags: ignoreversion; Components: "launcher_ui\legacy"
; The service will always overwrite Updater.exe before executing it
Source: "SakuraFrpService\Resources\Updater.exe"; DestDir: "{app}"; Flags: ignoreversion onlyifdoesntexist; Components: "launcher"
[Icons]
; Start Menu
Name: "{group}\{#AppName}"; Filename: "{app}\SakuraLauncher.exe"; Components: "launcher_ui\wpf"
Name: "{group}\{#AppName}"; Filename: "{app}\LegacyLauncher.exe"; Components: "launcher_ui\legacy"
Name: "{group}\访问 SakuraFrp 管理面板"; Filename: "https://www.natfrp.com/user/"
Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
; Desktop Icon
Name: "{autodesktop}\{#AppName}"; Filename: "{app}\SakuraLauncher.exe"; Components: "launcher_ui\wpf"; Tasks: "desktopicon"
Name: "{autodesktop}\{#AppName}"; Filename: "{app}\LegacyLauncher.exe"; Components: "launcher_ui\legacy"; Tasks: "desktopicon"
[Run]
; Service
Filename: "{app}\SakuraFrpService.exe"; Parameters: "--install"; StatusMsg: "正在安装系统服务..."; Components: "launcher\service"
; Post Install Actions
Filename: "{app}\SakuraLauncher.exe"; Description: "{cm:LaunchProgram,{#AppName}}"; Components: "launcher_ui\wpf"; Flags: nowait postinstall skipifsilent
Filename: "{app}\LegacyLauncher.exe"; Description: "{cm:LaunchProgram,{#AppName}}"; Components: "launcher_ui\legacy"; Flags: nowait postinstall skipifsilent
[UninstallRun]
Filename: "{app}\SakuraFrpService.exe"; Parameters: "--uninstall"; RunOnceId: "RemoveService"; Components: "launcher\service"
[UninstallDelete]
Type: files; Name: "{app}\InstallUtil.InstallLog"
Type: files; Name: "{app}\SakuraFrpService.InstallLog"
Type: dirifempty; Name: "{app}"
[Code]
var
requiresRestart: Boolean;
downloadPage: TDownloadWizardPage;
installNet: Boolean;
function TryInstall(const Name, File, Args: String): String;
var
resultCode: Integer;
outputPage: TOutputProgressWizardPage;
begin
outputPage := CreateOutputProgressPage('安装运行环境', '正在安装 ' + Name);
outputPage.ProgressBar.Style := npbstMarquee;
outputPage.ProgressBar.Visible := True;
outputPage.Show;
if not Exec(ExpandConstant('{tmp}\' + File), Args, '', SW_SHOW, ewWaitUntilTerminated, resultCode) then
begin
Result := Name + ' 安装失败: ' + SysErrorMessage(resultCode);
end else begin
case resultCode of
0: ;
1641, 3010: requiresRestart := True;
else begin
Result := Name + ' 安装失败: 错误代码 ' + IntToStr(resultCode);
end;
end;
end;
outputPage.Hide;
end;
//// Install Events ///////////////////////////////////////////
procedure InitializeWizard;
var
version: Cardinal;
begin
downloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), nil);
installNet := (not RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', version)) or (version < 528040);
end;
function UpdateReadyMemo(const Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
begin
Result := '';
if installNet then begin
Result := Result + '运行环境 (需要联网下载):' + Newline + Space + '{#LibraryNameNet}' + Newline + NewLine;
end;
if MemoUserInfoInfo <> '' then
Result := Result + MemoUserInfoInfo + Newline + NewLine;
if MemoDirInfo <> '' then
Result := Result + MemoDirInfo + Newline + NewLine;
if MemoTypeInfo <> '' then
Result := Result + MemoTypeInfo + Newline + NewLine;
if MemoComponentsInfo <> '' then
Result := Result + MemoComponentsInfo + Newline + NewLine;
if MemoGroupInfo <> '' then
Result := Result + MemoGroupInfo + Newline + NewLine;
if MemoTasksInfo <> '' then
Result := Result + MemoTasksInfo + Newline + NewLine;
end;
function NextButtonClick(const CurPageID: Integer): Boolean;
var
retry: Boolean;
begin
Result := True;
if (CurPageID = wpReady) and installNet then begin
try
downloadPage.Show;
downloadPage.Clear;
downloadPage.Add('https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/9b7b8746971ed51a1770ae4293618187/ndp48-web.exe', 'dotnet.exe', '0bba3094588c4bfec301939985222a20b340bf03431563dec8b2b4478b06fffa');
retry := True;
while retry do begin
retry := False;
try
downloadPage.Download;
except
if GetExceptionMessage = SetupMessage(msgErrorDownloadAborted) then
Result := False
else case SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbError, MB_RETRYCANCEL, IDCANCEL) of
IDRETRY: retry := True;
IDCANCEL: Result := False;
end;
end;
end;
finally
downloadPage.Hide;
end;
end;
end;
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
if installNet then
Result := TryInstall('{#LibraryNameNet}', 'dotnet.exe', '/passive /norestart /showrmui /showfinalerror');
end;
function NeedRestart(): Boolean;
begin
Result := requiresRestart;
end;
//// Uninstall Events ///////////////////////////////////////////
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
// Not sure if this is really appropriate, especially for LegacyLauncher dir
// if CurUninstallStep = usPostUninstall and MsgBox('删除启动器配置文件?', mbConfirmation, MB_YESNO) = IDYES then
// DelTree(ExpandConstant('{userappdata}\SakuraLauncher'), True, True, True);
// DelTree(ExpandConstant('{userappdata}\LegacyaLauncher'), True, True, True);
// DelTree(ExpandConstant('{userappdata}\SakuraFrpService'), True, True, True);
// end;
end;