-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathOpenLV.nsi
370 lines (289 loc) · 12.8 KB
/
OpenLV.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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
!addplugindir "Inetc\Plugins"
!include "WordFunc.nsh"
!insertmacro VersionCompare
!define PRODUCT_NAME "OpenLV"
!define PRODUCT_VERSION "0.9.2"
!define PRODUCT_EDITION "Open"
!define BASE_DIRECTORY "${PRODUCT_VERSION}\OpenLV_${PRODUCT_VERSION}"
!define PRODUCT_PUBLISHER "OpenLV Dev Team"
!define PRODUCT_WEB_SITE "http://www.openlv.org"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\OpenLV.jar"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
;java auto-download
!define JRE_MIN_VERSION "1.5"
;!define JRE_URL "http://dlc.sun.com/jdk/jre-1_5_0_01-windows-i586-p.exe"
;this is jre-6u20-windows-i586-p.exe
;!define JRE_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=39494"
;!define JRE_URL "http://download.oracle.com/otn-pub/java/jdk/6u43-b01/jre-6u43-windows-i586.exe"
!define JRE_URL "https://edelivery.oracle.com/otn-pub/java/jdk/6u43-b01/jre-6u43-windows-i586.exe"
;vmware auto-download
!define VMWARE_SERVER_URL "http://download3.vmware.com/software/vmserver/VMware-server-installer-1.0.10-203137.exe"
;!define VMWARE_SERVER_URL "http://download3.vmware.com/software/vmserver/VMware-server-installer-1.0.8-126538.exe"
;!define VMWARE_SERVER_URL "http://download3.vmware.com/software/vmserver/VMware-server-installer-1.0.3-44356.exe"
;!define VMWARE_SERVER_URL "http://download3.vmware.com/software/vmserver/VMware-server-installer-1.0.0-28343.exe"
;vmware disk mount auto-download
;vddk requires a log-in...
;!define VMWARE_MOUNT_URL "http://www.vmware.com/support/developer/vddk/"
;!define VMWARE_MOUNT_URL "http://download3.vmware.com/software/wkst/VMware-mount-5.5.0-18463.exe"
!define JRE_INSTALLER_NAME "jre-6u43-windows-i586.exe"
;!define JRE_INSTALLER_NAME "jre-6u17-windows-i586-s.exe"
!define VMWARE_INSTALLER_NAME "VMware-server-installer-1.0.10-203137.exe"
!define VMWARE_VDDK_INSTALLER_NAME "VMware-vix-disklib-1.1.1-207031.i386.exe"
;!define JRE_INSTALLER_NAME "jre-6u11-windows-i586-p.exe"
;!define VMWARE_INSTALLER_NAME "VMware-server-installer-1.0.8-126538.exe"
;!define VMWARE_VDDK_INSTALLER_NAME "VMware-vix-disklib-e.x.p-99191.i386.exe"
!include "MUI.nsh"
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "OpenLVLicense.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
;!define MUI_FINISHPAGE_RUN "$SYSDIR\javaw.exe" "-jar $INSTDIR\OpenLV.jar"
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "OpenLVInstallerv${PRODUCT_VERSION}.exe"
InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Section "MainSection" SEC01
Call DetectPreviousInstall
Call DetectJRE
; Call DetectVMSoftware
; Call DetectOldVMWareMount
; Call DetectVDDK
SetOutPath "$INSTDIR"
SetOverwrite try
File "${BASE_DIRECTORY}\OpenLV.jar"
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
Call FindJRE
Pop $R0
CreateShortCut "$DESKTOP\${PRODUCT_NAME} ${PRODUCT_VERSION}.lnk" $R0 "-jar OpenLV.jar" "$INSTDIR\Resources\app.ico" 0
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} ${PRODUCT_VERSION}.lnk" $R0 "-jar OpenLV.jar" "$INSTDIR\Resources\app.ico" 0
SetOutPath "$INSTDIR\Resources"
File "${BASE_DIRECTORY}\Resources\generic.mbr"
File "${BASE_DIRECTORY}\Resources\genericW98Me.mbr"
File "${BASE_DIRECTORY}\Resources\app.ico"
File "${BASE_DIRECTORY}\Resources\LVSmallIcon.gif"
File "${BASE_DIRECTORY}\Resources\merge.reg"
SectionEnd
Section -AdditionalIcons
SetOutPath $INSTDIR
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\OpenLV.jar"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\Resources\app.ico"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
Function GetJRE
IfFileExists "$EXEDIR\${JRE_INSTALLER_NAME}" foundjre
MessageBox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME} requires Java 1.5 or higher, it will now \
be downloaded and installed because it could not be detected on your system"
StrCpy $2 "$TEMP\${JRE_INSTALLER_NAME}"
; nsisdl::download /TIMEOUT=30000 ${JRE_URL} $2
inetc::get /NOCANCEL /CONNECTTIMEOUT=30000 /RECEIVETIMEOUT=30000 /RESUME "" ${JRE_URL} $2
Pop $R0 ;Get the return value
StrCmp $R0 "OK" +3
MessageBox MB_OK "Download failed: $R0"
Quit
ExecWait $2
Delete $2
Goto done
foundjre:
Messagebox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME} requires Java 1.5 or higher, it will now \
be installed from your installation media because no compatible Java installation could be detected on your system"
ExecWait "$EXEDIR\${JRE_INSTALLER_NAME}"
done:
FunctionEnd
Function GetVMware
IfFileExists "$EXEDIR\${VMWARE_INSTALLER_NAME}" foundvmware
MessageBox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME} reqires either VMware Server 1.0+, VMware Workstation 5.5+ or VirtualBox 2.0+. The free VMware Server will \
now be downloaded and installed because no compatible VMware installation could be detected on your system"
StrCpy $2 "$TEMP\${VMWARE_INSTALLER_NAME}"
nsisdl::download /TIMEOUT=30000 ${VMWARE_SERVER_URL} $2
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_OK "Download failed: $R0"
Quit
ExecWait $2
Delete $2
Goto done
foundvmware:
Messagebox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME} reqires either VMware Server 1.0+ or VMware Workstation 5.5+. The free VMware Server will \
now be installed from your installation media because no compatible VMware installation could be detected on your system"
ExecWait "$EXEDIR\${VMWARE_INSTALLER_NAME}"
done:
FunctionEnd
Function GetVDDK
IfFileExists "$EXEDIR\${VMWARE_VDDK_INSTALLER_NAME}" foundvddk
MessageBox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME} reqires VMware's Virtual Disk Developement Kit (VDDK) in order to use it's built in \
Disk Mount Utility. This free utility must downloaded and installed because it could be detected on your system \
Note: Free Registration is required. (http://www.vmware.com/download/sdk/virtualdisk.html)"
Quit
foundvddk:
Messagebox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME} reqires VMware's VDDK Disk Mount Utility. This free utility will \
now be installed from your installation media because no compatible VMware Disk Mount utility could be detected on your system"
ExecWait "$EXEDIR\${VMWARE_VDDK_INSTALLER_NAME}"
done:
FunctionEnd
Function DetectJRE
ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" \
"CurrentVersion"
${VersionCompare} $2 ${JRE_MIN_VERSION} $R0
IntCmp $R0 1 done
IntCmp $R0 0 done
Call GetJRE
done:
FunctionEnd
Function DetectPreviousInstall
ReadRegStr $2 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
"UninstallString"
StrCmp $2 "" done oldversiondetected
oldversiondetected:
Messagebox MB_OK|MB_ICONINFORMATION "A previous version of ${PRODUCT_NAME} was detected on your system. \
Please uninstall it before installing the new version."
Messagebox MB_YESNO "Would you like to pause this installation and launch the uninstaller now?" IDNO noskip
;execute the Uninstall info found in the registry
ExecWait $2
Messagebox MB_OK|MB_ICONINFORMATION "Please click 'OK' when the uninstaller has finished."
goto done
noskip:
;Pop $0
;didn't want to unintall
abort
done:
FunctionEnd
Function FindJRE
;
; Find JRE (javaw.exe)
; 1 - in .\jre directory (JRE Installed with application)
; 2 - in JAVA_HOME environment variable
; 3 - in the registry
; 4 - assume javaw.exe in current dir or PATH
Push $R0
Push $R1
ClearErrors
StrCpy $R0 "$EXEDIR\jre\bin\javaw.exe"
IfFileExists $R0 JreFound
StrCpy $R0 ""
ClearErrors
ReadEnvStr $R0 "JAVA_HOME"
StrCpy $R0 "$R0\bin\javaw.exe"
IfErrors 0 JreFound
ClearErrors
ReadRegStr $R1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" \
"CurrentVersion"
ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R1" \
"JavaHome"
StrCpy $R0 "$R0\bin\javaw.exe"
IfErrors 0 JreFound
StrCpy $R0 "javaw.exe"
JreFound:
Pop $R1
Exch $R0
FunctionEnd
Function DetectVMSoftware
Call DetectVBox
Pop $R0
IntCmp $R0 1 done
Call DetectVMWare
Pop $R0
IntCmp $R0 1 done
Call GetVMware
done:
FunctionEnd
Function DetectVBox
;TODO virtualbox registery settings
StrCpy $R0 "0"
ReadRegStr $2 HKLM "SOFTWARE\VMWare, Inc." \
"Core"
StrCmp $2 "VMware Server Standalone" ret1 done
StrCmp $2 "VMware Workstation" ret1 done
ret1:
StrCpy $R0 "1"
done:
FunctionEnd
Function DetectVMware
StrCpy $R0 "0"
ReadRegStr $2 HKLM "SOFTWARE\VMWare, Inc." \
"Core"
StrCmp $2 "VMware Server Standalone" ret1 done
StrCmp $2 "VMware Workstation" ret1 done
ret1:
StrCpy $R0 "1"
done:
FunctionEnd
Function DetectVDDK
ReadRegStr $2 HKLM "SOFTWARE\VMware, Inc.\VMware Virtual Disk Development Kit" \
"InstallPath"
StrCmp $2 "" novddk done
novddk:
Call GetVDDK
done:
FunctionEnd
Function DetectOldVMwareMount
ReadRegStr $2 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\vmware-mount.exe" \
"Path"
StrCmp $2 "" done hasvmmount
hasvmmount:
; Call UninstallVMwareMount
Messagebox MB_YESNO "A legacy version of vmware-mount (VMWare Diskmount Utility) was detected \
on your system. This should be removed for proper OpenLV operation. \
You should install the newer VDDK version of vmware-mount. \
Would you like to launch the uninstaller for the Diskmount Utility now?" IDNO noskip
;this is the remove key for VMWare DiskMount 5.5
ExecWait "MsiExec.exe /I{601D774D-0D04-4CB1-9E3B-5394FAAFA1FB}"
noskip:
Pop $0
done:
FunctionEnd
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd
Section Uninstall
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\TempWmicBatchFile.bat"
Delete "$INSTDIR\MostRecentRun.log"
Delete "$INSTDIR\Resources\merge.reg"
Delete "$INSTDIR\Resources\app.ico"
Delete "$INSTDIR\Resources\LVSmallIcon.gif"
Delete "$INSTDIR\Resources\genericW98Me.mbr"
Delete "$INSTDIR\Resources\generic.mbr"
Delete "$INSTDIR\OpenLV.jar"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk"
Delete "$DESKTOP\${PRODUCT_NAME} ${PRODUCT_VERSION}.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} ${PRODUCT_VERSION}.lnk"
RMDir "$SMPROGRAMS\${PRODUCT_NAME}"
RMDir "$INSTDIR\Resources"
RMDir "$INSTDIR"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd