Update README.md
[engrid-github.git] / src / misc / engrid.nsi
blobe1261a70d1e009aa559c6082e9711d224c10d7d7
1 ; !define FASTBUILD ; uncomment for debugging this script
3 ;Accepted name defines:
4 ; USE_mingw32
5 ; USE_VisualCppExpress2008
6 ; USE_VisualCppExpress2008_x64
8 ;Accepted value defines:
9 ; OUTPUTFOLDER="Folder path"
10 ; BUILDVERSION="win32"
11 ; PRODUCT_VERSION="1.4"
12 ; PRODUCT_VERSIONx4=1.4.0.0
14 ; Script generated by the HM NIS Edit Script Wizard.
15 ; TODO: The MinGW version is unfinished...
16 !ifdef USE_mingw32
17 !define MINGWBINDIR "c:\qt\2009.03\mingw\bin"
18 !define QTBINDIR "c:\qt\2009.03\qt\bin"
19 !define VTKBINDIR "P:\VTK\bin"
20 !endif
21 !ifdef USE_VisualCppExpress2008
22 !define QTBINDIR "${SRC_ROOT}\third_party\Qt\bin"
23 !define VTKBINDIR "${SRC_ROOT}\third_party\VTK\bin"
24 !define VTKLIBDIR "${SRC_ROOT}\third_party\VTK\lib"
25 !endif
27 !ifdef USE_VisualCppExpress2008_x64
28 !define QTBINDIR "${SRC_ROOT}\third_party64\Qt\bin"
29 !define VTKBINDIR "${SRC_ROOT}\third_party64\VTK\bin"
30 !define VTKLIBDIR "${SRC_ROOT}\third_party64\VTK\lib"
31 !ifndef USE_VisualCppExpress2008
32 !define USE_VisualCppExpress2008 ; useful for redundant operations!
33 !endif
34 !define WIN64
35 !endif
37 ; FIXME: These two are to be dropped?
38 !define QWTLIBDIR "c:\Libraries\qwt-5.3.0-svn\lib"
39 !define QWTPLOT3DLIBDIR "c:\Libraries\qwtplot3d\lib"
41 ;Default values:
42 !ifndef OUTPUTFOLDER
43 !define OUTPUTFOLDER "${SRC_ROOT}\windows"
44 !endif
46 !ifndef BUILDVERSION
47 !define BUILDVERSION "win32"
48 !endif
50 !ifndef PRODUCT_VERSION
51 !define PRODUCT_VERSION "1.4"
52 !endif
54 !ifndef PRODUCT_VERSIONx4
55 !define PRODUCT_VERSIONx4 1.4.0.0
56 !endif
58 ; Set up general options
59 ; SetCompressor lzma
60 !ifndef FASTBUILD
61 SetCompressor /SOLID lzma ; saves about 1.2MB
62 SetCompressorDictSize 128
63 !endif
66 ; set-up UAC
67 RequestExecutionLevel user
68 !addincludedir NSIS
69 !addplugindir NSIS
70 !include UAC.nsh
72 !ifdef WIN64
73 !include x64.nsh
74 !endif
76 ; Load headers for file functions
77 !include "FileFunc.nsh"
80 ; HM NIS Edit Wizard helper defines
81 !define SRC_ROOT "..\"
82 !define PRODUCT_NAME "enGrid"
83 ; PRODUCT_VERSION defined on the header part of this file
84 !define PRODUCT_PUBLISHER "enGits GmbH"
85 !define PRODUCT_WEB_SITE "http://www.engits.eu"
86 !define WIKI_WEB_SITE "https://github.com/enGits/engrid/wiki"
87 !define PRODUCT_DIR_REGKEY "Software\enGits\${PRODUCT_NAME}"
88 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
89 !define PRODUCT_UNINST_ROOT_KEY "HKLM"
90 !define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
92 ; MUI 1.67 compatible ------
93 !include "MUI.nsh"
95 ; MUI Settings
96 !define MUI_ABORTWARNING
97 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
98 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
100 ; Welcome page
101 !insertmacro MUI_PAGE_WELCOME
102 ; License page
103 !insertmacro MUI_PAGE_LICENSE "..\licence_exe.txt"
105 ; Directory page
106 !insertmacro MUI_PAGE_DIRECTORY
107 ; Start menu page
108 var ICONS_GROUP
109 var DESKTOP_ICON
110 !define MUI_STARTMENUPAGE_NODISABLE
111 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "$ICONS_GROUP"
112 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
113 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
114 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
115 !insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
116 ; Instfiles page
117 !insertmacro MUI_PAGE_INSTFILES
119 ; Finish page
120 ; Overriding the execution of enGrid to be done as normal user.
121 Function ExecAppFile
122 Exec '$INSTDIR\engrid.exe'
123 FunctionEnd
125 Function AppRunAs
126 !insertmacro UAC.CallFunctionAsUser ExecAppFile
127 FunctionEnd
129 !define MUI_FINISHPAGE_RUN
130 !define MUI_FINISHPAGE_RUN_FUNCTION AppRunAs
132 Function finishpageaction
133 SetShellVarContext all
134 CreateShortCut "$DESKTOP\enGrid.lnk" "$INSTDIR\engrid.exe" " " "$INSTDIR\engrid.exe"
135 StrCpy $DESKTOP_ICON "1"
136 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_DIR_REGKEY}" "DesktopIcon" "$DESKTOP_ICON"
137 FunctionEnd
139 !define MUI_FINISHPAGE_SHOWREADME ""
140 !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
141 !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
142 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION finishpageaction
144 !insertmacro MUI_PAGE_FINISH
146 ; Uninstaller pages
147 !insertmacro MUI_UNPAGE_INSTFILES
149 ; Language files
150 !insertmacro MUI_LANGUAGE "English"
152 ; MUI end ------
154 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
155 OutFile "${OUTPUTFOLDER}\${PRODUCT_NAME}_${PRODUCT_VERSION}_setup_${BUILDVERSION}.exe"
156 !ifdef WIN64
157 InstallDir "$PROGRAMFILES64\enGits\enGrid"
158 !else
159 InstallDir "$PROGRAMFILES\enGits\enGrid"
160 !endif
161 InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
162 ShowInstDetails show
163 ShowUnInstDetails show
165 Caption "${PRODUCT_NAME} ${PRODUCT_VERSION}"
166 VIProductVersion ${PRODUCT_VERSIONx4}
167 VIAddVersionKey ProductName "${PRODUCT_NAME}"
168 VIAddVersionKey Comments "Installer for ${PRODUCT_NAME} ${PRODUCT_VERSION}, build version ${BUILDVERSION}."
169 VIAddVersionKey CompanyName "${PRODUCT_PUBLISHER}"
170 VIAddVersionKey LegalCopyright "${PRODUCT_WEB_SITE}"
171 VIAddVersionKey FileDescription "${PRODUCT_NAME} ${PRODUCT_VERSION} installer."
172 VIAddVersionKey FileVersion ${PRODUCT_VERSIONx4}
173 VIAddVersionKey ProductVersion ${PRODUCT_VERSIONx4}
174 VIAddVersionKey InternalName "${PRODUCT_NAME} ${PRODUCT_VERSION} installer."
175 VIAddVersionKey LegalTrademarks "enGrid is a Trademark of enGits, GmbH."
176 VIAddVersionKey OriginalFilename "${PRODUCT_NAME}_${PRODUCT_VERSION}_setup_${BUILDVERSION}.exe"
178 Function .onInit
180 !ifdef WIN64
181 SetRegView 64
182 ${DisableX64FSRedirection}
184 ${If} ${RunningX64}
185 ${EnableX64FSRedirection}
186 ${else}
187 MessageBox MB_OK "Sorry this application runs only on x64 machines"
188 Abort
189 ${EndIf}
190 !endif
192 ;Extract InstallOptions files
193 ;$PLUGINSDIR will automatically be removed when the installer closes
195 InitPluginsDir
197 ; Initialize global variables
198 !ifdef WIN64
199 StrCpy $ICONS_GROUP "enGits\${PRODUCT_NAME} (x64)"
200 StrCpy $INSTDIR "$PROGRAMFILES64\enGits\enGrid"
201 !else
202 StrCpy $ICONS_GROUP "enGits\${PRODUCT_NAME}"
203 !endif
204 StrCpy $DESKTOP_ICON "0"
206 ; Force installation as super-user
207 UAC_Elevate:
208 UAC::RunElevated
209 StrCmp 1223 $0 UAC_ElevationAborted
210 StrCmp 0 $0 0 UAC_Err
211 StrCmp 1 $1 0 UAC_Success
212 Quit
214 UAC_Err:
215 MessageBox mb_iconstop "Unable to elevate, error $0"
216 Abort
218 UAC_ElevationAborted:
219 MessageBox mb_iconstop "This installer requires admin access, aborting!"
220 Abort
222 UAC_Success:
223 StrCmp 1 $3 +4
224 StrCmp 3 $1 0 UAC_ElevationAborted
225 MessageBox mb_iconstop "This installer requires admin access, try again"
226 goto UAC_Elevate
228 ; if the application is already installed, then ask you one wants to uninstall it
229 ReadRegStr $R0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString"
230 StrCmp $R0 "" done
232 ReadRegStr $R1 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion"
234 MessageBox MB_YESNO|MB_ICONEXCLAMATION "The enGrid version $R1 is already installed. $\nDo you want to remove \
235 the previous version before installing $(^Name)?" IDNO done
237 ;Run the uninstaller
238 ;uninst:
239 ClearErrors
240 ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
242 done:
244 FunctionEnd
246 Function .OnInstFailed
247 ${RefreshShellIcons}
248 UAC::Unload
249 FunctionEnd
251 !define SHCNE_ASSOCCHANGED 0x08000000
252 !define SHCNF_IDLIST 0
254 Function .OnInstSuccess
255 ${RefreshShellIcons}
256 UAC::Unload
257 FunctionEnd
259 Section "MainSection" SEC01
260 InstallOptions::dialog "$PLUGINSDIR\test.ini"
262 SetOutPath "$INSTDIR"
263 SetOverwrite ifnewer
264 !ifdef USE_mingw32
265 File "${SRC_ROOT}\release\engrid.exe"
266 File "${SRC_ROOT}\release\libengrid.dll"
267 File "${SRC_ROOT}\release\nglib.dll"
268 !else ifdef USE_VisualCppExpress2008_x64
269 File "${SRC_ROOT}\windows\VisualCppExpress2008\x64\Release\engrid.exe"
270 File "${SRC_ROOT}\windows\VisualCppExpress2008\x64\Release\libengrid.dll"
271 File "${SRC_ROOT}\windows\VisualCppExpress2008\x64\Release\nglib.dll"
272 !else ifdef USE_VisualCppExpress2008
273 File "${SRC_ROOT}\windows\VisualCppExpress2008\Release\engrid.exe"
274 File "${SRC_ROOT}\windows\VisualCppExpress2008\Release\libengrid.dll"
275 File "${SRC_ROOT}\windows\VisualCppExpress2008\Release\nglib.dll"
276 !endif
277 File "${SRC_ROOT}\licence.txt"
278 File "${SRC_ROOT}\license.txt"
279 File "${SRC_ROOT}\licence_exe.txt"
281 ;Install libraries
282 !include install_libraries.nsh
283 ;Install files
284 !include install_files.nsh
286 ;Create links
287 SetShellVarContext all
288 CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
289 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\enGrid.lnk" "$INSTDIR\engrid.exe" " " "$INSTDIR\engrid.exe"
291 SectionEnd
293 Section -AdditionalIcons
294 SetShellVarContext all
295 WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
296 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\enGits Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
298 WriteIniStr "$INSTDIR\${PRODUCT_NAME}_wiki.url" "InternetShortcut" "URL" "${WIKI_WEB_SITE}"
299 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\enGrid Wiki.lnk" "$INSTDIR\${PRODUCT_NAME}_wiki.url"
301 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Browse Tutorials.lnk" "$INSTDIR\tutorials"
303 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Browse Scripts for Blender.lnk" "$INSTDIR\blender_scripts"
305 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninst.exe"
306 ${RefreshShellIcons}
307 SectionEnd
309 Section -Post
310 WriteUninstaller "$INSTDIR\uninst.exe"
311 WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\engrid.exe"
312 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
313 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
314 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\engrid.exe"
315 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
316 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
317 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
318 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DesktopIcon" "$DESKTOP_ICON"
319 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "ProgramGroup" "$ICONS_GROUP"
320 WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "InstallDir" "$INSTDIR"
321 WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "Version" "${PRODUCT_VERSION}"
322 WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "tmp_directory" "$TEMP"
323 WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "working_directory" "$DOCUMENTS"
324 SectionEnd
327 Function un.onUninstSuccess
328 HideWindow
329 UAC::Unload
330 Delete "$INSTDIR\UAC.dll"
331 MessageBox MB_ICONINFORMATION|MB_OK "enGrid was successfully removed from your computer."
332 FunctionEnd
334 Function un.OnUnInstFailed
335 UAC::Unload
336 FunctionEnd
338 Function un.onInit
340 !ifdef WIN64
341 SetRegView 64
342 ${DisableX64FSRedirection}
343 !endif
345 UAC_Elevate:
346 UAC::RunElevated
347 StrCmp 1223 $0 UAC_ElevationAborted
348 StrCmp 0 $0 0 UAC_Err
349 StrCmp 1 $1 0 UAC_Success
350 Quit
352 UAC_Err:
353 MessageBox mb_iconstop "Unable to elevate, error $0"
354 Abort
356 UAC_ElevationAborted:
357 MessageBox mb_iconstop "This installer requires admin access, aborting!"
358 Abort
360 UAC_Success:
361 StrCmp 1 $3 +4
362 StrCmp 3 $1 0 UAC_ElevationAborted
363 MessageBox mb_iconstop "This installer requires admin access, try again"
364 goto UAC_Elevate
366 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove enGrid and all of its components?" IDYES +2
367 Abort
369 FunctionEnd
372 Section Uninstall
373 SetShellVarContext all
375 ;Remove files
376 !include uninstall_files.nsh
377 ;Remove libraries
378 !include uninstall_libraries.nsh
380 Delete "$INSTDIR\${PRODUCT_NAME}.url"
381 Delete "$INSTDIR\${PRODUCT_NAME}_wiki.url"
382 Delete "$INSTDIR\uninst.exe"
383 Delete "$INSTDIR\engrid.exe"
384 Delete "$INSTDIR\libengrid.dll"
385 Delete "$INSTDIR\nglib.dll"
386 Delete "$INSTDIR\license.txt"
387 Delete "$INSTDIR\licence.txt"
388 Delete "$INSTDIR\licence_exe.txt"
390 ReadRegStr $DESKTOP_ICON ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DesktopIcon"
391 StrCmp $R0 "0" +2
392 Delete "$DESKTOP\enGrid.lnk"
394 ReadRegStr $ICONS_GROUP ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "ProgramGroup"
396 Delete "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk"
397 Delete "$SMPROGRAMS\$ICONS_GROUP\enGits Website.lnk"
398 Delete "$SMPROGRAMS\$ICONS_GROUP\enGrid.lnk"
399 Delete "$SMPROGRAMS\$ICONS_GROUP\enGrid Wiki.lnk"
400 Delete "$SMPROGRAMS\$ICONS_GROUP\Browse Tutorials.lnk"
401 RMDir "$SMPROGRAMS\$ICONS_GROUP"
403 ; Take care of the parent folder here as well
404 ${GetParent} "$ICONS_GROUP" $R0
405 StrCmp $R0 "enGits" 0 +3
406 IfFileExists "$SMPROGRAMS\enGits" 0 +2
407 RMDir "$SMPROGRAMS\enGits"
409 RMDir "$INSTDIR"
411 ; this is a "just in case" for Program Files only. It will not take care of other custom folders!
412 ${GetParent} "$INSTDIR" $R0
414 !ifndef WIN64
415 StrCmp $R0 "$PROGRAMFILES\enGits" 0 +3
416 IfFileExists "$PROGRAMFILES\enGits" 0 +2
417 RMDir "$PROGRAMFILES\enGits"
418 StrCmp $R0 "$PROGRAMFILES32\enGits" 0 +3
419 IfFileExists "$PROGRAMFILES32\enGits" 0 +2
420 RMDir "$PROGRAMFILES32\enGits"
421 !else
422 StrCmp $R0 "$PROGRAMFILES64\enGits" 0 +3
423 IfFileExists "$PROGRAMFILES64\enGits" 0 +2
424 RMDir "$PROGRAMFILES64\enGits"
425 !endif
427 DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
428 DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
429 SetAutoClose true
430 SectionEnd