forked from Tribler/tribler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tribler.nsi
348 lines (281 loc) · 13.5 KB
/
tribler.nsi
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
!define PRODUCT "Tribler"
; Laurens, 2016-03-14: The __GIT__ string will be replaced by update_version_from_git.py
; with the current version of the build.
!define VERSION "__GIT__"
; Laurens, 2016-03-14: The _x86 will be replaced by _x64 if needed in update_version_from_git.py
!define BITVERSION "x86"
!include "MUI2.nsh"
!include "FileFunc.nsh"
!include "nsProcess.nsh"
; Laurens, 2016-04-06: We are going to possibly touch the C:/ drive (by default we do) and it's restricted areas,
; so we need admin permission to do so (for most devices).
RequestExecutionLevel admin
;--------------------------------
;Configuration
;General
Name "${PRODUCT} ${VERSION}"
OutFile "${PRODUCT}_${VERSION}_${BITVERSION}.exe"
;Folder selection page.
; Laurens, 2016-03-14: Note that $PROGRAMFILES will be replaced by $PROGRAMFILES64
; if the 64 bit argument is passed to update_version_from_git.py.
InstallDir "$PROGRAMFILES\${PRODUCT}"
; Laurens, 2016-03-15: No silent mode for the installer and uninstaller because
; this will disbale the init functions being called.
SilentInstall normal
SilentUnInstall normal
;Remember install folder
InstallDirRegKey HKCU "Software\${PRODUCT}" ""
;
; Uncomment for smaller file size
;
SetCompressor "lzma"
;
; Uncomment for quick built time
;
;SetCompress "off"
CompletedText "Installation completed. Thank you for choosing ${PRODUCT}."
BrandingText "${PRODUCT}"
; ----------------------------
; Tribler running check - shared function
!macro RUNMACRO un
Function ${un}checkrunning
DetailPrint "Checking if Tribler is not running..."
checkRunning:
${nsProcess::FindProcess} "tribler.exe" $r0
StrCmp $r0 0 0 notRunning
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${PRODUCT} is running, please close it so the (un)installation can proceed." /SD IDCANCEL IDRETRY checkRunning
Abort
notRunning:
FunctionEnd
!macroend
; Insert function as an installer and uninstaller function.
!insertmacro RUNMACRO ""
!insertmacro RUNMACRO "un."
;--------------------------------
;Modern UI Configuration
!define MUI_ICON "Tribler\Main\vwxGUI\images\tribler.ico"
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_ABORTWARNING
;--------------------------------
;Pages
!define MUI_LICENSEPAGE_RADIOBUTTONS
!define MUI_LICENSEPAGE_RADIOBUTTONS_TEXT_ACCEPT "I accept"
!define MUI_LICENSEPAGE_RADIOBUTTONS_TEXT_DECLINE "I decline"
!insertmacro MUI_PAGE_LICENSE "binary-LICENSE.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;!insertmacro MUI_DEFAULT UMUI_HEADERIMAGE_BMP heading.bmp"
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Language Strings
;Description
LangString DESC_SecMain ${LANG_ENGLISH} "Install ${PRODUCT}"
LangString DESC_SecDesk ${LANG_ENGLISH} "Create Desktop Shortcuts"
LangString DESC_SecStart ${LANG_ENGLISH} "Create Start Menu Shortcuts"
LangString DESC_SecDefaultTorrent ${LANG_ENGLISH} "Associate .torrent files with ${PRODUCT}"
LangString DESC_SecDefaultTStream ${LANG_ENGLISH} "Associate .tstream files with ${PRODUCT}"
LangString DESC_SecDefaultMagnet ${LANG_ENGLISH} "Associate magnet links with ${PRODUCT}"
;--------------------------------
;Installer Sections
Section "!Main EXE" SecMain
SectionIn RO
; Check if tribler is not running when trying to install because files will be in use when cleaning the isntall dir.
Call checkrunning
; Boudewijn, need to remove stuff from previously installed version
RMDir /r "$INSTDIR"
; Install Tribler stuff
SetOutPath "$INSTDIR"
File /r Microsoft.VC90.CRT
File /r *
File *.txt
File logger.conf
File tribler.exe
File ffmpeg.exe
File /r vlc
File tools\*.bat
Delete "$INSTDIR\*.pyd"
File *.pyd
Delete "$INSTDIR\python*.dll"
Delete "$INSTDIR\wx*.dll"
File *.dll
CreateDirectory "$INSTDIR\Tribler"
SetOutPath "$INSTDIR\Tribler"
File Tribler\*.sql
CreateDirectory "$INSTDIR\Tribler\Core"
; Main client specific
CreateDirectory "$INSTDIR\Tribler"
CreateDirectory "$INSTDIR\Tribler\Main\vwxGUI"
CreateDirectory "$INSTDIR\Tribler\Main\vwxGUI\images"
CreateDirectory "$INSTDIR\Tribler\Main\vwxGUI\images\default"
CreateDirectory "$INSTDIR\Tribler\Main\vwxGUI\images\flags"
SetOutPath "$INSTDIR\Tribler\Main\vwxGUI\images"
File Tribler\Main\vwxGUI\images\*
SetOutPath "$INSTDIR\Tribler\Main\vwxGUI\images\default"
File Tribler\Main\vwxGUI\images\default\*
SetOutPath "$INSTDIR\Tribler\Main\vwxGUI\images\flags"
File Tribler\Main\vwxGUI\images\flags\*
CreateDirectory "$INSTDIR\Tribler\Main\webUI"
CreateDirectory "$INSTDIR\Tribler\Main\webUI\static"
CreateDirectory "$INSTDIR\Tribler\Main\webUI\static\images"
CreateDirectory "$INSTDIR\Tribler\Main\webUI\static\lang"
SetOutPath "$INSTDIR\Tribler\Main\webUI\static"
File Tribler\Main\webUI\static\*.*
SetOutPath "$INSTDIR\Tribler\Main\webUI\static\images"
File Tribler\Main\webUI\static\images\*.*
SetOutPath "$INSTDIR\Tribler\Main\webUI\static\lang"
File Tribler\Main\webUI\static\lang\*.*
; Categories
CreateDirectory "$INSTDIR\Tribler\Category"
SetOutPath "$INSTDIR\Tribler\Category"
File Tribler\Category\*.conf
File Tribler\Category\*.filter
; Arno, 2012-05-25: data files for pymdht
CreateDirectory "$INSTDIR\Tribler\Core\DecentralizedTracking"
CreateDirectory "$INSTDIR\Tribler\Core\DecentralizedTracking\pymdht"
CreateDirectory "$INSTDIR\Tribler\Core\DecentralizedTracking\pymdht\core"
SetOutPath "$INSTDIR\Tribler\Core\DecentralizedTracking\pymdht\core"
File Tribler\Core\DecentralizedTracking\pymdht\core\bootstrap_stable
File Tribler\Core\DecentralizedTracking\pymdht\core\bootstrap_unstable
; Install MSVCR 2008, 2010, 2012
SetOutPath "$INSTDIR"
; Libraries dependant on 2008 are: Python, APSW
File vc_redist_90.exe
ExecWait "$INSTDIR\vc_redist_90.exe /q /norestart"
; Libraries dependant on 2012 are: LevelDB, LibTorrent
File vc_redist_110.exe
ExecWait "$INSTDIR\vc_redist_110.exe /q /norestart"
FileOpen $9 "$INSTDIR\tribler.exe.log" w
FileWrite $9 ""
FileClose $9
AccessControl::GrantOnFile "$INSTDIR\tribler.exe.log" "(BU)" "FullAccess"
AccessControl::GrantOnFile "$INSTDIR\tribler.exe.log" "(S-1-5-32-545)" "FullAccess"
; End
SetOutPath "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "DisplayName" "${PRODUCT}"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "NoRepair" 1
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "DisplayVersion" '${VERSION}'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "DisplayIcon" "$INSTDIR\${PRODUCT}.exe,0"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "Publisher" "The Tribler Team"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "HelpLink" 'http://forum.tribler.org'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "URLInfoAbout" 'http://www.tribler.org'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "URLUpdateInfo" 'http://www.tribler.org/trac/wiki/Download'
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "EstimatedSize" "$0"
; Now writing to KHEY_LOCAL_MACHINE only -- remove references to uninstall from current user
DeleteRegKey HKEY_CURRENT_USER "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}"
; Remove old error log if present
Delete "$INSTDIR\tribler.exe.log"
WriteUninstaller "$INSTDIR\Uninstall.exe"
; Add an application to the firewall exception list - All Networks - All IP Version - Enabled
SimpleFC::AddApplication "Tribler" "$INSTDIR\${PRODUCT}.exe" 0 2 "" 1
SectionEnd
Section "Desktop Icons" SecDesk
CreateShortCut "$DESKTOP\${PRODUCT}.lnk" "$INSTDIR\${PRODUCT}.exe" ""
SectionEnd
Section "Startmenu Icons" SecStart
CreateDirectory "$SMPROGRAMS\${PRODUCT}"
CreateShortCut "$SMPROGRAMS\${PRODUCT}\Uninstall ${PRODUCT}.lnk" "$INSTDIR\Uninstall.exe"
CreateShortCut "$SMPROGRAMS\${PRODUCT}\${PRODUCT}.lnk" "$INSTDIR\${PRODUCT}.exe"
SectionEnd
Section "Make Default For .torrent" SecDefaultTorrent
; Delete ddeexec key if it exists
DeleteRegKey HKCR "bittorrent\shell\open\ddeexec"
WriteRegStr HKCR .torrent "" bittorrent
WriteRegStr HKCR .torrent "Content Type" application/x-bittorrent
WriteRegStr HKCR "MIME\Database\Content Type\application/x-bittorrent" Extension .torrent
WriteRegStr HKCR bittorrent "" "TORRENT File"
WriteRegBin HKCR bittorrent EditFlags 00000100
WriteRegStr HKCR "bittorrent\shell" "" open
WriteRegStr HKCR "bittorrent\shell\open\command" "" '"$INSTDIR\${PRODUCT}.exe" "%1"'
WriteRegStr HKCR "bittorrent\DefaultIcon" "" "$INSTDIR\Tribler\Main\vwxGUI\images\torrenticon.ico"
SectionEnd
Section "Make Default For .tstream" SecDefaultTStream
; Arno: Poor man's attempt to check if already registered
ReadRegStr $0 HKCR .tstream ""
ReadRegStr $1 HKCR "tstream\shell\open\command" ""
StrCpy $2 $1 -4
StrCmp $0 "" 0 +2
return
MessageBox MB_YESNO ".tstream already registered to $2. Overwrite?" IDYES +2 IDNO 0
Return
DetailPrint "Arno registering .tstream: $0 $1 $2"
; Register
WriteRegStr HKCR .tstream "" tstream
WriteRegStr HKCR .tstream "Content Type" application/x-tribler-stream
WriteRegStr HKCR "MIME\Database\Content Type\application/x-tribler-stream" Extension .tstream
WriteRegStr HKCR tstream "" "TSTREAM File"
WriteRegBin HKCR tstream EditFlags 00000100
WriteRegStr HKCR "tstream\shell" "" open
WriteRegStr HKCR "tstream\shell\open\command" "" '"$INSTDIR\${PRODUCT}.exe" "%1"'
WriteRegStr HKCR "tstream\DefaultIcon" "" "$INSTDIR\Tribler\Main\vwxGUI\images\torrenticon.ico"
SectionEnd
Section "Make Default For magnet://" SecDefaultMagnet
WriteRegStr HKCR "magnet" "" "URL: Magnet Link Protocol"
WriteRegStr HKCR "magnet" "URL Protocol" ""
WriteRegStr HKCR "magnet\DefaultIcon" "" "$INSTDIR\Tribler\Main\vwxGUI\images\torrenticon.ico"
WriteRegStr HKCR "magnet\shell\open\command" "" '"$INSTDIR\${PRODUCT}.exe" "%1"'
WriteRegStr HKLM "SOFTWARE\Classes\magnet\shell\open\command" "" '"$INSTDIR\${PRODUCT}.exe" "%1"'
SectionEnd
;--------------------------------
;Descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecMain} $(DESC_SecMain)
!insertmacro MUI_DESCRIPTION_TEXT ${SecDesk} $(DESC_SecDesk)
!insertmacro MUI_DESCRIPTION_TEXT ${SecStart} $(DESC_SecStart)
!insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultTorrent} $(DESC_SecDefaultTorrent)
!insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultTStream} $(DESC_SecDefaultTStream)
!insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultMagnet} $(DESC_SecDefaultMagnet)
!insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultPpsp} $(DESC_SecDefaultPpsp)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
; Check if tribler is not running when trying to uninstall because files will be in use then.
Call un.checkrunning
RMDir /r "$INSTDIR"
Delete "$DESKTOP\${PRODUCT}.lnk"
SetShellVarContext all
RMDir "$SMPROGRAMS\${PRODUCT}"
RMDir /r "$SMPROGRAMS\${PRODUCT}"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${PRODUCT}"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}"
; Remove an application from the firewall exception list
SimpleFC::RemoveApplication "$INSTDIR\${PRODUCT}.exe"
SectionEnd
;--------------------------------
;Macros and Functions Section
Function .onInit
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "Tribler") i .r1 ?e'
Pop $R0
StrCmp $R0 0 checkinst
MessageBox MB_OK "The installer is already running."
Abort
checkinst:
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "UninstallString"
StrCmp $R0 "" done
IfFileExists $R0 showuninstdialog done
showuninstdialog:
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "${PRODUCT} is already installed. $\n$\nClick `OK` to remove the previous version or `Cancel` to cancel this upgrade." /SD IDCANCEL IDOK uninst
Abort
uninst:
ClearErrors
; Laurens (2016-03-29): Retrieve the uninstallString stored in the register.
; Do NOT use $INSTDIR as this points to the current $INSTDIR var of the INSTALLER,
; which is the default location at this point.
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "UninstallString"
ExecWait '"$R0" _?=$INSTDIR' ; This prevents the installer from being ran in a tmp directory, causing execwait not to wait.
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "UninstallString"
StrCmp $R0 "" done
Abort
done:
FunctionEnd