Reformat version detection, move null plugins, force remove folder in uninstaller.

Null plugins are sad and lonely, put them with the others later

Minor tweaks, force remove Plugins folder because it can prevent $INSTDIR from being deleted (assuming we're doing a standard uninstall)

Rewrite version detection to search for 0.9.8 to 1.4.0 as well as future builds.

Remove offending whitespace
This commit is contained in:
Christian Kenny 2017-01-18 00:32:54 -05:00 committed by Gregory Hainaut
parent 732dc881e4
commit b51eca87b6
4 changed files with 182 additions and 79 deletions

View File

@ -39,19 +39,10 @@
SetOutPath "$INSTDIR\Shaders" SetOutPath "$INSTDIR\Shaders"
!insertmacro UNINSTALL.LOG_OPEN_INSTALL !insertmacro UNINSTALL.LOG_OPEN_INSTALL
File ..\bin\shaders\* File ..\bin\shaders\GSdx.fx
File ..\bin\shaders\GSdx_FX_Settings.ini
!insertmacro UNINSTALL.LOG_CLOSE_INSTALL !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
SetOutPath "$INSTDIR\Plugins"
!insertmacro UNINSTALL.LOG_OPEN_INSTALL
; NULL plugins are required, because the PCSX2 plugin selector needs a dummy plugin in every slot
; in order to run (including CDVD!)
File ..\bin\Plugins\USBnull.dll
File ..\bin\Plugins\DEV9null.dll
File ..\bin\Plugins\FWnull.dll
!insertmacro UNINSTALL.LOG_CLOSE_INSTALL
; ------------------------------------------ ; ------------------------------------------
; -- Registry Section -- ; -- Registry Section --

View File

@ -25,23 +25,6 @@ FunctionEnd
; Shared Uninstall Functions ; Shared Uninstall Functions
; ======================================================================= ; =======================================================================
Function un.removeShorties
; Remove shortcuts, if any
Delete "$DESKTOP\${APP_NAME}.lnk"
Delete "$SMPROGRAMS\PCSX2\Uninstall ${APP_NAME}.lnk"
Delete "$SMPROGRAMS\PCSX2\${APP_NAME}.lnk"
;Delete "$SMPROGRAMS\PCSX2\pcsx2-dev.lnk"
Delete "$SMPROGRAMS\PCSX2\Readme.lnk"
Delete "$SMPROGRAMS\PCSX2\Frequently Asked Questions.lnk"
RMDir "$SMPROGRAMS\PCSX2"
FunctionEnd
; begin uninstall, could be added on top of uninstall section instead ; begin uninstall, could be added on top of uninstall section instead
Function un.onInit Function un.onInit
!insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL !insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
@ -53,8 +36,13 @@ Function un.onUninstSuccess
RMDir "$DOCUMENTS\PCSX2" RMDir "$DOCUMENTS\PCSX2"
RMDir "$INSTDIR\langs" RMDir "$INSTDIR\langs"
RMDir "$INSTDIR\plugins"
RMDir "$INSTDIR\docs" 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" RMDir "$INSTDIR"
FunctionEnd FunctionEnd
@ -62,8 +50,6 @@ Function un.onUninstSuccess
; Un.Installer Sections ; Un.Installer Sections
; ======================================================================= ; =======================================================================
; -----------------------------------------------------------------------
Section "Un.Program and Plugins ${APP_NAME}" Section "Un.Program and Plugins ${APP_NAME}"
SetShellVarContext all SetShellVarContext all
@ -81,7 +67,9 @@ Section "Un.Program and Plugins ${APP_NAME}"
; Remove uninstaller info reg key ( Wow6432Node on 64bit Windows! ) ; Remove uninstaller info reg key ( Wow6432Node on 64bit Windows! )
DeleteRegKey HKLM "${INSTDIR_REG_KEY}" DeleteRegKey HKLM "${INSTDIR_REG_KEY}"
Call un.removeShorties ; Remove shortcuts, if any
Delete "$DESKTOP\${APP_NAME}.lnk"
RMDir /r "$SMPROGRAMS\PCSX2"
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Langs" !insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Langs"
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Plugins" !insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\Plugins"

48
nsis/StrContains.nsh Normal file
View File

@ -0,0 +1,48 @@
; StrContains
; This function does a case sensitive searches for an occurrence of a substring in a string.
; It returns the substring if it is found.
; Otherwise it returns null("").
; Written by kenglish_hi
; Adapted from StrReplace written by dandaman32
Var STR_HAYSTACK
Var STR_NEEDLE
Var STR_CONTAINS_VAR_1
Var STR_CONTAINS_VAR_2
Var STR_CONTAINS_VAR_3
Var STR_CONTAINS_VAR_4
Var STR_RETURN_VAR
Function StrContains
Exch $STR_NEEDLE
Exch 1
Exch $STR_HAYSTACK
; Uncomment to debug
;MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK '
StrCpy $STR_RETURN_VAR ""
StrCpy $STR_CONTAINS_VAR_1 -1
StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE
StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK
loop:
IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1
StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1
StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found
StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done
Goto loop
found:
StrCpy $STR_RETURN_VAR $STR_NEEDLE
Goto done
done:
Pop $STR_NEEDLE ;Prevent "invalid opcode" errors and keep the
Exch $STR_RETURN_VAR
FunctionEnd
!macro _StrContainsConstructor OUT NEEDLE HAYSTACK
Push `${HAYSTACK}`
Push `${NEEDLE}`
Call StrContains
Pop `${OUT}`
!macroend
!define StrContains '!insertmacro "_StrContainsConstructor"'

View File

@ -2,10 +2,9 @@
; PCSX2 Full/Complete Install Package! ; PCSX2 Full/Complete Install Package!
; (a NSIS installer script) ; (a NSIS installer script)
; ;
; Copyright 2009-2016 PCSX2 Dev Team ; Copyright 2009-2017 PCSX2 Dev Team
; ;
!ifndef INC_CRT_2015 !ifndef INC_CRT_2015
; Set to 0 to disable inclusion of Visual Studio 2013 SP1 CRT Redists ; Set to 0 to disable inclusion of Visual Studio 2013 SP1 CRT Redists
!define INC_CRT_2015 1 !define INC_CRT_2015 1
@ -44,13 +43,11 @@ ShowUninstDetails nevershow
!insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "English"
!include "ApplyExeProps.nsh" !include "ApplyExeProps.nsh"
!include "StrContains.nsh"
; ======================================================================= ; =======================================================================
; Installer Sections ; Installer Sections
; ======================================================================= ; =======================================================================
; -----------------------------------------------------------------------
; The "" makes the section hidden. ; The "" makes the section hidden.
Section "" SecUninstallPrevious Section "" SecUninstallPrevious
@ -59,56 +56,139 @@ Section "" SecUninstallPrevious
SectionEnd SectionEnd
Function UninstallPrevious Function UninstallPrevious
;Check for uninstaller.
ReadRegStr $R0 HKLM "${INSTDIR_REG_KEY}" "UninstallString" ; Here's how StrContains works:
${If} $R0 == "" ; $result_var: This will store our result if the "needle" is found. Otherwise it will return null ("")
Goto Done ; $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} ${EndIf}
;Check if any other version is installed ; This will become the primary version check once more stable builds
ReadRegStr $R1 HKLM "${INSTDIR_REG_KEY}" "InstalledVersion" ReadRegStr $R1 HKLM "${INSTDIR_REG_KEY}" "InstalledVersion"
;This check for older versions (pre 1.6.0) without InstalledVersion string will bypass this section
${If} $R1 == "" ${If} $R1 == ""
DetailPrint "InstalledVersion string not found, skipping version check"
Goto Done
${EndIf} ${EndIf}
;Installing same version ; Search for 1.0.0
${If} $R1 S== ${APP_VERSION} ReadRegStr $R4 HKLM "${INSTDIR_REG_KEY}" "Uninst-pcsx2Directory"
MessageBox MB_ICONEXCLAMATION|MB_OKCANCEL "This version of PCSX2 is already installed. Do you want to continue?" IDCANCEL false ${StrContains} "$4" "1.0.0" "$R4"
DetailPrint "Overwriting current install" StrCmp $4 "" +1
Goto Done ${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: false:
Quit Quit
SetUninstPath:
${If} $R7 != ""
${AndIf} $R1 != ""
Goto ExecNormal
${Else} ${Else}
DetailPrint "Not the same version" Goto +1
${EndIf} ${EndIf}
;Installing newer version (and old version is detected) ${If} $R4 != ""
${If} $R1 S< ${APP_VERSION} ${AndIf} $4 == "1.0.0"
MessageBox MB_ICONEXCLAMATION|MB_OKCANCEL "An older version of PCSX2 is installed. Do you want to uninstall it?" IDOK true2 IDCANCEL false2 Goto Exec1.0.0
true2:
DetailPrint "Uninstalling old PCSX2 version"
Goto Next
false2:
Quit
${Else} ${Else}
DetailPrint "Not installing a new version" 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} ${EndIf}
;Run the uninstaller silently. ;Run the uninstaller silently.
Next: Exec1.4.0:
DetailPrint "Running silent uninstall" 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
;Copy files to a temp dir to prevent conflicts when removing $INSTDIR/uninstaller Exec1.2.1: ;GOOD
ReadRegStr $R2 HKLM Software\PCSX2 "Install_Dir" SetOutPath "$TEMP"
CreateDirectory "$TEMP\pcsx2_uninst_temp" CopyFiles /SILENT /FILESONLY "$R3\Uninst-pcsx2-r5875.exe" "$TEMP"
CopyFiles /SILENT /FILESONLY "$R2\uninst-pcsx2.exe" "$TEMP\pcsx2_uninst_temp" ExecWait '"$TEMP\Uninst-pcsx2-r5875.exe" /S _?=$R3'
Delete "$TEMP\Uninst-pcsx2-r5875.exe"
Goto Done
ExecWait '"$TEMP\pcsx2_uninst_temp\uninst-pcsx2.exe" /S _?=$R2' Exec1.0.0:
RMDir /r $TEMP\pcsx2_uninst_temp SetOutPath "$TEMP"
Done: 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 FunctionEnd
@ -138,6 +218,9 @@ Section "!${APP_NAME} (required)" SEC_CORE
File /nonfatal ..\bin\Plugins\lilypad.dll File /nonfatal ..\bin\Plugins\lilypad.dll
File /nonfatal ..\bin\Plugins\padPokopom.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 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
!endif !endif
@ -223,9 +306,7 @@ LangString DESC_STARTMENU ${LANG_ENGLISH} "Adds shortcuts for PCSX2 to the star
LangString DESC_DESKTOP ${LANG_ENGLISH} "Adds a shortcut for PCSX2 to the desktop (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_LANGS ${LANG_ENGLISH} "Adds additional languages other than the system default to PCSX2."
LangString DESC_DXPACKS ${LANG_ENGLISH} "Installs the Visual C++ Redistributable and DirectX SDK" LangString DESC_DXPACKS ${LANG_ENGLISH} "Installs the Visual C++ Redistributable and DirectX SDK (required for PCSX2)"
LangString DESC_CRT2015 ${LANG_ENGLISH} "Required by the PCSX2 binaries packaged in this installer."
LangString DESC_DIRECTX ${LANG_ENGLISH} "Only uncheck this if you are quite certain your Direct3D runtimes are up to date."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_CORE} $(DESC_CORE) !insertmacro MUI_DESCRIPTION_TEXT ${SEC_CORE} $(DESC_CORE)
@ -233,12 +314,7 @@ LangString DESC_DIRECTX ${LANG_ENGLISH} "Only uncheck this if you are quite c
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_DESKTOP} $(DESC_DESKTOP) !insertmacro MUI_DESCRIPTION_TEXT ${SEC_DESKTOP} $(DESC_DESKTOP)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_LANGS} $(DESC_LANGS) !insertmacro MUI_DESCRIPTION_TEXT ${SEC_LANGS} $(DESC_LANGS)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_DXPACKS} $(DESC_DXPACKS) !insertmacro MUI_DESCRIPTION_TEXT ${SEC_DXPACKS} $(DESC_DXPACKS)
!if ${INC_CRT_2015} > 0
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_CRT2015} $(DESC_CRT2015)
!endif
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_DIRECTX} $(DESC_DIRECTX)
!insertmacro MUI_FUNCTION_DESCRIPTION_END !insertmacro MUI_FUNCTION_DESCRIPTION_END
Section "" SID_PCSX2 Section "" SID_PCSX2