update nsis installer

* MUI2
* add new langs supported by nsis 3.08
* MultiUser
* specify arch and build version on command line
This commit is contained in:
Shawn Hoffman 2022-09-16 06:27:25 -07:00
parent 34de2b85f3
commit 6a3412de1f
2 changed files with 125 additions and 88 deletions

View File

@ -1,38 +1,53 @@
!define DOLPHIN_ARCH x64 ; Usage:
!define BASE_INSTALL_DIR "$PROGRAMFILES64" ; get the latest nsis: https://nsis.sourceforge.io/Download
; probably also want vscode extension: https://marketplace.visualstudio.com/items?itemName=idleberg.nsis
; makensis /DDOLPHIN_ARCH=<x64|arm64> /PRODUCT_VERSION=<release-name> <this-script>
; Require /DDOLPHIN_ARCH=<x64|arm64> to makensis.
; TODO support packing both archs in single installer.
!ifndef DOLPHIN_ARCH
!error "DOLPHIN_ARCH must be defined"
!endif
; Require /PRODUCT_VERSION=<release-name> to makensis.
!ifndef PRODUCT_VERSION
!error "PRODUCT_VERSION must be defined"
!endif
!define PRODUCT_NAME "Dolphin" !define PRODUCT_NAME "Dolphin"
!define PRODUCT_VERSION 5.0
!define BASE_DIR "..\Binary\${DOLPHIN_ARCH}"
; HM NIS Edit Wizard helper defines
!define PRODUCT_PUBLISHER "Dolphin Team" !define PRODUCT_PUBLISHER "Dolphin Team"
!define PRODUCT_WEB_SITE "https://dolphin-emu.org/" !define PRODUCT_WEB_SITE "https://dolphin-emu.org/"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_NAME}.exe" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_NAME}.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define BINARY_SOURCE_DIR "..\Binary\${DOLPHIN_ARCH}"
Name "${PRODUCT_NAME}"
OutFile "dolphin-${DOLPHIN_ARCH}-${PRODUCT_VERSION}.exe"
SetCompressor /SOLID lzma SetCompressor /SOLID lzma
ShowInstDetails show
ShowUnInstDetails show
!include "FileFunc.nsh" ; Setup MultiUser support:
; If launched without ability to elevate, user will not see any extra options.
; If user has ability to elevate, they can choose to install system-wide, with default to CurrentUser.
!define MULTIUSER_EXECUTIONLEVEL Highest
!define MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
!define MULTIUSER_INSTALLMODE_INSTDIR "${PRODUCT_NAME}"
!define MULTIUSER_MUI
!define MULTIUSER_INSTALLMODE_COMMANDLINE
!define MULTIUSER_USE_PROGRAMFILES64
!include "MultiUser.nsh"
; MUI 1.67 compatible ------ !include "MUI2.nsh"
!include "MUI.nsh"
; MUI Settings ; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "Dolphin.ico" !define MUI_ICON "Dolphin.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
; License page ; License page
!insertmacro MUI_PAGE_LICENSE "..\license.txt" !insertmacro MUI_PAGE_LICENSE "..\Data\license.txt"
; Components page ; All/Current user selection page
!insertmacro MUI_PAGE_COMPONENTS !insertmacro MULTIUSER_PAGE_INSTALLMODE
; Directory page ; Directory page
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
; Instfiles page ; Instfiles page
@ -47,25 +62,31 @@ SetCompressor /SOLID lzma
!insertmacro MUI_LANGUAGE "Afrikaans" !insertmacro MUI_LANGUAGE "Afrikaans"
!insertmacro MUI_LANGUAGE "Albanian" !insertmacro MUI_LANGUAGE "Albanian"
!insertmacro MUI_LANGUAGE "Arabic" !insertmacro MUI_LANGUAGE "Arabic"
!insertmacro MUI_LANGUAGE "Armenian"
!insertmacro MUI_LANGUAGE "Asturian"
!insertmacro MUI_LANGUAGE "Basque" !insertmacro MUI_LANGUAGE "Basque"
!insertmacro MUI_LANGUAGE "Belarusian" !insertmacro MUI_LANGUAGE "Belarusian"
!insertmacro MUI_LANGUAGE "Bosnian" !insertmacro MUI_LANGUAGE "Bosnian"
!insertmacro MUI_LANGUAGE "Breton" !insertmacro MUI_LANGUAGE "Breton"
!insertmacro MUI_LANGUAGE "Bulgarian" !insertmacro MUI_LANGUAGE "Bulgarian"
!insertmacro MUI_LANGUAGE "Catalan" !insertmacro MUI_LANGUAGE "Catalan"
!insertmacro MUI_LANGUAGE "Corsican"
!insertmacro MUI_LANGUAGE "Croatian" !insertmacro MUI_LANGUAGE "Croatian"
!insertmacro MUI_LANGUAGE "Czech" !insertmacro MUI_LANGUAGE "Czech"
!insertmacro MUI_LANGUAGE "Danish" !insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "Dutch" !insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Esperanto"
!insertmacro MUI_LANGUAGE "Estonian" !insertmacro MUI_LANGUAGE "Estonian"
!insertmacro MUI_LANGUAGE "Farsi" !insertmacro MUI_LANGUAGE "Farsi"
!insertmacro MUI_LANGUAGE "Finnish" !insertmacro MUI_LANGUAGE "Finnish"
!insertmacro MUI_LANGUAGE "French" !insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Galician" !insertmacro MUI_LANGUAGE "Galician"
!insertmacro MUI_LANGUAGE "Georgian"
!insertmacro MUI_LANGUAGE "German" !insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Greek" !insertmacro MUI_LANGUAGE "Greek"
!insertmacro MUI_LANGUAGE "Hebrew" !insertmacro MUI_LANGUAGE "Hebrew"
!insertmacro MUI_LANGUAGE "Hindi"
!insertmacro MUI_LANGUAGE "Hungarian" !insertmacro MUI_LANGUAGE "Hungarian"
!insertmacro MUI_LANGUAGE "Icelandic" !insertmacro MUI_LANGUAGE "Icelandic"
!insertmacro MUI_LANGUAGE "Indonesian" !insertmacro MUI_LANGUAGE "Indonesian"
@ -82,11 +103,13 @@ SetCompressor /SOLID lzma
!insertmacro MUI_LANGUAGE "Mongolian" !insertmacro MUI_LANGUAGE "Mongolian"
!insertmacro MUI_LANGUAGE "Norwegian" !insertmacro MUI_LANGUAGE "Norwegian"
!insertmacro MUI_LANGUAGE "NorwegianNynorsk" !insertmacro MUI_LANGUAGE "NorwegianNynorsk"
!insertmacro MUI_LANGUAGE "Pashto"
!insertmacro MUI_LANGUAGE "Polish" !insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Portuguese" !insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "PortugueseBR" !insertmacro MUI_LANGUAGE "PortugueseBR"
!insertmacro MUI_LANGUAGE "Romanian" !insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_LANGUAGE "Russian" !insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "ScotsGaelic"
!insertmacro MUI_LANGUAGE "Serbian" !insertmacro MUI_LANGUAGE "Serbian"
!insertmacro MUI_LANGUAGE "SerbianLatin" !insertmacro MUI_LANGUAGE "SerbianLatin"
!insertmacro MUI_LANGUAGE "SimpChinese" !insertmacro MUI_LANGUAGE "SimpChinese"
@ -95,114 +118,129 @@ SetCompressor /SOLID lzma
!insertmacro MUI_LANGUAGE "Spanish" !insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "SpanishInternational" !insertmacro MUI_LANGUAGE "SpanishInternational"
!insertmacro MUI_LANGUAGE "Swedish" !insertmacro MUI_LANGUAGE "Swedish"
!insertmacro MUI_LANGUAGE "Tatar"
!insertmacro MUI_LANGUAGE "Thai" !insertmacro MUI_LANGUAGE "Thai"
!insertmacro MUI_LANGUAGE "TradChinese" !insertmacro MUI_LANGUAGE "TradChinese"
!insertmacro MUI_LANGUAGE "Turkish" !insertmacro MUI_LANGUAGE "Turkish"
!insertmacro MUI_LANGUAGE "Ukrainian" !insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "Uzbek" !insertmacro MUI_LANGUAGE "Uzbek"
!insertmacro MUI_LANGUAGE "Vietnamese"
!insertmacro MUI_LANGUAGE "Welsh" !insertmacro MUI_LANGUAGE "Welsh"
; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; MUI end ------ ; MUI end ------
Name "${PRODUCT_NAME}" !include "WinVer.nsh"
!define UN_NAME "Uninstall $(^Name)" ; Declare the installer itself as win10/win11 compatible, so WinVer.nsh works correctly.
OutFile "dolphin-${DOLPHIN_ARCH}-${PRODUCT_VERSION}.exe" ManifestSupportedOS {8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}
InstallDir "${BASE_INSTALL_DIR}\$(^Name)"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Function .onInit Function .onInit
!insertmacro MULTIUSER_INIT
; Keep in sync with build_info.txt
!define MIN_WIN10_VERSION 1703
${IfNot} ${AtLeastwin10}
${OrIfNot} ${AtLeastWaaS} ${MIN_WIN10_VERSION}
MessageBox MB_OK "At least Windows 10 version ${MIN_WIN10_VERSION} is required."
Abort
${EndIf}
!insertmacro MUI_LANGDLL_DISPLAY !insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd FunctionEnd
Section "Base" SEC01 Function un.onInit
!insertmacro MULTIUSER_UNINIT
FunctionEnd
Var DisplayName
!macro UPDATE_DISPLAYNAME
${If} $MultiUser.InstallMode == "CurrentUser"
StrCpy $DisplayName "$(^Name) (User)"
${Else}
StrCpy $DisplayName "$(^Name)"
${EndIf}
!macroend
Section "Base"
SectionIn RO SectionIn RO
SetShellVarContext all
; Dolphin exe and dlls
; TODO: Make a nice subsection-ized display
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
SetOverwrite ifnewer
; Only delete what we put there; all $INSTDIR\User is left as is ; Clean up some old files possibly leftover from previous installs
Delete "$INSTDIR\uninst.exe" ; We only need to care about files which would cause problems if they were to
Delete "$INSTDIR\license.txt" ; be unexpectedly dynamically picked up by the incoming install.
Delete "$INSTDIR\*.dll" ; Note NSIS will happily install the same thing even if already installed.
Delete "$INSTDIR\Dolphin.exe"
Delete "$INSTDIR\DSPTool.exe"
Delete "$INSTDIR\cpack_package_description.txt"
Delete "$INSTDIR\qt.conf"
RMDir /r "$INSTDIR\Sys" RMDir /r "$INSTDIR\Sys"
RMDir /r "$INSTDIR\Languages" RMDir /r "$INSTDIR\Languages"
File "${BASE_DIR}\Dolphin.exe" ; The binplaced build output will be included verbatim.
File "${BASE_DIR}\license.txt" File /r "${BINARY_SOURCE_DIR}\*"
File "${BASE_DIR}\*.dll"
File "${BASE_DIR}\DSPTool.exe"
File "${BASE_DIR}\Updater.exe"
File "${BASE_DIR}\qt.conf"
File /r "${BASE_DIR}\QtPlugins"
File /r "${BASE_DIR}\Languages"
File /r "${BASE_DIR}\Sys"
!insertmacro UPDATE_DISPLAYNAME
; Create start menu and desktop shortcuts
; This needs to be done after Dolphin.exe is copied ; This needs to be done after Dolphin.exe is copied
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}" CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\Dolphin.exe" CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\$DisplayName.lnk" "$INSTDIR\Dolphin.exe"
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\Dolphin.exe" CreateShortCut "$DESKTOP\$DisplayName.lnk" "$INSTDIR\Dolphin.exe"
; ??
SetOutPath "$TEMP" SetOutPath "$TEMP"
SetOverwrite on
SectionEnd SectionEnd
Section -AdditionalIcons Section -AdditionalIcons
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${UN_NAME}.lnk" "$INSTDIR\uninst.exe" ; Create start menu shortcut for the uninstaller
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall $DisplayName.lnk" "$INSTDIR\uninst.exe" "/$MultiUser.InstallMode"
SectionEnd SectionEnd
!include "FileFunc.nsh"
Section -Post Section -Post
WriteUninstaller "$INSTDIR\uninst.exe" WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\Dolphin.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\Dolphin.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\Dolphin.exe" ; Write metadata for add/remove programs applet
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "$DisplayName"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe /$MultiUser.InstallMode"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\Dolphin.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR" WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR"
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0 IntFmt $0 "0x%08X" $0
WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "EstimatedSize" "$0" WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "EstimatedSize" "$0"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Comments" "GameCube and Wii emulator" WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Comments" "GameCube and Wii emulator"
SectionEnd SectionEnd
; Section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Installs all files required to run the Dolphin Emulator."
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Section Uninstall Section Uninstall
SetShellVarContext all !insertmacro UPDATE_DISPLAYNAME
; Only uninstall what we put there; all $INSTDIR\User is left as is
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\license.txt"
Delete "$INSTDIR\*.dll"
Delete "$INSTDIR\Dolphin.exe"
Delete "$INSTDIR\qt.conf"
Delete "$INSTDIR\DSPTool.exe"
Delete "$INSTDIR\Updater.exe"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\${UN_NAME}.lnk" Delete "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall $DisplayName.lnk"
Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"
Delete "$DESKTOP\$DisplayName.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\$DisplayName.lnk"
RMDir "$SMPROGRAMS\${PRODUCT_NAME}" RMDir "$SMPROGRAMS\${PRODUCT_NAME}"
; Be a bit careful to not delete files a user may have put into the install directory.
Delete "$INSTDIR\*.dll"
Delete "$INSTDIR\build_info.txt"
Delete "$INSTDIR\Dolphin.exe"
Delete "$INSTDIR\DolphinTool.exe"
Delete "$INSTDIR\DSPTool.exe"
Delete "$INSTDIR\license.txt"
Delete "$INSTDIR\qt.conf"
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\Updater.exe"
Delete "$INSTDIR\Updater.log"
RMDir /r "$INSTDIR\Sys" RMDir /r "$INSTDIR\Sys"
RMDir /r "$INSTDIR\Languages" RMDir /r "$INSTDIR\Languages"
RMDir /r "$INSTDIR\QtPlugins" RMDir /r "$INSTDIR\QtPlugins"
RMDir "$INSTDIR" RMDir "$INSTDIR"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
SetAutoClose true SetAutoClose true
SectionEnd SectionEnd

View File

@ -1 +0,0 @@
This package is provided "as is" and without warranty. Any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the authors be liable to any party for any direct, indirect, incidental, special, exemplary, or consequential damages arising in any way out of the use of this package.