NSIS.template.in 26 KB

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