From 6796120c3753576acd7f667df3ba8bd4f555e0ac Mon Sep 17 00:00:00 2001 From: "rob_strong%exchangecode.com" Date: Fri, 21 Mar 2008 20:25:15 +0000 Subject: [PATCH] Bug 392150 - Clean the old updates directory on uninstall / in-place upgrade. r=sspitzer, approval1.9b5=mconnor git-svn-id: svn://10.0.0.236/trunk@248373 18797224-902f-48f8-a5cc-f745e15eee43 --- .../installer/windows/nsis/uninstaller.nsi | 12 +- .../mozapps/installer/windows/nsis/common.nsh | 130 +++++++++++++++++- 2 files changed, 135 insertions(+), 7 deletions(-) diff --git a/mozilla/browser/installer/windows/nsis/uninstaller.nsi b/mozilla/browser/installer/windows/nsis/uninstaller.nsi index 109945e3771..8ee1363bab9 100755 --- a/mozilla/browser/installer/windows/nsis/uninstaller.nsi +++ b/mozilla/browser/installer/windows/nsis/uninstaller.nsi @@ -111,6 +111,7 @@ VIAddVersionKey "FileDescription" "${BrandShortName} Helper" !insertmacro un.ChangeMUIHeaderImage !insertmacro un.CheckForFilesInUse +!insertmacro un.CleanUpdatesDir !insertmacro un.CleanVirtualStore !insertmacro un.DeleteRelativeProfiles !insertmacro un.GetLongPath @@ -313,6 +314,13 @@ Section "Uninstall" Delete /REBOOTOK "$INSTDIR\removed-files" ${EndIf} + ; Remove the updates directory for Vista and above + ${un.CleanUpdatesDir} "Mozilla\Firefox" + + ; Remove files that may be left behind by the application in the + ; VirtualStore directory. + ${un.CleanVirtualStore} + ; Parse the uninstall log to unregister dll's and remove all installed ; files / directories this install is responsible for. ${un.ParseUninstallLog} @@ -323,10 +331,6 @@ Section "Uninstall" ; Remove the installation directory if it is empty ${RemoveDir} "$INSTDIR" - ; Remove files that may be left behind by the application in the - ; VirtualStore directory. - ${un.CleanVirtualStore} - ; If firefox.exe was successfully deleted yet we still need to restart to ; remove other files create a dummy firefox.exe.moz-delete to prevent the ; installer from allowing an install without restart when it is required diff --git a/mozilla/toolkit/mozapps/installer/windows/nsis/common.nsh b/mozilla/toolkit/mozapps/installer/windows/nsis/common.nsh index 1535ce72121..db2dc531b99 100755 --- a/mozilla/toolkit/mozapps/installer/windows/nsis/common.nsh +++ b/mozilla/toolkit/mozapps/installer/windows/nsis/common.nsh @@ -3114,10 +3114,20 @@ * If present removes the VirtualStore directory for this installation. Uses the * program files directory path and the current install location to determine * the sub-directory in the VirtualStore directory. + * + * $R7 = stores the value of the open command and the path macros return values + * $R8 = stores the handler's registry key name + * $R9 = _DEFAULT_VALUE and _RESULT */ !macro CleanVirtualStore !ifndef ${_MOZFUNC_UN}CleanVirtualStore + !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN} + !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath + !undef _MOZFUNC_UN + !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP} + !undef _MOZFUNC_UN_TMP + !verbose push !verbose ${_MOZFUNC_VERBOSE} !define ${_MOZFUNC_UN}CleanVirtualStore "!insertmacro ${_MOZFUNC_UN}CleanVirtualStoreCall" @@ -3137,11 +3147,13 @@ StrCmp $R7 "\" +1 start StrCpy $R9 "$INSTDIR" "" $R8 + StrCmp $R8 "" end +1 ClearErrors - GetFullPathName $R8 "$PROGRAMFILES$R9" - IfErrors end - GetFullPathName $R7 "$INSTDIR" + ${${_MOZFUNC_UN}GetLongPath} "$PROGRAMFILES$R9" $R8 + StrCmp $R8 "" end +1 + ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R7 + StrCmp $R7 "" end +1 ; Compare the installation's directory path with the path created by ; concatenating the installation's directory name and the path to the @@ -3195,6 +3207,114 @@ !endif !macroend +/** + * If present removes the updates directory located in the profile's local + * directory for this installation. + * + * @param _REL_PROFILE_PATH + * The relative path to the profile directory from $LOCALAPPDATA. + * + ^ $R6 = stores single characters to find the first "\" from the right of + * $INSTDIR and the long path to $INSTDIR + * $R7 = long path of the concatenation of Program Files and the installation + * directory name (e.g. $PROGRAMFILES$R68) + * $R8 = installation directory name + * $R9 = _REL_PROFILE_PATH + */ +!macro CleanUpdatesDir + + !ifndef ${_MOZFUNC_UN}CleanUpdatesDir + !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN} + !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath + !undef _MOZFUNC_UN + !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP} + !undef _MOZFUNC_UN_TMP + + !verbose push + !verbose ${_MOZFUNC_VERBOSE} + !define ${_MOZFUNC_UN}CleanUpdatesDir "!insertmacro ${_MOZFUNC_UN}CleanUpdatesDirCall" + + Function ${_MOZFUNC_UN}CleanUpdatesDir + Exch $R9 + Push $R8 + Push $R7 + Push $R6 + + StrCmp $R9 "" end +1 ; The path to the app's profiles is required + StrLen $R8 "$INSTDIR" + + ; Get the installation's directory name including the preceding slash + start: + IntOp $R7 $R7 - 1 + IntCmp $R7 -$R8 end end +1 + StrCpy $R6 "$INSTDIR" 1 $R7 + StrCmp $R6 "\" +1 start + + StrCpy $R8 "$INSTDIR" "" $R7 + StrCmp $R8 "" end +1 + + ClearErrors + ${${_MOZFUNC_UN}GetLongPath} "$PROGRAMFILES$R8" $R7 + StrCmp $R7 "" end +1 + ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R6 + StrCmp $R6 "" end +1 + + ; Compare the installation's directory path with the path created by + ; concatenating the installation's directory name and the path to the + ; program files directory. + StrCmp "$R6" "$R7" +1 end + + StrCpy $R6 "$LOCALAPPDATA\$R9$R8" + + ${${_MOZFUNC_UN}GetLongPath} "$R6" $R6 + StrCmp $R6 "" end +1 + IfFileExists "$R6\updates" +1 end + RmDir /r "$R6" + + end: + ClearErrors + + Pop $R6 + Pop $R7 + Pop $R8 + Exch $R9 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro CleanUpdatesDirCall _REL_PROFILE_PATH + !verbose push + !verbose ${_MOZFUNC_VERBOSE} + Push "${_REL_PROFILE_PATH}" + Call CleanUpdatesDir + !verbose pop +!macroend + +!macro un.CleanUpdatesDirCall _REL_PROFILE_PATH + !verbose push + !verbose ${_MOZFUNC_VERBOSE} + Push "${_REL_PROFILE_PATH}" + Call un.CleanUpdatesDir + !verbose pop +!macroend + +!macro un.CleanUpdatesDir + !ifndef un.CleanUpdatesDir + !verbose push + !verbose ${_MOZFUNC_VERBOSE} + !undef _MOZFUNC_UN + !define _MOZFUNC_UN "un." + + !insertmacro CleanUpdatesDir + + !undef _MOZFUNC_UN + !define _MOZFUNC_UN + !verbose pop + !endif +!macroend + /** * Deletes all relative profiles specified in an application's profiles.ini and * performs various other cleanup. @@ -4725,6 +4845,7 @@ !macro InstallStartCleanupCommon !ifndef InstallStartCleanupCommon + !insertmacro CleanUpdatesDir !insertmacro CleanVirtualStore !insertmacro EndUninstallLog !insertmacro ParseRemovedFilesLog @@ -4744,6 +4865,9 @@ Delete "$INSTDIR\updates.xml" Delete "$INSTDIR\active-update.xml" + ; Remove the updates directory for Vista and above + ${CleanUpdatesDir} "Mozilla\Firefox" + RmDir /r "$INSTDIR\distribution" ; Remove files from the uninstall directory.