Installer.nsi 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. ; Usage:
  2. ; get the latest nsis: https://nsis.sourceforge.io/Download
  3. ; probably also want vscode extension: https://marketplace.visualstudio.com/items?itemName=idleberg.nsis
  4. ; makensis /DDOLPHIN_ARCH=<x64|arm64> /PRODUCT_VERSION=<release-name> <this-script>
  5. ; Require /DDOLPHIN_ARCH=<x64|arm64> to makensis.
  6. ; TODO support packing both archs in single installer.
  7. !ifndef DOLPHIN_ARCH
  8. !error "DOLPHIN_ARCH must be defined"
  9. !endif
  10. ; Require /PRODUCT_VERSION=<release-name> to makensis.
  11. !ifndef PRODUCT_VERSION
  12. !error "PRODUCT_VERSION must be defined"
  13. !endif
  14. !define PRODUCT_NAME "Dolphin"
  15. !define PRODUCT_PUBLISHER "Dolphin Team"
  16. !define PRODUCT_WEB_SITE "https://dolphin-emu.org/"
  17. !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_NAME}.exe"
  18. !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
  19. !define BINARY_SOURCE_DIR "..\Binary\${DOLPHIN_ARCH}"
  20. Name "${PRODUCT_NAME}"
  21. OutFile "dolphin-${DOLPHIN_ARCH}-${PRODUCT_VERSION}.exe"
  22. SetCompressor /SOLID lzma
  23. ShowInstDetails show
  24. ShowUnInstDetails show
  25. ; Setup MultiUser support:
  26. ; If launched without ability to elevate, user will not see any extra options.
  27. ; If user has ability to elevate, they can choose to install system-wide, with default to CurrentUser.
  28. !define MULTIUSER_EXECUTIONLEVEL Highest
  29. !define MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
  30. !define MULTIUSER_INSTALLMODE_INSTDIR "${PRODUCT_NAME}"
  31. !define MULTIUSER_MUI
  32. !define MULTIUSER_INSTALLMODE_COMMANDLINE
  33. !define MULTIUSER_USE_PROGRAMFILES64
  34. !include "MultiUser.nsh"
  35. !include "MUI2.nsh"
  36. ; MUI Settings
  37. !define MUI_ICON "Dolphin.ico"
  38. !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
  39. ; License page
  40. !insertmacro MUI_PAGE_LICENSE "..\Data\license.txt"
  41. ; All/Current user selection page
  42. !insertmacro MULTIUSER_PAGE_INSTALLMODE
  43. ; Directory page
  44. !insertmacro MUI_PAGE_DIRECTORY
  45. ; Instfiles page
  46. !insertmacro MUI_PAGE_INSTFILES
  47. ; Finish page
  48. !insertmacro MUI_PAGE_FINISH
  49. ; Uninstaller pages
  50. !insertmacro MUI_UNPAGE_INSTFILES
  51. ; Language files
  52. !insertmacro MUI_LANGUAGE "Afrikaans"
  53. !insertmacro MUI_LANGUAGE "Albanian"
  54. !insertmacro MUI_LANGUAGE "Arabic"
  55. !insertmacro MUI_LANGUAGE "Armenian"
  56. !insertmacro MUI_LANGUAGE "Asturian"
  57. !insertmacro MUI_LANGUAGE "Basque"
  58. !insertmacro MUI_LANGUAGE "Belarusian"
  59. !insertmacro MUI_LANGUAGE "Bosnian"
  60. !insertmacro MUI_LANGUAGE "Breton"
  61. !insertmacro MUI_LANGUAGE "Bulgarian"
  62. !insertmacro MUI_LANGUAGE "Catalan"
  63. !insertmacro MUI_LANGUAGE "Corsican"
  64. !insertmacro MUI_LANGUAGE "Croatian"
  65. !insertmacro MUI_LANGUAGE "Czech"
  66. !insertmacro MUI_LANGUAGE "Danish"
  67. !insertmacro MUI_LANGUAGE "Dutch"
  68. !insertmacro MUI_LANGUAGE "English"
  69. !insertmacro MUI_LANGUAGE "Esperanto"
  70. !insertmacro MUI_LANGUAGE "Estonian"
  71. !insertmacro MUI_LANGUAGE "Farsi"
  72. !insertmacro MUI_LANGUAGE "Finnish"
  73. !insertmacro MUI_LANGUAGE "French"
  74. !insertmacro MUI_LANGUAGE "Galician"
  75. !insertmacro MUI_LANGUAGE "Georgian"
  76. !insertmacro MUI_LANGUAGE "German"
  77. !insertmacro MUI_LANGUAGE "Greek"
  78. !insertmacro MUI_LANGUAGE "Hebrew"
  79. !insertmacro MUI_LANGUAGE "Hindi"
  80. !insertmacro MUI_LANGUAGE "Hungarian"
  81. !insertmacro MUI_LANGUAGE "Icelandic"
  82. !insertmacro MUI_LANGUAGE "Indonesian"
  83. !insertmacro MUI_LANGUAGE "Irish"
  84. !insertmacro MUI_LANGUAGE "Italian"
  85. !insertmacro MUI_LANGUAGE "Japanese"
  86. !insertmacro MUI_LANGUAGE "Korean"
  87. !insertmacro MUI_LANGUAGE "Kurdish"
  88. !insertmacro MUI_LANGUAGE "Latvian"
  89. !insertmacro MUI_LANGUAGE "Lithuanian"
  90. !insertmacro MUI_LANGUAGE "Luxembourgish"
  91. !insertmacro MUI_LANGUAGE "Macedonian"
  92. !insertmacro MUI_LANGUAGE "Malay"
  93. !insertmacro MUI_LANGUAGE "Mongolian"
  94. !insertmacro MUI_LANGUAGE "Norwegian"
  95. !insertmacro MUI_LANGUAGE "NorwegianNynorsk"
  96. !insertmacro MUI_LANGUAGE "Pashto"
  97. !insertmacro MUI_LANGUAGE "Polish"
  98. !insertmacro MUI_LANGUAGE "Portuguese"
  99. !insertmacro MUI_LANGUAGE "PortugueseBR"
  100. !insertmacro MUI_LANGUAGE "Romanian"
  101. !insertmacro MUI_LANGUAGE "Russian"
  102. !insertmacro MUI_LANGUAGE "ScotsGaelic"
  103. !insertmacro MUI_LANGUAGE "Serbian"
  104. !insertmacro MUI_LANGUAGE "SerbianLatin"
  105. !insertmacro MUI_LANGUAGE "SimpChinese"
  106. !insertmacro MUI_LANGUAGE "Slovak"
  107. !insertmacro MUI_LANGUAGE "Slovenian"
  108. !insertmacro MUI_LANGUAGE "Spanish"
  109. !insertmacro MUI_LANGUAGE "SpanishInternational"
  110. !insertmacro MUI_LANGUAGE "Swedish"
  111. !insertmacro MUI_LANGUAGE "Tatar"
  112. !insertmacro MUI_LANGUAGE "Thai"
  113. !insertmacro MUI_LANGUAGE "TradChinese"
  114. !insertmacro MUI_LANGUAGE "Turkish"
  115. !insertmacro MUI_LANGUAGE "Ukrainian"
  116. !insertmacro MUI_LANGUAGE "Uzbek"
  117. !insertmacro MUI_LANGUAGE "Vietnamese"
  118. !insertmacro MUI_LANGUAGE "Welsh"
  119. ; MUI end ------
  120. !include "WinVer.nsh"
  121. ; Declare the installer itself as win10/win11 compatible, so WinVer.nsh works correctly.
  122. ManifestSupportedOS {8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}
  123. Function .onInit
  124. !insertmacro MULTIUSER_INIT
  125. ; Keep in sync with build_info.txt
  126. !define MIN_WIN10_VERSION 1703
  127. ${IfNot} ${AtLeastwin10}
  128. ${OrIfNot} ${AtLeastWaaS} ${MIN_WIN10_VERSION}
  129. MessageBox MB_OK "At least Windows 10 version ${MIN_WIN10_VERSION} is required."
  130. Abort
  131. ${EndIf}
  132. !insertmacro MUI_LANGDLL_DISPLAY
  133. FunctionEnd
  134. Function un.onInit
  135. !insertmacro MULTIUSER_UNINIT
  136. FunctionEnd
  137. Var DisplayName
  138. !macro UPDATE_DISPLAYNAME
  139. ${If} $MultiUser.InstallMode == "CurrentUser"
  140. StrCpy $DisplayName "$(^Name) (User)"
  141. ${Else}
  142. StrCpy $DisplayName "$(^Name)"
  143. ${EndIf}
  144. !macroend
  145. Section "Base"
  146. SectionIn RO
  147. SetOutPath "$INSTDIR"
  148. ; Clean up some old files possibly leftover from previous installs
  149. ; We only need to care about files which would cause problems if they were to
  150. ; be unexpectedly dynamically picked up by the incoming install.
  151. ; Note NSIS will happily install the same thing even if already installed.
  152. RMDir /r "$INSTDIR\Sys"
  153. RMDir /r "$INSTDIR\Languages"
  154. ; The binplaced build output will be included verbatim.
  155. File /r "${BINARY_SOURCE_DIR}\*"
  156. !insertmacro UPDATE_DISPLAYNAME
  157. ; Create start menu and desktop shortcuts
  158. ; This needs to be done after Dolphin.exe is copied
  159. CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
  160. CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\$DisplayName.lnk" "$INSTDIR\Dolphin.exe"
  161. CreateShortCut "$DESKTOP\$DisplayName.lnk" "$INSTDIR\Dolphin.exe"
  162. ; ??
  163. SetOutPath "$TEMP"
  164. SectionEnd
  165. Section -AdditionalIcons
  166. ; Create start menu shortcut for the uninstaller
  167. CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall $DisplayName.lnk" "$INSTDIR\uninst.exe" "/$MultiUser.InstallMode"
  168. SectionEnd
  169. !include "FileFunc.nsh"
  170. Section -Post
  171. WriteUninstaller "$INSTDIR\uninst.exe"
  172. WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\Dolphin.exe"
  173. ; Write metadata for add/remove programs applet
  174. WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "$DisplayName"
  175. WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe /$MultiUser.InstallMode"
  176. WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\Dolphin.exe"
  177. WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  178. WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  179. WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
  180. WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR"
  181. ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
  182. IntFmt $0 "0x%08X" $0
  183. WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "EstimatedSize" "$0"
  184. WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Comments" "GameCube and Wii emulator"
  185. SectionEnd
  186. Section Uninstall
  187. !insertmacro UPDATE_DISPLAYNAME
  188. Delete "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall $DisplayName.lnk"
  189. Delete "$DESKTOP\$DisplayName.lnk"
  190. Delete "$SMPROGRAMS\${PRODUCT_NAME}\$DisplayName.lnk"
  191. RMDir "$SMPROGRAMS\${PRODUCT_NAME}"
  192. ; Be a bit careful to not delete files a user may have put into the install directory.
  193. Delete "$INSTDIR\*.dll"
  194. Delete "$INSTDIR\build_info.txt"
  195. Delete "$INSTDIR\Dolphin.exe"
  196. Delete "$INSTDIR\DolphinTool.exe"
  197. Delete "$INSTDIR\DSPTool.exe"
  198. Delete "$INSTDIR\license.txt"
  199. Delete "$INSTDIR\qt.conf"
  200. Delete "$INSTDIR\uninst.exe"
  201. Delete "$INSTDIR\Updater.exe"
  202. Delete "$INSTDIR\Updater.log"
  203. RMDir /r "$INSTDIR\Sys"
  204. RMDir /r "$INSTDIR\Languages"
  205. RMDir /r "$INSTDIR\QtPlugins"
  206. RMDir "$INSTDIR"
  207. DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
  208. DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
  209. SetAutoClose true
  210. SectionEnd