Split portable/pre-install and full installer into own scripts. Move shared definitions to their own files to reduce code duplication.

Move version check to own file

Split main installer into own script. Integrated changes for portable/standard installation.

Forgot to remove a message box
This commit is contained in:
Christian Kenny 2017-03-13 18:46:15 -04:00 committed by Gregory Hainaut
parent 833622c870
commit b896eed5d4
12 changed files with 484 additions and 527 deletions

View File

@ -1,60 +0,0 @@
Function IsUserAdmin
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
# GetOriginalAccountType will check the tokens of the original user of the
# current thread/process. If the user tokens were elevated or limited for
# this process, GetOriginalAccountType will return the non-restricted
# account type.
# On Vista with UAC, for example, this is not the same value when running
# with `RequestExecutionLevel user`. GetOriginalAccountType will return
# "admin" while GetAccountType will return "user".
UserInfo::GetOriginalAccountType
Pop $2
; Windows9x can sometimes return empty strings...
StrCmp $1 "" 0 +2
Goto Win9x
StrCmp $1 "Admin" 0 +3
DetailPrint '(UAC) User "$0" is in the Administrators group'
Goto done
StrCmp $1 "Power" 0 +3
DetailPrint '(UAC) User "$0" is in the Power Users group'
Goto done
StrCmp $1 "User" 0 +3
DetailPrint '(UAC) User "$0" is just a regular user'
Goto done
StrCmp $1 "Guest" 0 +3
; Guest account? Probably doomed to failure, but might as well try, just in case some shit
; is being mis-reported.
DetailPrint '(UAC) User "$0" is a guest -- this installer is probably going to fail. Good luck.'
Goto done
;MessageBox MB_OK "Unknown error while trying to detect "
DetailPrint "(UAC) Unknown error while trying to detect account type; assuming USER mode."
StrCpy $1 "User"
Goto done
Win9x:
# This one means you don't need to care about admin or
# not admin because Windows 9x doesn't either
MessageBox MB_OK "Error! PCSX2 requires Windows 2000 or newer to install and run!"
Quit
done:
; How to return the admin modeas a variable? NSIS confuses me -- air
;Exch $R0
FunctionEnd

View File

@ -1,60 +0,0 @@
; --- UAC NIGHTMARES ---
; Ideally this would default to 'current' for user-level installs and 'all' for admin-level installs.
; There are problems to be aware of, however!
;
; * If the user is an admin, Windows Vista/7 will DEFAULT to an "all" shell context (installing shortcuts
; for all users), even if we don't want it to (which causes the uninstaller to fail!)
; * If the user is not an admin, setting Shell Context to all will cause the installer to fail because the
; user won't have permission enough to install it at all (sigh).
;
; For now we just require Admin rights to install PCSX2. An ideal solution would be to use our IsUserAdmin
; function to auto-detect and modify nsis installer behavior accordingly.
;
; (note! the SetShellVarContext use in the uninstaller section must match this one!)
SetShellVarContext all
;SetShellVarContext current
SetOutPath "$INSTDIR"
!insertmacro UNINSTALL.LOG_OPEN_INSTALL
File ..\bin\pcsx2.exe
;File /nonfatal ..\bin\pcsx2-dev.exe
; ------------------------------------------
; -- Shared Core Components --
; ------------------------------------------
; (Binaries, shared DLLs, null plugins, game database, languages, etc)
File ..\bin\GameIndex.dbf
File ..\bin\cheats_ws.zip
File ..\bin\PCSX2_keys.ini.default
!insertmacro UNINSTALL.LOG_CLOSE_INSTALL
SetOutPath "$INSTDIR\Docs"
!insertmacro UNINSTALL.LOG_OPEN_INSTALL
File ..\bin\docs\*
!insertmacro UNINSTALL.LOG_CLOSE_INSTALL
SetOutPath "$INSTDIR\Shaders"
!insertmacro UNINSTALL.LOG_OPEN_INSTALL
File ..\bin\shaders\GSdx.fx
File ..\bin\shaders\GSdx_FX_Settings.ini
!insertmacro UNINSTALL.LOG_CLOSE_INSTALL
; ------------------------------------------
; -- Registry Section --
; ------------------------------------------
; Write the installation path into the registry
WriteRegStr HKLM Software\PCSX2 "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "${INSTDIR_REG_KEY}" "DisplayName" "PCSX2 - Playstation 2 Emulator"
WriteRegStr HKLM "${INSTDIR_REG_KEY}" "UninstallString" "${UNINST_EXE}"
WriteRegStr HKLM "${INSTDIR_REG_KEY}" "InstalledVersion" "${APP_VERSION}"
WriteRegDWORD HKLM "${INSTDIR_REG_KEY}" "NoModify" 1
WriteRegDWORD HKLM "${INSTDIR_REG_KEY}" "NoRepair" 1
WriteUninstaller "${UNINST_EXE}"

View File

@ -1,33 +0,0 @@
; -----------------------------------------------------------------------
; Start Menu - Optional section (can be disabled by the user)
Section "Start Menu Shortcuts" SEC_STARTMENU
; CreateShortCut gets the working directory from OutPath
SetOutPath "$INSTDIR"
CreateDirectory "$SMPROGRAMS\PCSX2"
CreateShortCut "$SMPROGRAMS\PCSX2\Uninstall ${APP_NAME}.lnk" "${UNINST_EXE}" "" "${UNINST_EXE}" 0
CreateShortCut "$SMPROGRAMS\PCSX2\${APP_NAME}.lnk" "${APP_EXE}" "" "${APP_EXE}" 0
CreateShortCut "$SMPROGRAMS\PCSX2\Readme.lnk" "$INSTDIR\docs\${PCSX2_README}" \
"" "" 0 "" "" "Typical usage overview and background information for PCSX2."
CreateShortCut "$SMPROGRAMS\PCSX2\Frequently Asked Questions.lnk" "$INSTDIR\docs\${PCSX2_FAQ}" \
"" "" 0 "" "" "Common answers to common problems and inquiries."
;IfFileExists ..\bin\pcsx2-dev.exe 0 +2
; CreateShortCut "PCSX2\pcsx2-dev.lnk" "$INSTDIR\pcsx2-dev.exe" "" "$INSTDIR\pcsx2-dev.exe" 0 "" "" \
; "PCSX2 Devel (has additional logging support)"
SectionEnd
; -----------------------------------------------------------------------
; Desktop Icon - Optional section (can be disabled by the user)
Section "Desktop Shortcut" SEC_DESKTOP
; CreateShortCut gets the working directory from OutPath
SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "${APP_EXE}" "" "${APP_EXE}" 0 "" "" "A Playstation 2 Emulator"
SectionEnd

View File

@ -7,11 +7,6 @@ Function .onInit
;prepare Advanced Uninstall log always within .onInit function
!insertmacro UNINSTALL.LOG_PREPARE_INSTALL
!include WinVer.nsh
${IfNot} ${AtLeastWinVista}
MessageBox MB_OK "Your operating system is unsupported by PCSX2. Please upgrade your operating system or install PCSX2 1.4.0."
Quit
${EndIf}
FunctionEnd
Function .onInstSuccess
@ -36,61 +31,51 @@ Function un.onUninstSuccess
RMDir "$DOCUMENTS\PCSX2"
RMDir "$INSTDIR\langs"
RMDir "$INSTDIR\docs"
; Force remove plugins folder due to Windows 10's wonderful UAC
; Uninstaller has Admin rights, so I guess MS still can't get UAC to behave consistently?
; I've been able to duplicate the bug in older PCSX2 installers - so it's not an NSIS 3.0 issue
; When this behavior occurs; DEV9null and USBnull left in the folder
RMDir /r "$INSTDIR\plugins"
RMDir "$INSTDIR"
FunctionEnd
; =======================================================================
; Un.Installer Sections
; =======================================================================
Section "Un.Program and Plugins ${APP_NAME}"
SetShellVarContext all
; First thing, remove the registry entry in case uninstall doesn't complete successfully
; otherwise, pcsx2 will be "confused" if it's re-installed later.
DeleteRegKey HKLM Software\PCSX2
; Please note that pointing to HKCU here is intentional. It is the only key generated by PCSX2 and *not* NSIS!
; The key stores configuration data used by the First Time Wizard (check AppConfig.cpp for details) such as DocumentsFolderMode, ect.
; Failure to delete this key can result in configuration errors
; This key is generated by PCSX2 and *not* NSIS!
; Failure to delete this key can result in configuration errors after a fresh install.
DeleteRegKey HKCU Software\PCSX2
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR"
; Remove uninstaller info reg key ( Wow6432Node on 64bit Windows! )
DeleteRegKey HKLM "${INSTDIR_REG_KEY}"
; Remove shortcuts, if any
Delete "$DESKTOP\${APP_NAME}.lnk"
RMDir /r "$SMPROGRAMS\PCSX2"
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Langs"
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Plugins"
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Docs"
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Shaders"
; Remove files and registry key that store PCSX2 paths configurations
Delete "$INSTDIR\GameIndex.dbf"
Delete "$INSTDIR\cheats_ws.zip"
Delete "$INSTDIR\PCSX2_keys.ini.default"
Delete "$INSTDIR\pcsx2.exe"
RMDir /r "$INSTDIR\Langs"
RMDir /r "$INSTDIR\Plugins"
RMDir /r "$INSTDIR\Docs"
RMDir /r "$INSTDIR\Shaders"
SetShellVarContext current
Delete $DOCUMENTS\PCSX2\inis\PCSX2_ui.ini
SectionEnd
; /o for optional and unticked by default
Section /o "Un.Configuration files (Programs and Plugins)"
SetShellVarContext current
RMDir /r "$DOCUMENTS\PCSX2\inis\"
SectionEnd
Section /o "Un.Memory cards/savestates"
Section /o "Un.Memory Cards and Savestates"
SetShellVarContext current
RMDir /r "$DOCUMENTS\PCSX2\memcards\"
RMDir /r "$DOCUMENTS\PCSX2\sstates\"
@ -98,13 +83,11 @@ SectionEnd
; /o for optional and unticked by default
Section /o "Un.User files (Cheats, Logs, Snapshots)"
SetShellVarContext current
RMDir /r "$DOCUMENTS\PCSX2\Cheats_ws\"
RMDir /r "$DOCUMENTS\PCSX2\cheats\"
RMDir /r "$DOCUMENTS\PCSX2\logs\"
RMDir /r "$DOCUMENTS\PCSX2\snaps\"
SectionEnd
; /o for optional and unticked by default

View File

@ -0,0 +1,121 @@
; Copyright (C) 2017 Christian Kenny
Function UninstallPrevious
; Here's how StrContains works:
; $result_var: This will store our result if the "needle" is found. Otherwise it will return null ("")
; $needle: String to search for
; $Haystack: String to look in
; Search for 1.0.0
ReadRegStr $R7 HKLM "${INSTDIR_REG_KEY}" "Uninst-pcsx2Directory"
${StrContains} "$4" "1.0.0" "$R7"
StrCmp $4 "" +1
${If} $R7 == ""
${EndIf}
; This will become the primary version check once more stable builds
ReadRegStr $R1 HKLM "${INSTDIR_REG_KEY}" "DisplayVersion"
${If} $R1 == ""
${EndIf}
; Search for 1.4.0
ReadRegStr $R2 HKLM "${INSTDIR_REG_KEY}" "Uninst-pcsx2 1.4.0Directory"
${StrContains} "$2" "1.4.0" "$R2"
StrCmp $2 "" +1
${If} $R2 == ""
${EndIf}
; Search for 1.2.1
ReadRegStr $R3 HKLM "${INSTDIR_REG_KEY}-r5875" "Uninst-pcsx2-r5875Directory"
${StrContains} "$3" "1.2.1" "$R3"
StrCmp $3 "" +1
${If} $R3 == ""
${EndIf}
; Search for 0.9.8
ReadRegStr $R5 HKLM "${INSTDIR_REG_KEY}-r4600" "Uninst-pcsx2-r4600Directory"
${StrContains} "$5" "0.9.8" "$R5"
StrCmp $5 "" +1
${If} $R5 == ""
${EndIf}
; If all cases return null, our work here is done.
;${If} $R1 == ""
${If} $R2 == ""
${AndIf} $R3 == ""
${AndIf} $R5 == ""
${AndIf} $R7 == ""
Goto Done
${EndIf}
; Installing another version
MessageBox MB_ICONEXCLAMATION|MB_OKCANCEL "Another version of PCSX2 is already installed. Please back up your files and click OK to uninstall PCSX2; or Cancel to abort the setup." IDOK true IDCANCEL false
true:
Goto SetUninstPath
false:
Quit
SetUninstPath:
${If} $R7 != ""
${AndIf} $R1 != ""
${OrIf} $4 == "1.0.0"
Goto ExecNormal
${Else}
Goto +1
${EndIf}
${If} $R2 != ""
${AndIf} $2 == "1.4.0"
Goto Exec1.4.0
${Else}
Goto +1
${EndIf}
${If} $R3 != ""
${AndIf} $3 == "1.2.1"
Goto Exec1.2.1
${Else}
Goto +1
${EndIf}
${If} $R5 != ""
${AndIf} $5 == "0.9.8"
Goto Exec0.9.8
${Else}
Goto +1
${EndIf}
ExecNormal:
SetOutPath "$TEMP"
CopyFiles /SILENT /FILESONLY "$R7\Uninst-pcsx2.exe" "$TEMP"
ExecWait '"$TEMP\Uninst-pcsx2.exe" /S _?=$R7'
Delete "$TEMP\Uninst-pcsx2.exe"
Goto Done
Exec1.4.0:
SetOutPath "$TEMP"
CopyFiles /SILENT /FILESONLY "$R2\Uninst-pcsx2 1.4.0.exe" "$TEMP"
ExecWait '"$TEMP\Uninst-pcsx2 1.4.0.exe" /S _?=$R2'
RMDir /r "$DOCUMENTS\PCSX2\inis_1.4.0"
Delete "$TEMP\Uninst-pcsx2 1.4.0.exe"
DeleteRegKey HKLM Software\PCSX2
Goto Done
Exec1.2.1:
SetOutPath "$TEMP"
CopyFiles /SILENT /FILESONLY "$R3\Uninst-pcsx2-r5875.exe" "$TEMP"
ExecWait '"$TEMP\Uninst-pcsx2-r5875.exe" /S _?=$R3'
Delete "$TEMP\Uninst-pcsx2-r5875.exe"
Goto Done
Exec0.9.8:
SetOutPath "$TEMP"
CopyFiles /SILENT /FILESONLY "$R5\Uninst-pcsx2-r4600.exe" "$TEMP"
ExecWait '"$TEMP\Uninst-pcsx2-r4600.exe" /S _?=$R5'
Delete "$TEMP\Uninst-pcsx2-r4600.exe"
Goto Done
Done:
FunctionEnd

View File

@ -1,85 +0,0 @@
; =======================================================================
; Core Includes and Defines
; =======================================================================
!ifndef INC_CORE
!define INC_CORE 1
!endif
!ifndef INC_PLUGINS
; Set to 0 to include the core binaries only (no plugins)
!define INC_PLUGINS 1
!endif
; Notes on Uninstall Log Location (UNINSTALL_LOG)
; The name of the uninstall log determines whether or not future installers
; fall under the same single uninstall entry, or if they use multiple (separate)
; uninstall folders.
!ifndef APP_VERSION
!define APP_VERSION "1.6.0"
!endif
!define APP_NAME "PCSX2 ${APP_VERSION}"
!define APP_FILENAME "pcsx2"
!define UNINSTALL_LOG "Uninst-pcsx2"
!define INSTDIR_REG_ROOT "HKLM"
; LZMA is the best, by far, so let's make sure it's always in use:
; (dictionaries larger than 24MB don't seem to help)
SetCompressor /SOLID lzma
SetCompressorDictSize 24
; The name of the installer
Name "${APP_NAME}"
; Output the installer to the nsis folder (in git repo)
OutFile "pcsx2-${APP_VERSION}-${OUTFILE_POSTFIX}.exe"
; The default installation directory
InstallDir "$PROGRAMFILES\PCSX2 ${APP_VERSION}"
; These defines are dependent on NSIS vars assigned above.
!define APP_EXE "$INSTDIR\${APP_FILENAME}.exe"
!define INSTDIR_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_FILENAME}"
!define PCSX2_README "PCSX2_Readme.pdf"
!define PCSX2_FAQ "PCSX2_FAQ.pdf"
Var DirectXSetupError
; =======================================================================
; Vista/Win7 UAC Stuff
; =======================================================================
; FIXME !!
; Request application privileges for Windows Vista/7; I'd love for this to be sensible about which
; execution level it requests, but UAC is breaking my mind. I included some code for User type
; detection in function IsUserAdmin, but not really using it constructively yet. (see also our
; uses of SetShellVarContext in the installer sections)
;!include "IsUserAdmin.nsi"
; Allow admin-rights PCSX2 users to be hardcore!
AllowRootDirInstall true
; Just require admin for now, until we figure out a nice way to allow for casual user installs.
RequestExecutionLevel admin
; =======================================================================
; MUI2 and Advanced Uninstaller Basics
; =======================================================================
!include "MUI2.nsh"
!include "AdvUninstLog.nsh"
; This defines the Advanced Uninstaller mode of operation...
!insertmacro UNATTENDED_UNINSTALL
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "banner.bmp"
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_ICON "AppIcon.ico"

76
nsis/SharedCore.nsh Normal file
View File

@ -0,0 +1,76 @@
; --- UAC NIGHTMARES ---
; Ideally this would default to 'current' for user-level installs and 'all' for admin-level installs.
; There are problems to be aware of, however!
;
; * If the user is an admin, Windows Vista/7 will DEFAULT to an "all" shell context (installing shortcuts
; for all users), even if we don't want it to (which causes the uninstaller to fail!)
; * If the user is not an admin, setting Shell Context to all will cause the installer to fail because the
; user won't have permission enough to install it at all (sigh).
; (note! the SetShellVarContext use in the uninstaller section must match this one!)
;SetShellVarContext all
;SetShellVarContext current
Section "!${APP_NAME} (required)" SEC_CORE
SectionIn RO
SetOutPath "$INSTDIR"
File ..\bin\pcsx2.exe
File ..\bin\GameIndex.dbf
File ..\bin\cheats_ws.zip
File ..\bin\PCSX2_keys.ini.default
SetOutPath "$INSTDIR\Docs"
File ..\bin\docs\*
SetOutPath "$INSTDIR\Shaders"
File ..\bin\shaders\GSdx.fx
File ..\bin\shaders\GSdx_FX_Settings.ini
SetOutPath "$INSTDIR\Plugins"
File /nonfatal ..\bin\Plugins\gsdx32-sse2.dll
File /nonfatal ..\bin\Plugins\gsdx32-sse4.dll
File /nonfatal ..\bin\Plugins\gsdx32-avx2.dll
File /nonfatal ..\bin\Plugins\spu2-x.dll
File /nonfatal ..\bin\Plugins\cdvdGigaherz.dll
File /nonfatal ..\bin\Plugins\lilypad.dll
File /nonfatal ..\bin\Plugins\USBnull.dll
File /nonfatal ..\bin\Plugins\DEV9null.dll
File /nonfatal ..\bin\Plugins\FWnull.dll
SectionEnd
Section "Additional Languages" SEC_LANGS
SetOutPath $INSTDIR\Langs
File /nonfatal /r ..\bin\Langs\*.mo
SectionEnd
!include "SharedShortcuts.nsh"
SectionGroup "Tools & Utilities" SEC_UTILS
Section "SCP Toolkit" SEC_SCPTK
inetc::get "https://github.com/nefarius/ScpToolkit/releases/download/v1.7.277.16103-BETA/ScpToolkit_Setup.exe" "$TEMP\ScpToolkit_Setup.exe" /END
ExecWait "$TEMP\ScpToolkit_Setup.exe"
Delete "$TEMP\ScpToolkit_Setup.exe"
SectionEnd
SectionGroupEnd
LangString DESC_CORE ${LANG_ENGLISH} "Core components (binaries, plugins, documentation, etc)."
LangString DESC_STARTMENU ${LANG_ENGLISH} "Adds shortcuts for PCSX2 to the start menu (all users)."
LangString DESC_DESKTOP ${LANG_ENGLISH} "Adds a shortcut for PCSX2 to the desktop (all users)."
LangString DESC_LANGS ${LANG_ENGLISH} "Adds additional languages other than the system default to PCSX2."
LangString DESC_SCPTK ${LANG_ENGLISH} "Download and install nefarius's SCPToolkit that allows Dualshock Controllers to be used with Windows."
LangString DESC_UTILS ${LANG_ENGLISH} "Additional utilities that are available for PCSX2 such as legacy plugins and debugging tools."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_UTILS} $(DESC_UTILS)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_SCPTK} $(DESC_SCPTK)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_CORE} $(DESC_CORE)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_STARTMENU} $(DESC_STARTMENU)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_DESKTOP} $(DESC_DESKTOP)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_LANGS} $(DESC_LANGS)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

35
nsis/SharedDefs.nsh Normal file
View File

@ -0,0 +1,35 @@
; Copyright (C) 2017 PCSX2 Team
; These definitions are shared between the 2 installers (pre-install/portable and full)
; This reduces duplicate code throughout both installers.
ManifestDPIAware true
ShowInstDetails show
ShowUninstDetails nevershow
SetCompressor /SOLID lzma
SetCompressorDictSize 24
!ifndef APP_VERSION
!define APP_VERSION "1.6.0"
!endif
!define APP_NAME "PCSX2 ${APP_VERSION}"
; The name of the installer
Name "${APP_NAME}"
!define APP_FILENAME "pcsx2"
!define APP_EXE "$INSTDIR\${APP_FILENAME}.exe"
!define PCSX2_README "PCSX2_Readme.pdf"
!define PCSX2_FAQ "PCSX2_FAQ.pdf"
;===============================
; MUI STUFF
!include "MUI2.nsh"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "banner.bmp"
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_ICON "AppIcon.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\nsis3-uninstall.ico"

13
nsis/SharedShortcuts.nsh Normal file
View File

@ -0,0 +1,13 @@
Section "Start Menu Shortcuts" SEC_STARTMENU
; CreateShortCut gets the working directory from OutPath
SetOutPath "$INSTDIR"
CreateShortCut "$SMPROGRAMS\${APP_NAME}.lnk" "${APP_EXE}" "" "${APP_EXE}" 0
SectionEnd
Section "Desktop Shortcut" SEC_DESKTOP
; CreateShortCut gets the working directory from OutPath
SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "${APP_EXE}" "" "${APP_EXE}" 0 "" "" "A Playstation 2 Emulator"
SectionEnd

View File

@ -1,31 +1,33 @@
; PCSX2 Full/Complete Install Package!
; (a NSIS installer script)
;
; Copyright 2009-2017 PCSX2 Dev Team
;
; Copyright 2009-2017 PCSX2 Dev Team
ManifestDPIAware true
ShowInstDetails nevershow
ShowUninstDetails nevershow
!include "SharedDefs.nsh"
!define OUTFILE_POSTFIX "setup"
!include "SharedBase.nsh"
!include "x64.nsh"
RequestExecutionLevel admin
AllowRootDirInstall true
; Reserve features for improved performance with solid archiving.
; (uncomment if we add our own install options ini files)
;!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
;!insertmacro MUI_RESERVEFILE_LANGDLL
; This is the uninstaller name.
!define UNINSTALL_LOG "Uninst-pcsx2"
!define INSTDIR_REG_ROOT "HKLM"
!define OUTFILE_POSTFIX "include_standard"
; The installer name will read as "pcsx2-x.x.x-include_standard"
OutFile "pcsx2-${APP_VERSION}-${OUTFILE_POSTFIX}.exe"
; The default installation directory for the full installer
InstallDir "$PROGRAMFILES\PCSX2 ${APP_VERSION}"
!define INSTDIR_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_FILENAME}"
!include "AdvUninstLog.nsh"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
; This hack is required to launch pcsx2.exe from the FINISHPAGE of the installer.
; RequestExecutionLevel defaults to admin as of NSIS 3.0; and UAC behavior is defined
; as such that any elevation rights are transferred to child processes
; RequestExecutionLevel is admin for the full install, so we need to avoid transferring the elevated rights to the child process.
!define MUI_FINISHPAGE_RUN "$WINDIR\explorer.exe"
!define MUI_FINISHPAGE_RUN_PARAMETERS "$INSTDIR\pcsx2.exe"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ModifyRunCheckbox
@ -34,258 +36,42 @@ ShowUninstDetails nevershow
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
; This defines the Advanced Uninstaller mode of operation...
!insertmacro UNATTENDED_UNINSTALL
!include "nsDialogs.nsh"
!include "ApplyExeProps.nsh"
!include "StrContains.nsh"
; =======================================================================
; Installer Sections
; =======================================================================
; The "" makes the section hidden.
Section "" SecUninstallPrevious
Call UninstallPrevious
!include "SectionVersionCheck.nsh"
Section ""
Call UninstallPrevious
SectionEnd
Function UninstallPrevious
; Here's how StrContains works:
; $result_var: This will store our result if the "needle" is found. Otherwise it will return null ("")
; $needle: String to search for
; $Haystack: String to look in
; Used for the InstalledVersion string to prevent conflicts with 1.0.0 RegString
ReadRegStr $R7 HKLM "${INSTDIR_REG_KEY}" "Uninst-pcsx2Directory"
${If} $R7 == ""
${EndIf}
; This will become the primary version check once more stable builds
ReadRegStr $R1 HKLM "${INSTDIR_REG_KEY}" "InstalledVersion"
${If} $R1 == ""
${EndIf}
; Search for 1.0.0
ReadRegStr $R4 HKLM "${INSTDIR_REG_KEY}" "Uninst-pcsx2Directory"
${StrContains} "$4" "1.0.0" "$R4"
StrCmp $4 "" +1
${If} $R4 == ""
${EndIf}
; Search for 1.4.0
ReadRegStr $R2 HKLM "${INSTDIR_REG_KEY}" "Uninst-pcsx2 1.4.0Directory"
${StrContains} "$2" "1.4.0" "$R2"
StrCmp $2 "" +1
${If} $R2 == ""
${EndIf}
; Search for 1.2.1
ReadRegStr $R3 HKLM "${INSTDIR_REG_KEY}-r5875" "Uninst-pcsx2-r5875Directory"
${StrContains} "$3" "1.2.1" "$R3"
StrCmp $3 "" +1
${If} $R3 == ""
${EndIf}
; Search for 0.9.8
ReadRegStr $R5 HKLM "${INSTDIR_REG_KEY}-r4600" "Uninst-pcsx2-r4600Directory"
${StrContains} "$5" "0.9.8" "$R5"
StrCmp $5 "" +1
${If} $R5 == ""
${EndIf}
; If all cases return null, our work here is done.
${If} $R1 == ""
${AndIf} $R2 == ""
${AndIf} $R3 == ""
${AndIf} $R4 == ""
${AndIf} $R5 == ""
${AndIf} $R7 == ""
Goto Done
${EndIf}
; Installing another version
MessageBox MB_ICONEXCLAMATION|MB_OKCANCEL "Another version of PCSX2 is already installed. Please back up your files and click OK to uninstall PCSX2; or Cancel to abort the setup." IDOK true IDCANCEL false
true:
Goto SetUninstPath
false:
Quit
SetUninstPath:
${If} $R7 != ""
${AndIf} $R1 != ""
Goto ExecNormal
${Else}
Goto +1
${EndIf}
${If} $R4 != ""
${AndIf} $4 == "1.0.0"
Goto Exec1.0.0
${Else}
Goto +1
${EndIf}
${If} $R2 != ""
${AndIf} $2 == "1.4.0"
Goto Exec1.4.0
${Else}
Goto +1
${EndIf}
${If} $R3 != ""
${AndIf} $3 == "1.2.1"
Goto Exec1.2.1
${Else}
Goto +1
${EndIf}
${If} $R5 != ""
${AndIf} $5 == "0.9.8"
Goto Exec0.9.8
${Else}
Goto +1
${EndIf}
;Run the uninstaller silently.
Exec1.4.0:
SetOutPath "$TEMP"
CopyFiles /SILENT /FILESONLY "$R2\Uninst-pcsx2 1.4.0.exe" "$TEMP"
ExecWait '"$TEMP\Uninst-pcsx2 1.4.0.exe" /S _?=$R2'
Delete "$TEMP\Uninst-pcsx2 1.4.0.exe"
Goto Done
Exec1.2.1: ;GOOD
SetOutPath "$TEMP"
CopyFiles /SILENT /FILESONLY "$R3\Uninst-pcsx2-r5875.exe" "$TEMP"
ExecWait '"$TEMP\Uninst-pcsx2-r5875.exe" /S _?=$R3'
Delete "$TEMP\Uninst-pcsx2-r5875.exe"
Goto Done
Exec1.0.0:
SetOutPath "$TEMP"
CopyFiles /SILENT /FILESONLY "$R4\Uninst-pcsx2.exe" "$TEMP"
ExecWait '"$TEMP\Uninst-pcsx2.exe" /S _?=$R4'
Delete "$TEMP\Uninst-pcsx2.exe"
Goto Done
Exec0.9.8:
SetOutPath "$TEMP"
CopyFiles /SILENT /FILESONLY "$R5\Uninst-pcsx2-r4600.exe" "$TEMP"
ExecWait '"$TEMP\Uninst-pcsx2-r4600.exe" /S _?=$R5'
Delete "$TEMP\Uninst-pcsx2-r4600.exe"
Goto Done
ExecNormal:
SetOutPath "$TEMP"
CopyFiles /SILENT /FILESONLY "$R7\Uninst-pcsx2.exe" "$TEMP"
ExecWait '"$TEMP\Uninst-pcsx2.exe" /S _?=$R7'
Delete "$TEMP\Uninst-pcsx2.exe"
Done:
FunctionEnd
; Basic section (emulation proper)
Section "!${APP_NAME} (required)" SEC_CORE
SectionIn RO
!include "SectionCoreReqs.nsh"
; ------------------------------------------
; -- Plugins Section --
; ------------------------------------------
!if ${INC_PLUGINS} > 0
SetOutPath "$INSTDIR\Plugins"
!insertmacro UNINSTALL.LOG_OPEN_INSTALL
File /nonfatal ..\bin\Plugins\gsdx32-sse2.dll
File /nonfatal ..\bin\Plugins\gsdx32-sse4.dll
File /nonfatal ..\bin\Plugins\gsdx32-avx2.dll
File /nonfatal ..\bin\Plugins\spu2-x.dll
File /nonfatal ..\bin\Plugins\cdvdGigaherz.dll
File /nonfatal ..\bin\Plugins\lilypad.dll
File /nonfatal ..\bin\Plugins\padPokopom.dll
File /nonfatal ..\bin\Plugins\USBnull.dll
File /nonfatal ..\bin\Plugins\DEV9null.dll
File /nonfatal ..\bin\Plugins\FWnull.dll
!insertmacro UNINSTALL.LOG_CLOSE_INSTALL
!endif
SectionEnd
!include "SectionShortcuts.nsh"
Section "Additional Languages" SEC_LANGS
SetOutPath $INSTDIR\Langs
!insertmacro UNINSTALL.LOG_OPEN_INSTALL
File /nonfatal /r ..\bin\Langs\*.mo
!insertmacro UNINSTALL.LOG_CLOSE_INSTALL
SectionEnd
Section "" SEC_DXRedists
!include WinVer.nsh
${IfNot} ${AtLeastWin8.1}
Goto InstallRedist
${ElseIf} ${AtLeastWin8.1}
Goto SkipDx
${EndIf}
InstallRedist:
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
ReadRegDword $R0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
${If} $R0 == "1"
Goto done
${Else}
Goto +2
${EndIf}
SetOutPath "$TEMP"
File "vcredist_2015_Update_1_x86.exe"
ExecWait '"$TEMP\vcredist_2015_Update_1_x86.exe" /qb'
DetailPrint "Finished Visual C++ 2015 Redistributable Setup"
Delete "$TEMP\vcredist_2015_Update_1_x86.exe"
done:
;DirectX Web Setup
SetOutPath "$TEMP"
File "dxwebsetup.exe"
DetailPrint "Running DirectX Web Setup..."
ExecWait '"$TEMP\dxwebsetup.exe" /Q' $DirectXSetupError
DetailPrint "Finished DirectX Web Setup"
Delete "$TEMP\dxwebsetup.exe"
SkipDX:
SectionEnd
!include "SharedCore.nsh"
!include "SectionUninstaller.nsh"
LangString DESC_CORE ${LANG_ENGLISH} "Core components (binaries, plugins, documentation, etc)."
LangString DESC_STARTMENU ${LANG_ENGLISH} "Adds shortcuts for PCSX2 to the start menu (all users)."
LangString DESC_DESKTOP ${LANG_ENGLISH} "Adds a shortcut for PCSX2 to the desktop (all users)."
LangString DESC_LANGS ${LANG_ENGLISH} "Adds additional languages other than the system default to PCSX2."
Section ""
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_CORE} $(DESC_CORE)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_STARTMENU} $(DESC_STARTMENU)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_DESKTOP} $(DESC_DESKTOP)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_LANGS} $(DESC_LANGS)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
; Write the installation path into the registry
WriteRegStr HKLM Software\PCSX2 "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "${INSTDIR_REG_KEY}" "DisplayName" "PCSX2 - Playstation 2 Emulator"
WriteRegStr HKLM "${INSTDIR_REG_KEY}" "Publisher" "PCSX2 Team"
WriteRegStr HKLM "${INSTDIR_REG_KEY}" "DisplayIcon" "$INSTDIR\pcsx2.exe"
WriteRegStr HKLM "${INSTDIR_REG_KEY}" "DisplayVersion" "${APP_VERSION}"
${GetSize} "$INSTDIR" "/S=0K" $6 $7 $8
IntFmt $6 "0x%08X" $6
WriteRegDWORD HKLM "${INSTDIR_REG_KEY}" "EstimatedSize" "$6"
WriteRegStr HKLM "${INSTDIR_REG_KEY}" "UninstallString" "${UNINST_EXE}"
WriteRegDWORD HKLM "${INSTDIR_REG_KEY}" "NoModify" 1
WriteRegDWORD HKLM "${INSTDIR_REG_KEY}" "NoRepair" 1
WriteUninstaller "${UNINST_EXE}"
SectionEnd
Section "" SID_PCSX2
SectionEnd
Function ModifyRunCheckbox
@ -293,4 +79,4 @@ ${IfNot} ${SectionIsSelected} ${SID_PCSX2}
SendMessage $MUI.FINISHPAGE.RUN ${BM_SETCHECK} ${BST_UNCHECKED} 0
EnableWindow $MUI.FINISHPAGE.RUN 0
${EndIf}
FunctionEnd
FunctionEnd

181
nsis/pcsx2_shared_init.nsi Normal file
View File

@ -0,0 +1,181 @@
; PCSX2 Pre-Installer Script
; Copyright (C) 2017 Christian Kenny
; Copyright (C) 2017 PCSX2 Team
!include "SharedDefs.nsh"
RequestExecutionLevel user
!define OUTFILE_POSTFIX "setup"
OutFile "pcsx2-${APP_VERSION}-${OUTFILE_POSTFIX}.exe"
Var UserPrivileges
Var IsAdmin
Var DirectXSetupError
; Dialog Vars
Var InstallMode_Dialog
Var InstallMode_DlgNext
Var InstallMode_Label
Var InstallMode_Full
Var InstallMode_Portable
!include "nsDialogs.nsh"
Page Custom IsUserAdmin
Page Custom CheckDirectX
Page Custom InstallMode InstallModeLeave
Function IsUserAdmin
!include WinVer.nsh
${IfNot} ${AtLeastWinVista}
MessageBox MB_OK "Your operating system is unsupported by PCSX2. Please upgrade your operating system or install PCSX2 1.4.0."
Quit
${EndIf}
ClearErrors
UserInfo::GetName
Pop $R8
UserInfo::GetOriginalAccountType
Pop $UserPrivileges
;UserInfo::GetOriginalAccountType
;Pop $2
;MessageBox MB_OK "$2"
;${EndIf}
# GetOriginalAccountType will check the tokens of the original user of the
# current thread/process. If the user tokens were elevated or limited for
# this process, GetOriginalAccountType will return the non-restricted
# account type.
# On Vista with UAC, for example, this is not the same value when running
# with `RequestExecutionLevel user`. GetOriginalAccountType will return
# "admin" while GetAccountType will return "user".
;UserInfo::GetOriginalAccountType
;Pop $R2
${If} $UserPrivileges == "Admin"
StrCpy $IsAdmin 1
${ElseIf} $UserPrivileges == "User"
StrCpy $IsAdmin 0
${EndIf}
FunctionEnd
Function CheckDirectX
!include WinVer.nsh
!include "X64.nsh"
${If} ${AtLeastWin8.1}
${OrIf} $IsAdmin == 0
Goto SkipDx
${EndIf}
${If} ${RunningX64}
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
${Else}
ReadRegDword $R0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
${EndIf}
Pop $R0
${If} $R0 == "1"
Goto ExecDxSetup
${EndIf}
inetc::get "https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe" "$TEMP\vcredist_2015_Update_1_x86.exe" /END
ExecWait "$TEMP\vcredist_2015_Update_1_x86.exe"
Delete "$TEMP\vcredist_2015_Update_1_x86.exe"
ExecDxSetup:
inetc::get "https://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe" "$TEMP\dxwebsetup.exe" /END
ExecWait '"$TEMP\dxwebsetup.exe" /Q' $DirectXSetupError
Delete "$TEMP\dxwebsetup.exe"
SkipDX:
FunctionEnd
Function InstallMode
nsDialogs::Create /NOUNLOAD 1018
Pop $InstallMode_Dialog
GetDlgItem $InstallMode_DlgNext $HWNDPARENT 1
EnableWindow $InstallMode_DlgNext 0
${NSD_CreateLabel} 0 0 100% 10u "Select an installation mode for PCSX2."
Pop $InstallMode_Label
${NSD_CreateRadioButton} 10 35 100% 10u "Full Installation"
Pop $InstallMode_Full
${If} $IsAdmin == 0
EnableWindow $InstallMode_Full 0
${EndIf}
${NSD_OnClick} $InstallMode_Full InstallMode_UsrWait
${NSD_CreateLabel} 26 55 100% 20u " PCSX2 will be installed in Program Files; unless another directory is specified. In addition, User files are stored in the Documents/PCSX2 directory"
${NSD_CreateRadioButton} 10 95 100% 10u "Portable Installation"
Pop $InstallMode_Portable
${NSD_OnClick} $InstallMode_Portable InstallMode_UsrWait
${NSD_CreateLabel} 26 115 100% 20u "Install PCSX2 to whatever directory you want. Choose this option if you prefer to have all of your files in the same folder or frequently update PCSX2 through Orphis' Buildbot."
nsDialogs::Show
FunctionEnd
Function InstallMode_UsrWait
GetDlgItem $InstallMode_DlgNext $HWNDPARENT 1
EnableWindow $InstallMode_DlgNext 1
FunctionEnd
Function InstallModeLeave
${NSD_GetState} $InstallMode_Full $0
${NSD_GetState} $InstallMode_Portable $1
${If} ${BST_CHECKED} == $0
SetOutPath "$TEMP"
File "pcsx2-${APP_VERSION}-include_standard.exe"
ExecShell open "$TEMP\pcsx2-${APP_VERSION}-include_standard.exe"
Quit
${Else}
Goto +2
${EndIf}
FunctionEnd
; ----------------------------------
; Portable Install Section
; ----------------------------------
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\pcsx2.exe"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ModifyRunCheckbox
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
!include "ApplyExeProps.nsh"
; The default installation directory for the portable binary.
InstallDir "$DOCUMENTS\$R8\PCSX2${APP_VERSION}"
; Installed files are housed here
!include "SharedCore.nsh"
Section "" INST_PORTABLE
SetOutPath "$INSTDIR"
File portable.ini
SectionEnd
Section "" SID_PCSX2
SectionEnd
Function ModifyRunCheckbox
${IfNot} ${SectionIsSelected} ${SID_PCSX2}
SendMessage $MUI.FINISHPAGE.RUN ${BM_SETCHECK} ${BST_UNCHECKED} 0
EnableWindow $MUI.FINISHPAGE.RUN 0
${EndIf}
FunctionEnd

0
nsis/portable.ini Normal file
View File