зеркало из https://github.com/mozilla/pjs.git
Bug 361402 - installer does not automatically find path to existing installation when going from 1.5.0.x to 2.0.0.x. r=sspitzer
This commit is contained in:
Родитель
21257f574d
Коммит
9dbb403912
|
@ -80,6 +80,7 @@ Var fhUninstallLog
|
|||
!insertmacro WordReplace
|
||||
!insertmacro GetSize
|
||||
!insertmacro GetParameters
|
||||
!insertmacro GetParent
|
||||
!insertmacro GetOptions
|
||||
!insertmacro GetRoot
|
||||
!insertmacro DriveSpace
|
||||
|
@ -107,6 +108,7 @@ VIAddVersionKey "FileDescription" "${BrandShortName} Installer"
|
|||
!insertmacro CanWriteToInstallDir
|
||||
!insertmacro CheckDiskSpace
|
||||
!insertmacro AddHandlerValues
|
||||
!insertmacro GetSingleInstallPath
|
||||
|
||||
!include shared.nsh
|
||||
|
||||
|
@ -829,6 +831,17 @@ Function leaveComponents
|
|||
FunctionEnd
|
||||
|
||||
Function preDirectory
|
||||
SetShellVarContext all ; Set SHCTX to HKLM
|
||||
${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
|
||||
${If} $R9 == "false"
|
||||
SetShellVarContext current ; Set SHCTX to HKCU
|
||||
${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
|
||||
${EndIf}
|
||||
|
||||
${Unless} $R9 == "false"
|
||||
StrCpy $INSTDIR "$R9"
|
||||
${EndUnless}
|
||||
|
||||
${If} $InstallType != 4
|
||||
${CheckDiskSpace} $R9
|
||||
${If} $R9 != "false"
|
||||
|
|
|
@ -1612,6 +1612,117 @@ Exch $R9 ; exchange the new $R9 value with the top of the stack
|
|||
!endif
|
||||
!macroend
|
||||
|
||||
/**
|
||||
* Finds an existing installation path of the application based on the
|
||||
* application name so we can default to using this path for the install. If
|
||||
* there is zero or more than one installation for the application then we
|
||||
* default to the normal default path. This uses SHCTX to determine the
|
||||
* registry hive so you must call SetShellVarContext first.
|
||||
*
|
||||
* IMPORTANT! $R9 will be overwritten by this macro with the return value so
|
||||
* protect yourself!
|
||||
*
|
||||
* @param _KEY
|
||||
* The registry subkey (typically this will be Software\Mozilla\App Name).
|
||||
* @return _RESULT
|
||||
* false if a single install location for this app name isn't found,
|
||||
* path to the install directory if a single install location is found.
|
||||
*
|
||||
* $R5 = _KEY
|
||||
* $R6 = value returned from EnumRegKey
|
||||
* $R7 = value returned from ReadRegStr
|
||||
* $R8 = counter for the loop's EnumRegKey
|
||||
* $R9 = _RESULT
|
||||
*/
|
||||
!macro GetSingleInstallPath
|
||||
|
||||
!ifndef ${_MOZFUNC_UN}GetSingleInstallPath
|
||||
!verbose push
|
||||
!verbose ${_MOZFUNC_VERBOSE}
|
||||
!define ${_MOZFUNC_UN}GetSingleInstallPath "!insertmacro ${_MOZFUNC_UN}GetSingleInstallPathCall"
|
||||
|
||||
Function ${_MOZFUNC_UN}GetSingleInstallPath
|
||||
Exch $R5
|
||||
Push $R6
|
||||
Push $R7
|
||||
Push $R8
|
||||
|
||||
StrCpy $R9 "false"
|
||||
StrCpy $R8 0 ; set the counter for the loop to 0
|
||||
|
||||
loop:
|
||||
ClearErrors
|
||||
EnumRegKey $R6 SHCTX $R5 $R8
|
||||
IfErrors cleanup
|
||||
StrCmp $R6 "" cleanup ; if empty there are no more keys to enumerate
|
||||
IntOp $R8 $R8 + 1 ; increment the loop's counter
|
||||
ClearErrors
|
||||
ReadRegStr $R7 SHCTX "$R5\$R6\Main" "PathToExe"
|
||||
IfErrors loop
|
||||
GetFullPathName $R7 "$R7"
|
||||
IfErrors loop
|
||||
|
||||
|
||||
StrCmp "$R9" "false" 0 +3
|
||||
StrCpy $R9 "$R7"
|
||||
GoTo Loop
|
||||
|
||||
StrCpy $R9 "false"
|
||||
|
||||
cleanup:
|
||||
StrCmp $R9 "false" end
|
||||
${${_MOZFUNC_UN}GetParent} "$R9" $R9
|
||||
StrCpy $R8 $R9 "" -1 ; Copy the last char.
|
||||
StrCmp $R8 '\' end ; Is it a \?
|
||||
StrCpy $R9 "$R9\" ; Append \ to the string
|
||||
|
||||
end:
|
||||
ClearErrors
|
||||
|
||||
Pop $R8
|
||||
Pop $R7
|
||||
Pop $R6
|
||||
Exch $R5
|
||||
Push $R9
|
||||
FunctionEnd
|
||||
|
||||
!verbose pop
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
!macro GetSingleInstallPathCall _KEY _RESULT
|
||||
!verbose push
|
||||
!verbose ${_MOZFUNC_VERBOSE}
|
||||
Push "${_KEY}"
|
||||
Call GetSingleInstallPath
|
||||
Pop ${_RESULT}
|
||||
!verbose pop
|
||||
!macroend
|
||||
|
||||
!macro un.GetSingleInstallPathCall _KEY _RESULT
|
||||
!verbose push
|
||||
!verbose ${_MOZFUNC_VERBOSE}
|
||||
Push "${_KEY}"
|
||||
Call un.GetSingleInstallPath
|
||||
Pop ${_RESULT}
|
||||
!verbose pop
|
||||
!macroend
|
||||
|
||||
!macro un.GetSingleInstallPath
|
||||
!ifndef un.GetSingleInstallPath
|
||||
!verbose push
|
||||
!verbose ${_MOZFUNC_VERBOSE}
|
||||
!undef _MOZFUNC_UN
|
||||
!define _MOZFUNC_UN "un."
|
||||
|
||||
!insertmacro GetSingleInstallPath
|
||||
|
||||
!undef _MOZFUNC_UN
|
||||
!define _MOZFUNC_UN
|
||||
!verbose pop
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
/**
|
||||
* Writes common registry values for a handler using SHCTX.
|
||||
* @param _KEY
|
||||
|
|
Загрузка…
Ссылка в новой задаче