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