mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 20:49:27 +00:00
Bug 344490 - Implement silent and unattended installation for NSIS installer. r=sspitzer
This commit is contained in:
parent
4acc9c866f
commit
72ad8634a0
@ -73,6 +73,9 @@ CRCCheck on
|
||||
!insertmacro WordFind
|
||||
!insertmacro WordReplace
|
||||
!insertmacro GetSize
|
||||
!insertmacro GetParameters
|
||||
!insertmacro un.GetParameters
|
||||
!insertmacro GetOptions
|
||||
|
||||
; Use the pre-processor where ever possible
|
||||
; Remember that !define's create smaller packages than Var's!
|
||||
@ -230,7 +233,7 @@ Function un.checkIfAppIsLoaded
|
||||
${EndIf}
|
||||
${If} ${Errors}
|
||||
ClearErrors
|
||||
${un.CloseApp} $(WARN_APP_RUNNING_UNINSTALL)
|
||||
${un.CloseApp} "true" $(WARN_APP_RUNNING_UNINSTALL)
|
||||
; Try to delete it again to prevent launching the app while we are
|
||||
; installing.
|
||||
${DeleteFile} "$INSTDIR\${FileMainEXE}"
|
||||
@ -238,41 +241,6 @@ Function un.checkIfAppIsLoaded
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function un.GetParameters
|
||||
Push $R0
|
||||
Push $R1
|
||||
Push $R2
|
||||
Push $R3
|
||||
|
||||
StrCpy $R2 1
|
||||
StrLen $R3 $CMDLINE
|
||||
|
||||
;Check for quote or space
|
||||
StrCpy $R0 $CMDLINE $R2
|
||||
StrCmp $R0 '"' 0 +3
|
||||
StrCpy $R1 '"'
|
||||
Goto loop
|
||||
StrCpy $R1 " "
|
||||
|
||||
loop:
|
||||
IntOp $R2 $R2 + 1
|
||||
StrCpy $R0 $CMDLINE 1 $R2
|
||||
StrCmp $R0 $R1 get
|
||||
StrCmp $R2 $R3 get
|
||||
Goto loop
|
||||
|
||||
get:
|
||||
IntOp $R2 $R2 + 1
|
||||
StrCpy $R0 $CMDLINE 1 $R2
|
||||
StrCmp $R0 " " get
|
||||
StrCpy $R0 $CMDLINE "" $R2
|
||||
|
||||
Pop $R3
|
||||
Pop $R2
|
||||
Pop $R1
|
||||
Exch $R0
|
||||
FunctionEnd
|
||||
|
||||
; Setup the survey controls, functions, etc. except when the application has
|
||||
; defined NO_UNINSTALL_SURVEY
|
||||
!ifndef NO_UNINSTALL_SURVEY
|
||||
@ -399,7 +367,7 @@ Section "-Application" Section1
|
||||
${EndIf}
|
||||
${If} ${Errors}
|
||||
ClearErrors
|
||||
${CloseApp} $(WARN_APP_RUNNING_INSTALL)
|
||||
${CloseApp} "true" $(WARN_APP_RUNNING_INSTALL)
|
||||
; Try to delete it again to prevent launching the app while we are
|
||||
; installing.
|
||||
${DeleteFile} "$INSTDIR\${FileMainEXE}"
|
||||
@ -1193,11 +1161,116 @@ Function preComponents
|
||||
FunctionEnd
|
||||
|
||||
Function LaunchApp
|
||||
${CloseApp} $(WARN_APP_RUNNING_INSTALL)
|
||||
${CloseApp} "true" $(WARN_APP_RUNNING_INSTALL)
|
||||
Exec "$INSTDIR\${FileMainEXE}"
|
||||
FunctionEnd
|
||||
|
||||
Function .onInit
|
||||
${GetParameters} $R0
|
||||
${If} $R0 != ""
|
||||
; Command line argument found
|
||||
${GetOptions} "$R0" "-ms" $R1
|
||||
${If} ${Errors}
|
||||
; Default install type
|
||||
StrCpy $InstallType "1"
|
||||
; Support for specifying an installation configuration file.
|
||||
ClearErrors
|
||||
${GetOptions} "$R0" "/INI=" $R1
|
||||
${Unless} ${Errors}
|
||||
; The configuration file must also exist
|
||||
${If} ${FileExists} "$R1"
|
||||
SetSilent silent
|
||||
ReadINIStr $0 $R1 "Install" "InstallDirectoryName"
|
||||
${If} $0 != ""
|
||||
StrCpy $INSTDIR "$PROGRAMFILES\$0"
|
||||
${Else}
|
||||
ReadINIStr $0 $R1 "Install" "InstallDirectoryPath"
|
||||
${If} $$0 != ""
|
||||
StrCpy $INSTDIR "$0"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
${If} $INSTDIR == ""
|
||||
; Check if there is an existing uninstall registry entry for this
|
||||
; version of the application and if present install into that location
|
||||
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})" "InstallLocation"
|
||||
${If} $0 == ""
|
||||
StrCpy $INSTDIR "$PROGRAMFILES\${BrandFullName}"
|
||||
${Else}
|
||||
GetFullPathName $INSTDIR "$0"
|
||||
${Unless} ${FileExists} "$INSTDIR"
|
||||
StrCpy $INSTDIR "$PROGRAMFILES\${BrandFullName}"
|
||||
${EndUnless}
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
; Quit if we are unable to create the installation directory or we are
|
||||
; unable to write to a file in the installation directory.
|
||||
ClearErrors
|
||||
${If} ${FileExists} "$INSTDIR"
|
||||
GetTempFileName $R2 "$INSTDIR"
|
||||
FileOpen $R3 $R2 w
|
||||
FileWrite $R3 "Write Access Test"
|
||||
FileClose $R3
|
||||
Delete $R2
|
||||
${If} ${Errors}
|
||||
Quit
|
||||
${EndIf}
|
||||
${Else}
|
||||
CreateDirectory "$INSTDIR"
|
||||
${If} ${Errors}
|
||||
Quit
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
ReadINIStr $0 $R1 "Install" "CloseAppNoPrompt"
|
||||
${If} $0 == "true"
|
||||
ClearErrors
|
||||
${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
|
||||
${DeleteFile} "$INSTDIR\${FileMainEXE}"
|
||||
${EndIf}
|
||||
${If} ${Errors}
|
||||
ClearErrors
|
||||
${CloseApp} "false" ""
|
||||
${DeleteFile} "$INSTDIR\${FileMainEXE}"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
ReadINIStr $0 $R1 "Install" "QuickLaunchShortcut"
|
||||
${If} $0 == "false"
|
||||
StrCpy $AddQuickLaunchSC "0"
|
||||
${Else}
|
||||
StrCpy $AddQuickLaunchSC "1"
|
||||
${EndIf}
|
||||
|
||||
ReadINIStr $0 $R1 "Install" "DesktopShortcut"
|
||||
${If} $0 == "false"
|
||||
StrCpy $AddDesktopSC "0"
|
||||
${Else}
|
||||
StrCpy $AddDesktopSC "1"
|
||||
${EndIf}
|
||||
|
||||
ReadINIStr $0 $R1 "Install" "StartMenuShortcuts"
|
||||
${If} $0 == "false"
|
||||
StrCpy $AddStartMenuSC "0"
|
||||
${Else}
|
||||
StrCpy $AddStartMenuSC "1"
|
||||
${EndIf}
|
||||
|
||||
ReadINIStr $0 $R1 "Install" "StartMenuDirectoryName"
|
||||
${If} $0 != ""
|
||||
StrCpy $StartMenuDir "$0"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
${EndUnless}
|
||||
${Else}
|
||||
; Support for the deprecated -ms command line argument. The new command
|
||||
; line arguments are not supported when -ms is used.
|
||||
SetSilent silent
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
ClearErrors
|
||||
|
||||
StrCpy $LANGUAGE 0
|
||||
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "options.ini"
|
||||
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "shortcuts.ini"
|
||||
|
@ -706,8 +706,12 @@ Exch $R9 ; exchange the new $R9 value with the top of the stack
|
||||
* message window's class.
|
||||
* @param _MSG
|
||||
* The message text to display in the message box.
|
||||
* @param _PROMPT
|
||||
* If false don't prompt the user and automatically exit the
|
||||
* application if it is running.
|
||||
*
|
||||
* $R8 = value returned from FindWindow
|
||||
* $R7 = value returned from FindWindow
|
||||
* $R8 = _PROMPT
|
||||
* $R9 = _MSG
|
||||
*/
|
||||
!macro CloseApp
|
||||
@ -719,14 +723,17 @@ Exch $R9 ; exchange the new $R9 value with the top of the stack
|
||||
|
||||
Function ${_MOZFUNC_UN}CloseApp
|
||||
Exch $R9
|
||||
Push $R8
|
||||
Exch 1
|
||||
Exch $R8
|
||||
Push $R7
|
||||
|
||||
loop:
|
||||
FindWindow $R8 "${WindowClass}"
|
||||
IntCmp $R8 0 end
|
||||
FindWindow $R7 "${WindowClass}"
|
||||
IntCmp $R7 0 end
|
||||
StrCmp $R8 "false" +2 0
|
||||
MessageBox MB_OKCANCEL|MB_ICONQUESTION "$R9" IDCANCEL exit 0
|
||||
; Only post this one time.
|
||||
System::Call 'user32::PostMessage(i r18, i ${WM_QUIT}, i 0, i 0)'
|
||||
|
||||
System::Call 'user32::PostMessage(i r17, i ${WM_QUIT}, i 0, i 0)'
|
||||
# The amount of time to wait for the app to shutdown before prompting again
|
||||
Sleep 4000
|
||||
Goto loop
|
||||
@ -736,7 +743,9 @@ Exch $R9 ; exchange the new $R9 value with the top of the stack
|
||||
|
||||
end:
|
||||
|
||||
Pop $R8
|
||||
Pop $R7
|
||||
Exch $R8
|
||||
Exch 1
|
||||
Exch $R9
|
||||
FunctionEnd
|
||||
|
||||
@ -744,10 +753,11 @@ Exch $R9 ; exchange the new $R9 value with the top of the stack
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
!macro CloseAppCall _MSG
|
||||
!macro CloseAppCall _MSG _PROMPT
|
||||
!verbose push
|
||||
!verbose ${_MOZFUNC_VERBOSE}
|
||||
Push "${_MSG}"
|
||||
Push "${_PROMPT}"
|
||||
Call CloseApp
|
||||
!verbose pop
|
||||
!macroend
|
||||
@ -767,10 +777,11 @@ Exch $R9 ; exchange the new $R9 value with the top of the stack
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
!macro un.CloseAppCall _MSG
|
||||
!macro un.CloseAppCall _MSG _PROMPT
|
||||
!verbose push
|
||||
!verbose ${_MOZFUNC_VERBOSE}
|
||||
Push "${_MSG}"
|
||||
Push "${_PROMPT}"
|
||||
Call un.CloseApp
|
||||
!verbose pop
|
||||
!macroend
|
||||
@ -829,7 +840,7 @@ Exch $R9 ; exchange the new $R9 value with the top of the stack
|
||||
Exch 3
|
||||
Exch $R7
|
||||
Exch 2
|
||||
Exch $R7
|
||||
Exch $R8
|
||||
Exch 1
|
||||
Exch $R9
|
||||
FunctionEnd
|
||||
|
Loading…
x
Reference in New Issue
Block a user