NSIS.template.in 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. ;ownCloud installer script.
  2. !define APPLICATION_SHORTNAME "@APPLICATION_SHORTNAME@"
  3. !define APPLICATION_NAME "@APPLICATION_NAME@"
  4. !define APPLICATION_VENDOR "@APPLICATION_VENDOR@"
  5. !define APPLICATION_EXECUTABLE "@APPLICATION_EXECUTABLE@.exe"
  6. !define APPLICATION_DOMAIN "@APPLICATION_DOMAIN@"
  7. !define MUI_FINISHPAGE_LINK_LOCATION "http://www.${APPLICATION_DOMAIN}"
  8. ;-----------------------------------------------------------------------------
  9. ; Some installer script options (comment-out options not required)
  10. ;-----------------------------------------------------------------------------
  11. ;!define OPTION_LICENSE_AGREEMENT
  12. !define OPTION_UAC_PLUGIN_ENHANCED
  13. !define OPTION_SECTION_SC_START_MENU
  14. !define OPTION_SECTION_SC_DESKTOP
  15. !define OPTION_SECTION_SC_QUICK_LAUNCH
  16. !define OPTION_SECTION_SC_AUTOSTART
  17. !define OPTION_FINISHPAGE
  18. !define OPTION_FINISHPAGE_LAUNCHER
  19. ; !define OPTION_FINISHPAGE_RELEASE_NOTES
  20. ;-----------------------------------------------------------------------------
  21. ; Some paths.
  22. ;-----------------------------------------------------------------------------
  23. !ifndef MING_PATH
  24. !define MING_PATH "/usr/i686-w64-mingw32/sys-root/mingw"
  25. !endif
  26. !define MING_BIN "${MING_PATH}/bin"
  27. !define MING_LIB "${MING_PATH}/lib"
  28. !define BUILD_PATH "@CMAKE_BINARY_DIR@"
  29. !define SOURCE_PATH "@CMAKE_SOURCE_DIR@"
  30. !define QT_DLL_PATH "${MING_BIN}"
  31. !define SQLITE_DLL_PATH "${MING_LIB}/qt4/plugins/sqldrivers"
  32. !define IMAGEFORMATS_DLL_PATH "${MING_LIB}/qt4/plugins/imageformats"
  33. !define CSYNC_LIBRARY_DIR "@CSYNC_LIBRARY_DIR@"
  34. !define CSYNC_PLUGIN_DIR "@CSYNC_PLUGIN_DIR@"
  35. !define CSYNC_CONFIG_DIR "@CSYNC_CONFIG_DIR@"
  36. !define NSI_PATH "${SOURCE_PATH}/admin/win/nsi"
  37. ;-----------------------------------------------------------------------------
  38. ; Installer version
  39. ;-----------------------------------------------------------------------------
  40. !define VER_MAJOR "@CPACK_PACKAGE_VERSION_MAJOR@"
  41. !define VER_MINOR "@CPACK_PACKAGE_VERSION_MINOR@"
  42. !define VER_BUILD "@CPACK_PACKAGE_VERSION_PATCH@"
  43. !define VERSION "@CPACK_PACKAGE_VERSION@"
  44. ;-----------------------------------------------------------------------------
  45. ; Installer build timestamp.
  46. ;-----------------------------------------------------------------------------
  47. !define /date BUILD_TIME "built on %Y/%m/%d at %I:%M %p"
  48. ;-----------------------------------------------------------------------------
  49. ; Initial installer setup and definitions.
  50. ;-----------------------------------------------------------------------------
  51. Name "@CPACK_NSIS_PACKAGE_NAME@"
  52. Caption "${APPLICATION_NAME} Setup"
  53. BrandingText "${APPLICATION_NAME} ${VERSION} -- ${BUILD_TIME}"
  54. OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
  55. InstallDir "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
  56. InstallDirRegKey HKCU "Software\${APPLICATION_NAME}" ""
  57. InstType Standard
  58. InstType Full
  59. InstType Minimal
  60. CRCCheck On
  61. SetCompressor @CPACK_NSIS_COMPRESSOR@
  62. RequestExecutionLevel user ;Now using the UAC plugin.
  63. ReserveFile NSIS.InstallOptions.ini
  64. ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
  65. @CPACK_NSIS_SECTION_SELECTED_VARS@
  66. ;-----------------------------------------------------------------------------
  67. ; Include some required header files.
  68. ;-----------------------------------------------------------------------------
  69. !include LogicLib.nsh ;Used by APPDATA uninstaller.
  70. !include nsDialogs.nsh ;Used by APPDATA uninstaller.
  71. !include MUI2.nsh ;Used by APPDATA uninstaller.
  72. !include InstallOptions.nsh ;Required by MUI2 to support old MUI_INSTALLOPTIONS.
  73. !include Memento.nsh ;Remember user selections.
  74. !include WinVer.nsh ;Windows version detection.
  75. !include WordFunc.nsh ;Used by VersionCompare macro function.
  76. !include UAC.nsh ;Used by the UAC elevation to install as user or admin.
  77. ;-----------------------------------------------------------------------------
  78. ; Memento selections stored in registry.
  79. ;-----------------------------------------------------------------------------
  80. !define MEMENTO_REGISTRY_ROOT HKLM
  81. !define MEMENTO_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}"
  82. ;-----------------------------------------------------------------------------
  83. ; Modern User Interface (MUI) defintions and setup.
  84. ;-----------------------------------------------------------------------------
  85. !define MUI_ABORTWARNING
  86. !define MUI_ICON ${NSI_PATH}\installer.ico
  87. !define MUI_UNICON ${NSI_PATH}\installer.ico
  88. !define MUI_WELCOMEFINISHPAGE_BITMAP ${NSI_PATH}\welcome_${APPLICATION_SHORTNAME}.bmp
  89. !define MUI_WELCOMEPAGE_TITLE "Welcome to the @CPACK_PACKAGE_NAME@ ${VERSION} Setup Wizard"
  90. !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation.$\r$\n$\r$\n$_CLICK"
  91. !define MUI_HEADERIMAGE
  92. !define MUI_HEADERIMAGE_BITMAP ${NSI_PATH}\page_header_${APPLICATION_SHORTNAME}.bmp
  93. !define MUI_COMPONENTSPAGE_SMALLDESC
  94. !define MUI_FINISHPAGE_TITLE "@CPACK_PACKAGE_NAME@ Setup Completed"
  95. !define MUI_FINISHPAGE_LINK "Click here to visit the @CPACK_PACKAGE_NAME@ website."
  96. !define MUI_FINISHPAGE_NOREBOOTSUPPORT
  97. !ifdef OPTION_FINISHPAGE_RELEASE_NOTES
  98. !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
  99. !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\NOTES.txt"
  100. !define MUI_FINISHPAGE_SHOWREADME_TEXT "Show release notes"
  101. !endif
  102. !ifdef OPTION_FINISHPAGE_LAUNCHER
  103. !define MUI_FINISHPAGE_NOAUTOCLOSE
  104. !define MUI_FINISHPAGE_RUN
  105. !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchApplication"
  106. !endif
  107. ;-----------------------------------------------------------------------------
  108. ; Page macros.
  109. ;-----------------------------------------------------------------------------
  110. !insertmacro MUI_PAGE_WELCOME
  111. !ifdef OPTION_LICENSE_AGREEMENT
  112. !insertmacro MUI_PAGE_LICENSE "LICENSE.txt"
  113. !endif
  114. Page custom PageReinstall PageLeaveReinstall
  115. !insertmacro MUI_PAGE_COMPONENTS
  116. !insertmacro MUI_PAGE_DIRECTORY
  117. !insertmacro MUI_PAGE_INSTFILES
  118. !ifdef OPTION_FINISHPAGE
  119. !insertmacro MUI_PAGE_FINISH
  120. !endif
  121. !insertmacro MUI_UNPAGE_CONFIRM
  122. UninstPage custom un.UnPageUserAppData un.UnPageUserAppDataLeave
  123. !insertmacro MUI_UNPAGE_INSTFILES
  124. ;-----------------------------------------------------------------------------
  125. ; Other MUI macros.
  126. ;-----------------------------------------------------------------------------
  127. !insertmacro MUI_LANGUAGE "English"
  128. ##############################################################################
  129. # #
  130. # FINISH PAGE LAUNCHER FUNCTIONS #
  131. # #
  132. ##############################################################################
  133. Function LaunchApplication
  134. ${UAC.CallFunctionAsUser} LaunchApplicationAsUser
  135. FunctionEnd
  136. Function LaunchApplicationAsUser
  137. Exec "$INSTDIR\${APPLICATION_EXECUTABLE}"
  138. FunctionEnd
  139. ##############################################################################
  140. # #
  141. # PROCESS HANDLING FUNCTIONS AND MACROS #
  142. # #
  143. ##############################################################################
  144. !macro CheckForProcess processName gotoWhenFound gotoWhenNotFound
  145. Processes::FindProcess ${processName}
  146. StrCmp $R0 "0" ${gotoWhenNotFound} ${gotoWhenFound}
  147. !macroend
  148. !macro ConfirmEndProcess processName
  149. MessageBox MB_YESNO|MB_ICONEXCLAMATION \
  150. "Found ${processName} process(s) which need to be stopped.$\nDo you want the installer to stop these for you?" \
  151. IDYES process_${processName}_kill IDNO process_${processName}_ended
  152. process_${processName}_kill:
  153. DetailPrint "Killing ${processName} processes."
  154. Processes::KillProcess ${processName}
  155. Sleep 1500
  156. StrCmp $R0 "1" process_${processName}_ended
  157. DetailPrint "Process to kill not found!"
  158. process_${processName}_ended:
  159. !macroend
  160. !macro CheckAndConfirmEndProcess processName
  161. !insertmacro CheckForProcess ${processName} 0 no_process_${processName}_to_end
  162. !insertmacro ConfirmEndProcess ${processName}
  163. no_process_${processName}_to_end:
  164. !macroend
  165. Function EnsureOwncloudShutdown
  166. !insertmacro CheckAndConfirmEndProcess "${APPLICATION_EXECUTABLE}"
  167. FunctionEnd
  168. ##############################################################################
  169. # #
  170. # RE-INSTALLER FUNCTIONS #
  171. # #
  172. ##############################################################################
  173. Function PageReinstall
  174. ReadRegStr $R0 HKLM "Software\${APPLICATION_NAME}" ""
  175. StrCmp $R0 "" 0 +2
  176. Abort
  177. ;Detect version
  178. ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionMajor"
  179. IntCmp $R0 ${VER_MAJOR} minor_check new_version older_version
  180. minor_check:
  181. ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionMinor"
  182. IntCmp $R0 ${VER_MINOR} build_check new_version older_version
  183. build_check:
  184. ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionBuild"
  185. IntCmp $R0 ${VER_BUILD} same_version new_version older_version
  186. new_version:
  187. !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "An older version of ${APPLICATION_NAME} is installed on your system. It is recommended that you uninstall the current version before installing. Select the operation you want to perform and click Next to continue."
  188. !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Uninstall before installing"
  189. !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Do not uninstall"
  190. !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install ${APPLICATION_NAME}."
  191. StrCpy $R0 "1"
  192. Goto reinst_start
  193. older_version:
  194. !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "A newer version of ${APPLICATION_NAME} is already installed! It is not recommended that you install an older version. If you really want to install this older version, it is better to uninstall the current version first. Select the operation you want to perform and click Next to continue."
  195. !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Uninstall before installing"
  196. !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Do not uninstall"
  197. !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install ${APPLICATION_NAME}."
  198. StrCpy $R0 "1"
  199. Goto reinst_start
  200. same_version:
  201. !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "${APPLICATION_NAME} ${VERSION} is already installed.\r\nSelect the operation you want to perform and click Next to continue."
  202. !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Add/Reinstall components"
  203. !insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Uninstall ${APPLICATION_NAME}"
  204. !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose the maintenance option to perform."
  205. StrCpy $R0 "2"
  206. reinst_start:
  207. !insertmacro INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
  208. FunctionEnd
  209. Function PageLeaveReinstall
  210. !insertmacro INSTALLOPTIONS_READ $R1 "NSIS.InstallOptions.ini" "Field 2" "State"
  211. StrCmp $R0 "1" 0 +2
  212. StrCmp $R1 "1" reinst_uninstall reinst_done
  213. StrCmp $R0 "2" 0 +3
  214. StrCmp $R1 "1" reinst_done reinst_uninstall
  215. reinst_uninstall:
  216. ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "UninstallString"
  217. HideWindow
  218. ClearErrors
  219. ExecWait '$R1 _?=$INSTDIR'
  220. IfErrors no_remove_uninstaller
  221. IfFileExists "$INSTDIR\${APPLICATION_EXECUTABLE}" no_remove_uninstaller
  222. Delete $R1
  223. RMDir $INSTDIR
  224. no_remove_uninstaller:
  225. StrCmp $R0 "2" 0 +3
  226. UAC::Unload
  227. Quit
  228. BringToFront
  229. reinst_done:
  230. FunctionEnd
  231. ##############################################################################
  232. # #
  233. # INSTALLER SECTIONS #
  234. # #
  235. ##############################################################################
  236. Section "${APPLICATION_NAME}" SEC_OWNCLOUD
  237. SectionIn 1 2 3 RO
  238. SetDetailsPrint listonly
  239. SetDetailsPrint textonly
  240. DetailPrint "Installing ${APPLICATION_NAME} essentials."
  241. SetDetailsPrint listonly
  242. SetOutPath "$INSTDIR"
  243. !ifdef INSTALL_PATH
  244. ;Main executable.
  245. File "${INSTALL_PATH}\bin\${APPLICATION_EXECUTABLE}"
  246. !endif
  247. !ifndef INSTALL_PATH
  248. ;Main executable.
  249. File "${BUILD_PATH}\bin\${APPLICATION_EXECUTABLE}"
  250. File "${BUILD_PATH}\src\libowncloudsync.dll"
  251. File "${BUILD_PATH}\src\mirall_ca.qm"
  252. File "${BUILD_PATH}\src\mirall_cs_CZ.qm"
  253. File "${BUILD_PATH}\src\mirall_de.qm"
  254. File "${BUILD_PATH}\src\mirall_el.qm"
  255. File "${BUILD_PATH}\src\mirall_en.qm"
  256. File "${BUILD_PATH}\src\mirall_es.qm"
  257. File "${BUILD_PATH}\src\mirall_fr.qm"
  258. File "${BUILD_PATH}\src\mirall_it.qm"
  259. File "${BUILD_PATH}\src\mirall_ja_JP.qm"
  260. File "${BUILD_PATH}\src\mirall_pl.qm"
  261. File "${BUILD_PATH}\src\mirall_pt_BR.qm"
  262. File "${BUILD_PATH}\src\mirall_pt_PT.qm"
  263. File "${BUILD_PATH}\src\mirall_ru.qm"
  264. File "${BUILD_PATH}\src\mirall_sk_SK.qm"
  265. File "${BUILD_PATH}\src\mirall_sl.qm"
  266. File "${BUILD_PATH}\src\mirall_sv.qm"
  267. SetOutPath "$INSTDIR\modules"
  268. ; FIXME: fix installation dir of module, currently needs manual copying to
  269. ; /usr/i686-w64-mingw32/sys-root/mingw/bin/csync_modules/
  270. File "${CSYNC_PLUGIN_DIR}/ocsync_owncloud.dll"
  271. SetOutPath "$INSTDIR"
  272. !endif
  273. ;License & release notes.
  274. File "@CPACK_RESOURCE_FILE_LICENSE@"
  275. File /oname=NOTES.txt ${NSI_PATH}\RELEASE_NOTES.txt
  276. ;QT stuff:
  277. File "${QT_DLL_PATH}\QtCore4.dll"
  278. File "${QT_DLL_PATH}\QtGui4.dll"
  279. File "${QT_DLL_PATH}\QtNetwork4.dll"
  280. File "${QT_DLL_PATH}\QtXml4.dll"
  281. File "${CSYNC_LIBRARY_DIR}/libocsync.dll"
  282. File "${MING_BIN}\libsqlite3-0.dll"
  283. File "${MING_BIN}\libiniparser.dll"
  284. File "${MING_BIN}\libdl.dll"
  285. File "${MING_BIN}\libpng15-15.dll"
  286. ; ownCloud plugin
  287. File "${MING_BIN}\libgcrypt-11.dll"
  288. File "${MING_BIN}\libgnutls-26.dll"
  289. File "${MING_BIN}\libgpg-error-0.dll"
  290. File "${MING_BIN}\libintl-8.dll"
  291. File "${MING_BIN}\libneon-27.dll"
  292. File "${MING_BIN}\libproxy.dll"
  293. File "${MING_BIN}\libmodman.dll"
  294. File "${MING_BIN}\libtasn1-3.dll"
  295. File "${MING_BIN}\libxml2-2.dll"
  296. ;MinGW stuff
  297. File "${MING_BIN}\libgcc_s_sjlj-1.dll"
  298. File "${MING_BIN}\libstdc++-6.dll"
  299. ; Other
  300. ;File "${MING_BIN}\libpng15-15.dll"
  301. ;File "${MING_BIN}\libjpeg-8.dll"
  302. File "${MING_BIN}\zlib1.dll"
  303. File "${MING_BIN}\libcrypto-8.dll"
  304. File "${MING_BIN}\libssl-8.dll"
  305. ; CSync configs
  306. File "${CSYNC_CONFIG_DIR}/ocsync.conf"
  307. File "${SOURCE_PATH}/sync-exclude.lst"
  308. SectionEnd
  309. SectionGroup "Shortcuts"
  310. !ifdef OPTION_SECTION_SC_START_MENU
  311. ${MementoSection} "Start Menu Program Group" SEC_START_MENU
  312. SectionIn 1 2 3
  313. SetDetailsPrint textonly
  314. DetailPrint "Adding shortcuts for the ${APPLICATION_NAME} program group to the Start Menu."
  315. SetDetailsPrint listonly
  316. SetShellVarContext all
  317. RMDir /r "$SMPROGRAMS\${APPLICATION_NAME}"
  318. CreateDirectory "$SMPROGRAMS\${APPLICATION_NAME}"
  319. CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\LICENSE.lnk" "$INSTDIR\LICENSE.txt"
  320. CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\${APPLICATION_NAME}.lnk" "$INSTDIR\${APPLICATION_EXECUTABLE}"
  321. CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\Release notes.lnk" "$INSTDIR\NOTES.txt"
  322. CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe"
  323. SetShellVarContext current
  324. ${MementoSectionEnd}
  325. !endif
  326. !ifdef OPTION_SECTION_SC_DESKTOP
  327. ${MementoSection} "Desktop Shortcut" SEC_DESKTOP
  328. SectionIn 1 2
  329. SetDetailsPrint textonly
  330. DetailPrint "Creating Desktop Shortcuts"
  331. SetDetailsPrint listonly
  332. CreateShortCut "$DESKTOP\${APPLICATION_NAME}.lnk" "$INSTDIR\${APPLICATION_EXECUTABLE}"
  333. ${MementoSectionEnd}
  334. !endif
  335. !ifdef OPTION_SECTION_SC_QUICK_LAUNCH
  336. ${MementoSection} "Quick Launch Shortcut" SEC_QUICK_LAUNCH
  337. SectionIn 1 2
  338. SetDetailsPrint textonly
  339. DetailPrint "Creating Quick Launch Shortcut"
  340. SetDetailsPrint listonly
  341. CreateShortCut "$QUICKLAUNCH\${APPLICATION_NAME}.lnk" "$INSTDIR\${APPLICATION_EXECUTABLE}"
  342. ${MementoSectionEnd}
  343. !endif
  344. SectionGroupEnd
  345. !ifdef OPTION_SECTION_SC_AUTOSTART
  346. ${MementoSection} "Autostart" SEC_AUTOSTART
  347. SectionIn 1 2
  348. SetDetailsPrint textonly
  349. DetailPrint "Creating Windows Start Entry"
  350. SetDetailsPrint listonly
  351. WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Run" \
  352. "${APPLICATION_NAME}" "$INSTDIR\${APPLICATION_EXECUTABLE}"
  353. ${MementoSectionEnd}
  354. !endif
  355. ${MementoSectionDone}
  356. ; Installer section descriptions
  357. ;--------------------------------
  358. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  359. !insertmacro MUI_DESCRIPTION_TEXT ${SEC_APPLICATION} "${APPLICATION_NAME} essentials."
  360. !insertmacro MUI_DESCRIPTION_TEXT ${SEC_START_MENU} "${APPLICATION_NAME} program group."
  361. !insertmacro MUI_DESCRIPTION_TEXT ${SEC_DESKTOP} "Desktop shortcut for ${APPLICATION_NAME}."
  362. !insertmacro MUI_DESCRIPTION_TEXT ${SEC_QUICK_LAUNCH} "Quick Launch shortcut for ${APPLICATION_NAME}."
  363. !insertmacro MUI_DESCRIPTION_TEXT ${SEC_QUICK_AUTOSTART} "Register ${APPLICATION_NAME} to run on Windows startup."
  364. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  365. Section -post
  366. ;Uninstaller file.
  367. SetDetailsPrint textonly
  368. DetailPrint "Writing Uninstaller"
  369. SetDetailsPrint listonly
  370. WriteUninstaller $INSTDIR\uninstall.exe
  371. ;Registry keys required for installer version handling and uninstaller.
  372. SetDetailsPrint textonly
  373. DetailPrint "Writing Installer Registry Keys"
  374. SetDetailsPrint listonly
  375. ;Version numbers used to detect existing installation version for comparisson.
  376. WriteRegStr HKLM "Software\${APPLICATION_NAME}" "" $INSTDIR
  377. WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionMajor" "${VER_MAJOR}"
  378. WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionMinor" "${VER_MINOR}"
  379. WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionRevision" "${REVISION}"
  380. WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionBuild" "${VER_BUILD}"
  381. ;Add or Remove Programs entry.
  382. WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
  383. WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "InstallLocation" "$INSTDIR"
  384. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "DisplayName" "${APPLICATION_NAME}"
  385. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "Publisher" "${APPLICATION_VENDOR}"
  386. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "DisplayIcon" "$INSTDIR\Uninstall.exe,0"
  387. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "DisplayVersion" "${VERSION}"
  388. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "VersionMajor" "${VER_MAJOR}"
  389. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "VersionMinor" "${VER_MINOR}.${REVISION}"
  390. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "URLInfoAbout" "http://${APPLICATION_DOMAIN}/"
  391. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "HelpLink" "http://${APPLICATION_DOMAIN}/"
  392. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "NoModify" "1"
  393. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "NoRepair" "1"
  394. SetDetailsPrint textonly
  395. DetailPrint "Finished."
  396. SectionEnd
  397. ##############################################################################
  398. # #
  399. # UNINSTALLER SECTION #
  400. # #
  401. ##############################################################################
  402. Var UnPageUserAppDataDialog
  403. Var UnPageUserAppDataCheckbox
  404. Var UnPageUserAppDataCheckbox_State
  405. Var UnPageUserAppDataEditBox
  406. Function un.UnPageUserAppData
  407. !insertmacro MUI_HEADER_TEXT "Uninstall ${APPLICATION_NAME}" "Remove ${APPLICATION_NAME}'s data folder from your computer."
  408. nsDialogs::Create /NOUNLOAD 1018
  409. Pop $UnPageUserAppDataDialog
  410. ${If} $UnPageUserAppDataDialog == error
  411. Abort
  412. ${EndIf}
  413. ${NSD_CreateLabel} 0 0 100% 12u "Do you want to delete ${APPLICATION_NAME}'s data folder?"
  414. Pop $0
  415. ${NSD_CreateText} 0 13u 100% 12u "$LOCALAPPDATA\${APPLICATION_NAME}"
  416. Pop $UnPageUserAppDataEditBox
  417. SendMessage $UnPageUserAppDataEditBox ${EM_SETREADONLY} 1 0
  418. ${NSD_CreateLabel} 0 46u 100% 24u "Leave unchecked to keep the data folder for later use or check to delete the data folder."
  419. Pop $0
  420. ${NSD_CreateCheckbox} 0 71u 100% 8u "Yes, delete this data folder."
  421. Pop $UnPageUserAppDataCheckbox
  422. nsDialogs::Show
  423. FunctionEnd
  424. Function un.UnPageUserAppDataLeave
  425. ${NSD_GetState} $UnPageUserAppDataCheckbox $UnPageUserAppDataCheckbox_State
  426. FunctionEnd
  427. Function un.EnsureOwncloudShutdown
  428. !insertmacro CheckAndConfirmEndProcess "${APPLICATION_EXECUTABLE}"
  429. FunctionEnd
  430. Section Uninstall
  431. IfFileExists "$INSTDIR\${APPLICATION_EXECUTABLE}" owncloud_installed
  432. MessageBox MB_YESNO "It does not appear that ${APPLICATION_NAME} is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)?" IDYES owncloud_installed
  433. Abort "Uninstall aborted by user"
  434. owncloud_installed:
  435. ;Delete registry keys.
  436. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}"
  437. DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionBuild"
  438. DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionMajor"
  439. DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionMinor"
  440. DeleteRegValue HKLM "Software\${APPLICATION_NAME}" "VersionRevision"
  441. DeleteRegValue HKLM "Software\${APPLICATION_NAME}" ""
  442. DeleteRegKey HKLM "Software\${APPLICATION_NAME}"
  443. DeleteRegKey HKCR "${APPLICATION_NAME}"
  444. ;Windows Start entry
  445. !ifdef OPTION_SECTION_SC_AUTOSTART
  446. DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "${APPLICATION_NAME}"
  447. !endif
  448. ;Start menu shortcuts.
  449. !ifdef OPTION_SECTION_SC_START_MENU
  450. SetShellVarContext all
  451. RMDir /r "$SMPROGRAMS\${APPLICATION_NAME}"
  452. SetShellVarContext current
  453. !endif
  454. ;Desktop shortcut.
  455. !ifdef OPTION_SECTION_SC_DESKTOP
  456. IfFileExists "$DESKTOP\${APPLICATION_NAME}.lnk" 0 +2
  457. Delete "$DESKTOP\${APPLICATION_NAME}.lnk"
  458. !endif
  459. ;Quick Launch shortcut.
  460. !ifdef OPTION_SECTION_SC_QUICK_LAUNCH
  461. IfFileExists "$QUICKLAUNCH\${APPLICATION_NAME}.lnk" 0 +2
  462. Delete "$QUICKLAUNCH\${APPLICATION_NAME}.lnk"
  463. !endif
  464. ;Remove all the Program Files.
  465. RMDir /r $INSTDIR
  466. ;Uninstall User Data if option is checked, otherwise skip.
  467. ${If} $UnPageUserAppDataCheckbox_State == ${BST_CHECKED}
  468. RMDir /r "$LOCALAPPDATA\${APPLICATION_NAME}"
  469. ${EndIf}
  470. SetDetailsPrint textonly
  471. DetailPrint "Finshed."
  472. SectionEnd
  473. ##############################################################################
  474. # #
  475. # NSIS Installer Event Handler Functions #
  476. # #
  477. ##############################################################################
  478. Function .onInit
  479. !insertmacro INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
  480. ;Remove Quick Launch option from Windows 7, as no longer applicable - usually.
  481. ${IfNot} ${AtMostWinVista}
  482. SectionSetText ${SEC_QUICK_LAUNCH} "Quick Launch Shortcut (N/A)"
  483. SectionSetFlags ${SEC_QUICK_LAUNCH} ${SF_RO}
  484. SectionSetInstTypes ${SEC_QUICK_LAUNCH} 0
  485. ${EndIf}
  486. ${MementoSectionRestore}
  487. UAC_Elevate:
  488. UAC::RunElevated
  489. StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
  490. StrCmp 0 $0 0 UAC_Err ; Error?
  491. StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
  492. Quit
  493. UAC_Err:
  494. MessageBox MB_ICONSTOP "Unable to elevate, error $0"
  495. Abort
  496. UAC_ElevationAborted:
  497. Abort
  498. UAC_Success:
  499. StrCmp 1 $3 +4 ;Admin?
  500. StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
  501. MessageBox MB_ICONSTOP "This installer requires admin access, try again"
  502. goto UAC_Elevate
  503. ;Prevent multiple instances.
  504. System::Call 'kernel32::CreateMutexA(i 0, i 0, t "owncloudInstaller") i .r1 ?e'
  505. Pop $R0
  506. StrCmp $R0 0 +3
  507. MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
  508. Abort
  509. ;Use available InstallLocation when possible. This is useful in the uninstaller
  510. ;via re-install, which would otherwise use a default location - a bug.
  511. ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPLICATION_NAME}" "InstallLocation"
  512. StrCmp $R0 "" SkipSetInstDir
  513. StrCpy $INSTDIR $R0
  514. SkipSetInstDir:
  515. ;Shutdown ${APPLICATION_NAME} in case Add/Remove re-installer option used.
  516. Call EnsureOwncloudShutdown
  517. FunctionEnd
  518. Function .onInstSuccess
  519. ${MementoSectionSave}
  520. UAC::Unload ;Must call unload!
  521. FunctionEnd
  522. Function .onInstFailed
  523. UAC::Unload ;Must call unload!
  524. FunctionEnd
  525. ##############################################################################
  526. # #
  527. # NSIS Uninstaller Event Handler Functions #
  528. # #
  529. ##############################################################################
  530. Function un.onInit
  531. UAC_Elevate:
  532. UAC::RunElevated
  533. StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
  534. StrCmp 0 $0 0 UAC_Err ; Error?
  535. StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
  536. Quit
  537. UAC_Err:
  538. MessageBox MB_ICONSTOP "Unable to elevate, error $0"
  539. Abort
  540. UAC_ElevationAborted:
  541. Abort
  542. UAC_Success:
  543. StrCmp 1 $3 +4 ;Admin?
  544. StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
  545. MessageBox MB_ICONSTOP "This uninstaller requires admin access, try again"
  546. goto UAC_Elevate
  547. ;Prevent multiple instances.
  548. System::Call 'kernel32::CreateMutexA(i 0, i 0, t "owncloudUninstaller") i .r1 ?e'
  549. Pop $R0
  550. StrCmp $R0 0 +3
  551. MessageBox MB_OK|MB_ICONEXCLAMATION "This uninstaller is already running."
  552. Abort
  553. ;Shutdown ${APPLICATION_NAME} in order to remove locked files.
  554. Call un.EnsureOwncloudShutdown
  555. FunctionEnd
  556. Function un.onUnInstSuccess
  557. UAC::Unload ;Must call unload!
  558. FunctionEnd
  559. Function un.onUnInstFailed
  560. UAC::Unload ;Must call unload!
  561. FunctionEnd