Bug 797157 - Trying to pave-over install with the stub installer with nightly already running - warning comes up that nightly is already running, but installer closes and leaves behind 'to_be_deleted' folder in C:\Program Files\Nightly. r=bbondy

This commit is contained in:
Robert Strong 2012-10-05 13:56:58 -07:00
parent 297525d538
commit 55c8f6f09f
6 changed files with 119 additions and 20 deletions

View File

@ -76,8 +76,6 @@ VIAddVersionKey "ProductVersion" "${AppVersion}"
# Comments is not used but left below commented out for future reference
# VIAddVersionKey "Comments" "Comments"
!define TO_BE_DELETED "to_be_deleted"
# It isn't possible to get the size of the installation prior to downloading
# so the stub installer uses an estimate.
!define APPROXIMATE_REQUIRED_SPACE_MB "42.2"

View File

@ -222,6 +222,8 @@ Section "-Application" APP_IDX
DetailPrint $(STATUS_INSTALL_APP)
SetDetailsPrint none
RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
${LogHeader} "Installing Main Files"
${CopyFilesFromDir} "$EXEDIR\core" "$INSTDIR" \
"$(ERROR_CREATE_DIRECTORY_PREFIX)" \

View File

@ -94,6 +94,8 @@
${RemoveDeprecatedFiles}
RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
!ifdef MOZ_MAINTENANCE_SERVICE
Call IsUserAdmin
Pop $R0

View File

@ -63,6 +63,7 @@ Var SpaceAvailableBytes
Var InitialInstallDir
Var HandleDownload
Var CanSetAsDefault
Var TmpVal
Var HEIGHT_PX
Var CTL_RIGHT_PX
@ -105,6 +106,7 @@ Var CTL_RIGHT_PX
!insertmacro GetSingleInstallPath
!insertmacro GetTextWidthHeight
!insertmacro IsUserAdmin
!insertmacro OnStubInstallUninstall
!insertmacro SetBrandNameVars
!insertmacro UnloadUAC
@ -923,21 +925,7 @@ Function OnDownload
WriteIniStr "$0" "TASKBAR" "Migrated" "true"
${EndIf}
${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
; Move files that are check in shared.nsh for in use out of the way
; so installing silently will just succeed.
CreateDirectory "$INSTDIR\${TO_BE_DELETED}"
Rename "$INSTDIR\${FileMainEXE}" "$INSTDIR\${TO_BE_DELETED}\${FileMainEXE}"
Rename "$INSTDIR\updater.exe" "$INSTDIR\${TO_BE_DELETED}\updater.exe"
Rename "$INSTDIR\crashreporter.exe" "$INSTDIR\${TO_BE_DELETED}\crashreporter.exe"
Rename "$INSTDIR\xpcom.dll" "$INSTDIR\${TO_BE_DELETED}\xpcom.dll"
Rename "$INSTDIR\mozsqlite3.dll" "$INSTDIR\${TO_BE_DELETED}\mozsqlite3.dll"
Rename "$INSTDIR\nssdbm3.dll" "$INSTDIR\${TO_BE_DELETED}\nssdbm3.dll"
Rename "$INSTDIR\nspr4.dll" "$INSTDIR\${TO_BE_DELETED}\nspr4.dll"
Rename "$INSTDIR\nssckbi.dll" "$INSTDIR\${TO_BE_DELETED}\nssckbi.dll"
Rename "$INSTDIR\freebl3.dll" "$INSTDIR\${TO_BE_DELETED}\freebl3.dll"
Rename "$INSTDIR\AccessibleMarshal.dll" "$INSTDIR\${TO_BE_DELETED}\AccessibleMarshal.dll"
${EndIf}
${OnStubInstallUninstall}
Exec "$\"$PLUGINSDIR\download.exe$\" /INI=$PLUGINSDIR\${CONFIG_INI}"
; Close the handle that prevents modification of the full installer
@ -972,9 +960,6 @@ Function StartInstall
Delete "$INSTDIR\uninstall\uninstall.tmp"
Delete "$PLUGINSDIR\download.exe"
Delete "$PLUGINSDIR\${CONFIG_INI}"
${If} ${FileExists} "$INSTDIR\${TO_BE_DELETED}"
RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
${EndIf}
${If} "$CheckboxSetAsDefault" == "1"
${GetParameters} $0

View File

@ -414,6 +414,8 @@ Section "Uninstall"
RmDir "$INSTDIR\webapprt\components"
RmDir "$INSTDIR\webapprt"
RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
; Remove the installation directory if it is empty
${RemoveDir} "$INSTDIR"

View File

@ -81,6 +81,7 @@
!include overrides.nsh
!define SHORTCUTS_LOG "shortcuts_log.ini"
!define TO_BE_DELETED "to_be_deleted"
################################################################################
@ -4139,6 +4140,115 @@
!verbose pop
!macroend
/**
* Parses the uninstall.log for the stub installer on install to first remove a
* previous installation's files prior to installing.
*
* When modifying this macro be aware that LineFind uses all registers except
* $R0-$R3 so be cautious. Callers of this macro are not affected.
*/
!macro OnStubInstallUninstall
!ifndef OnStubInstallUninstall
!insertmacro GetParent
!insertmacro LineFind
!insertmacro TrimNewLines
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!define OnStubInstallUninstall "!insertmacro OnStubInstallUninstallCall"
Function OnStubInstallUninstall
Push $R9
Push $R8
Push $R7
Push $R6
Push $R5
Push $R4
Push $R3
Push $R2
Push $R1
Push $R0
Push $TmpVal
IfFileExists "$INSTDIR\uninstall\uninstall.log" +1 end
; Copy the uninstall log file to a temporary file
GetTempFileName $TmpVal
CopyFiles /SILENT /FILESONLY "$INSTDIR\uninstall\uninstall.log" "$TmpVal"
CreateDirectory "$INSTDIR\${TO_BE_DELETED}"
; Delete files
${LineFind} "$TmpVal" "/NUL" "1:-1" "StubRemoveFilesCallback"
; Delete the temporary uninstall log file
Delete /REBOOTOK "$TmpVal"
RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
end:
ClearErrors
Pop $TmpVal
Pop $R0
Pop $R1
Pop $R2
Pop $R3
Pop $R4
Pop $R5
Pop $R6
Pop $R7
Pop $R8
Pop $R9
FunctionEnd
Function StubRemoveFilesCallback
${TrimNewLines} "$R9" $R9
StrCpy $R1 "$R9" 5 ; Copy the first five chars
StrCmp "$R1" "File:" +1 end
StrCpy $R9 "$R9" "" 6 ; Copy string starting after the 6th char
StrCpy $R0 "$R9" 1 ; Copy the first char
StrCmp "$R0" "\" +1 end ; If this isn't a relative path goto end
StrCmp "$R9" "\MapiProxy_InUse.dll" end +1 ; Skip the MapiProxy_InUse.dll
StrCmp "$R9" "\mozMapi32_InUse.dll" end +1 ; Skip the mozMapi32_InUse.dll
StrCpy $R1 "$INSTDIR$R9" ; Copy the install dir path and suffix it with the string
IfFileExists "$R1" +1 end
ClearErrors
Delete "$R1"
${Unless} ${Errors}
Goto end
${EndUnless}
GetTempFileName $R2 "$INSTDIR\${TO_BE_DELETED}"
Delete "$R2"
ClearErrors
Rename "$R1" "$R2"
${If} ${Errors}
Delete /REBOOTOK "$R1"
${EndUnless}
end:
ClearErrors
Push 0
FunctionEnd
!verbose pop
!endif
!macroend
!macro OnStubInstallUninstallCall
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Call OnStubInstallUninstall
!verbose pop
!macroend
/**
* Parses the uninstall.log to unregister dll's, remove files, and remove
* empty directories for this installation.