forked from dlang/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dinstaller.nsi
329 lines (244 loc) · 10.7 KB
/
dinstaller.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
;--------------------------------------------------------
; Defines
;--------------------------------------------------------
; Version
;!define Version1 "1.046"
;!define Version2 "2.031"
!define VersionCurl "7.24.0"
; Download zip from website, or include the compressed zip?
!define Download
; If Download, the urls of the dmd.zip and dmc.zip
!define DownloadDmd1ZipUrl "http://ftp.digitalmars.com/dmd.${Version1}.zip"
!define DownloadDmd2ZipUrl "https://github.com/downloads/D-Programming-Language/dmd/dmd.${Version2}.zip"
!define DownloadDmcZipUrl "http://ftp.digitalmars.com/dmc.zip"
!define DownloadCurlZipUrl "https://github.com/downloads/D-Programming-Language/dmd/curl-${VersionCurl}-dmd-win32.zip" ;"http://ftp.digitalmars.com/dmc.zip"
; If not Download, the paths of dmd.zip and dmc.zip
!define DmdZipPath1 "dmd.${Version1}.zip"
!define DmdZipPath2 "dmd.${Version2}.zip"
!define DmcZipPath "dmc.zip"
!define CurlZipPath "curl-${VersionCurl}-dmd-win32.zip"
;--------------------------------------------------------
; Includes
;--------------------------------------------------------
!include "MUI.nsh"
!include "EnvVarUpdate.nsh"
;--------------------------------------------------------
; General definitions
;--------------------------------------------------------
; Name of the installer
Name "D Programming Language"
; Name of the output file of the installer
OutFile "dinstaller.exe"
; Where the program will be installed
InstallDir "C:\D"
; Take the instalation directory from the registry, if possible
InstallDirRegKey HKCU "Software\D" ""
; This is so no one can corrupt the installer
CRCCheck force
;--------------------------------------------------------
; Interface settings
;--------------------------------------------------------
; Confirmation when exiting the installer
!define MUI_ABORTWARNING
!define MUI_ICON "installer-icon.ico"
!define MUI_UNICON "uninstaller-icon.ico"
;--------------------------------------------------------
; Langauge selection dialog settings
;--------------------------------------------------------
; Remember the installation language
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software\D"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
;--------------------------------------------------------
; Installer pages
;--------------------------------------------------------
!define MUI_WELCOMEFINISHPAGE_BITMAP "installer_image.bmp"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------------------------------
; The languages
;--------------------------------------------------------
!insertmacro MUI_LANGUAGE "English"
;!insertmacro MUI_LANGUAGE "Spanish"
;--------------------------------------------------------
; Reserve files needed by the installation
;--------------------------------------------------------
!insertmacro MUI_RESERVEFILE_LANGDLL
;--------------------------------------------------------
; Required section: main program files,
; registry entries, etc.
;--------------------------------------------------------
Section /o "D 1" Dmd1Files
; This section is mandatory
;SectionIn RO
SetOutPath $INSTDIR
; Create installation directory
CreateDirectory "$INSTDIR"
!ifdef Download
; Download the zip files
inetc::get /caption "Downloading dmd.${Version1}.zip..." /popup "" "${DownloadDmd1ZipUrl}" "$INSTDIR\dmd.zip" /end
Pop $0 # return value = exit code, "OK" means OK
!else
FILE "/oname=$INSTDIR\dmd.zip" "${DmdZipPath1}"
!endif
; Unzip them right there
nsisunz::Unzip "$INSTDIR\dmd.zip" "$INSTDIR"
; Delete the zip files
Delete "$INSTDIR\dmd.zip"
; Add directories to path (for all users)
; (if for the current user, use HKCU)
${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\dmd\windows\bin"
; Write installation dir in the registry
WriteRegStr HKLM SOFTWARE\D "Install_Dir" "$INSTDIR"
; Write registry keys to make uninstall from Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "DisplayName" "D"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "NoRepair" 1
WriteUninstaller "uninstall.exe"
SectionEnd
Section "D 2" Dmd2Files
; This section is mandatory
;SectionIn RO
SetOutPath $INSTDIR
; Create installation directory
CreateDirectory "$INSTDIR"
!ifdef Download
; Download the zip files
inetc::get /caption "Downloading dmd.${Version2}.zip..." /popup "" "${DownloadDmd2ZipUrl}" "$INSTDIR\dmd2.zip" /end
Pop $0 # return value = exit code, "OK" means OK
!else
FILE "/oname=$INSTDIR\dmd2.zip" "${DmdZipPath2}"
!endif
; Unzip them right there
nsisunz::Unzip "$INSTDIR\dmd2.zip" "$INSTDIR"
; Delete the zip files
Delete "$INSTDIR\dmd2.zip"
; Add directories to path (for all users)
; (if for the current user, use HKCU)
${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\dmd2\windows\bin"
; Write installation dir in the registry
WriteRegStr HKLM SOFTWARE\D "Install_Dir" "$INSTDIR"
; Write registry keys to make uninstall from Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "DisplayName" "D"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "NoRepair" 1
WriteUninstaller "uninstall.exe"
SectionEnd
Section "cURL support for D 2" cURLFiles
; This section is mandatory
;SectionIn RO
SetOutPath $INSTDIR
; Create installation directory
CreateDirectory "$INSTDIR"
!ifdef Download
; Download the zip files
inetc::get /caption "Downloading ${CurlZipPath}..." /popup "" "${DownloadCurlZipUrl}" "$INSTDIR\curl.zip" /end
Pop $0 # return value = exit code, "OK" means OK
!else
FILE "/oname=$INSTDIR\curl.zip" "${CurlZipPath}"
!endif
; Unzip them right there
nsisunz::Unzip "$INSTDIR\curl.zip" "$INSTDIR"
; Delete the zip files
Delete "$INSTDIR\curl.zip"
SectionEnd
Section "dmc" DmcFiles
; This section is mandatory
;SectionIn RO
SetOutPath $INSTDIR
; Create installation directory
CreateDirectory "$INSTDIR"
!ifdef Download
; Download the zip files
inetc::get /caption "Downloading dmc.zip..." /popup "" "${DownloadDmcZipUrl}" "$INSTDIR\dmc.zip" /end
Pop $0 # return value = exit code, "OK" means OK
!else
FILE "/oname=$INSTDIR\dmc.zip" "${DmcZipPath}"
!endif
; Unzip them right there
nsisunz::Unzip "$INSTDIR\dmc.zip" "$INSTDIR"
; Delete the zip files
Delete "$INSTDIR\dmc.zip"
; Add directories to path (for all users)
; (if for the current user, use HKCU)
${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\dm\bin"
; Write installation dir in the registry
WriteRegStr HKLM SOFTWARE\D "Install_Dir" "$INSTDIR"
; Write registry keys to make uninstall from Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "DisplayName" "D"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "NoRepair" 1
WriteUninstaller "uninstall.exe"
SectionEnd
Section "Start Menu Shortcuts" StartMenuShortcuts
CreateDirectory "$SMPROGRAMS\D"
; install dmd 1 documentation
SectionGetFlags ${Dmd1Files} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} +1 +2
CreateShortCut "$SMPROGRAMS\D\D1 Documentation.lnk" "$INSTDIR\dmd\html\d\index.html" "" "$INSTDIR\dmd\html\d\index.html" 0
; install dmd 2 documentation
SectionGetFlags ${Dmd2Files} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} +1 +2
CreateShortCut "$SMPROGRAMS\D\D2 Documentation.lnk" "$INSTDIR\dmd2\html\d\index.html" "" "$INSTDIR\dmd2\html\d\index.html" 0
CreateShortCut "$SMPROGRAMS\D\$(SHORTCUT_Uninstall).lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
SectionEnd
;--------------------------------------------------------
; Installer functions
;--------------------------------------------------------
Function .onInit
; This is commented because there's only one language
; (for now)
;!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
; Contains descriptions of components and other stuff
!include dinstaller_descriptions.nsh
;--------------------------------------------------------
; Uninstaller
;--------------------------------------------------------
Section "Uninstall"
; Remove directories to path (for all users)
; (if for the current user, use HKCU)
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\dm\bin"
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\dmd\windows\bin"
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\dmd2\windows\bin"
; Remove stuff from registry
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D"
DeleteRegKey HKLM SOFTWARE\D
DeleteRegKey /ifempty HKLM SOFTWARE\D
; This is for deleting the remembered language of the installation
DeleteRegKey HKCU Software\D
DeleteRegKey /ifempty HKCU Software\D
; Remove the uninstaller
Delete $INSTDIR\uninstall.exe
; Remove shortcuts
Delete "$SMPROGRAMS\D\D1 Documentation.lnk"
Delete "$SMPROGRAMS\D\D2 Documentation.lnk"
Delete "$SMPROGRAMS\D\$(SHORTCUT_Uninstall).lnk"
; Remove used directories
RMDir /r /REBOOTOK "$INSTDIR\dm"
RMDir /r /REBOOTOK "$INSTDIR\dmd"
RMDir /r /REBOOTOK "$INSTDIR\dmd2"
RMDir /r /REBOOTOK "$INSTDIR"
RMDir /r /REBOOTOK "$SMPROGRAMS\D"
SectionEnd
;--------------------------------------------------------
; Uninstaller functions
;--------------------------------------------------------
Function un.onInit
; Ask language before starting the uninstall
; This is commented because there's only one language
; (for now)
;!insertmacro MUI_UNGETLANGUAGE
FunctionEnd