Skip to content

Commit

Permalink
Bug 1316136 - Support post-signing/attribution data in full installer…
Browse files Browse the repository at this point in the history
…. r=mhowell

This reuses some logic from the stub installer, moved into common.nsh.

Differential Revision: https://phabricator.services.mozilla.com/D72078
  • Loading branch information
agashlin committed Apr 23, 2020
1 parent 9faab64 commit 4b27205
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 12 deletions.
29 changes: 29 additions & 0 deletions browser/installer/windows/nsis/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Var FinishPhaseStart
Var FinishPhaseEnd
Var InstallResult
Var LaunchedNewApp
Var PostSigningData

; By defining NO_STARTMENU_DIR an installer that doesn't provide an option for
; an application's Start Menu PROGRAMS directory and doesn't define the
Expand Down Expand Up @@ -98,6 +99,7 @@ VIAddVersionKey "OriginalFilename" "setup.exe"
!insertmacro CheckForFilesInUse
!insertmacro CleanUpdateDirectories
!insertmacro CopyFilesFromDir
!insertmacro CopyPostSigningData
!insertmacro CreateRegKey
!insertmacro GetFirstInstallPath
!insertmacro GetLongPath
Expand Down Expand Up @@ -742,6 +744,23 @@ Section "-InstallEndCleanup"
DetailPrint "$(STATUS_CLEANUP)"
SetDetailsPrint none

; Maybe copy the post-signing data?
StrCpy $PostSigningData ""
${GetParameters} $0
ClearErrors
; We don't get post-signing data from the MSI.
${GetOptions} $0 "/LaunchedFromMSI" $1
${If} ${Errors}
; The stub will handle copying the data if it ran us.
ClearErrors
${GetOptions} $0 "/LaunchedFromStub" $1
${If} ${Errors}
; We're being run standalone, copy the data.
${CopyPostSigningData}
Pop $PostSigningData
${EndIf}
${EndIf}

${Unless} ${Silent}
ClearErrors
${MUI_INSTALLOPTIONS_READ} $0 "summary.ini" "Field 4" "State"
Expand Down Expand Up @@ -1157,6 +1176,16 @@ Function SendPing
nsJSON::Set /tree ping "Data" "finish_time" /value "$1"
${EndIf}

; $PostSigningData should only be empty if we didn't try to copy the
; postSigningData file at all. If we did try and the file was missing
; or empty, this will be "0", and for consistency with the stub we will
; still submit it.
${If} $PostSigningData != ""
nsJSON::Quote /always $PostSigningData
Pop $0
nsJSON::Set /tree ping "Data" "attribution" /value $0
${EndIf}

nsJSON::Set /tree ping "Data" "new_launched" /value "$LaunchedNewApp"

nsJSON::Set /tree ping "Data" "succeeded" /value false
Expand Down
16 changes: 4 additions & 12 deletions browser/installer/windows/nsis/stub.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ Var ArchToInstall

!include "common.nsh"

!insertmacro CopyPostSigningData
!insertmacro ElevateUAC
!insertmacro GetLongPath
!insertmacro GetPathFromString
Expand Down Expand Up @@ -1287,7 +1288,9 @@ Function FinishInstall

StrCpy $ExitCode "${ERR_SUCCESS}"

Call CopyPostSigningData
${CopyPostSigningData}
Pop $PostSigningData

Call LaunchApp
FunctionEnd

Expand Down Expand Up @@ -1440,17 +1443,6 @@ Function WaitForAppLaunch
${EndIf}
FunctionEnd

Function CopyPostSigningData
${LineRead} "$EXEDIR\postSigningData" "1" $PostSigningData
${If} ${Errors}
ClearErrors
StrCpy $PostSigningData "0"
${Else}
CreateDirectory "$LOCALAPPDATA\Mozilla\Firefox"
CopyFiles /SILENT "$EXEDIR\postSigningData" "$LOCALAPPDATA\Mozilla\Firefox"
${Endif}
FunctionEnd

Function DisplayDownloadError
WebBrowser::CancelTimer $TimerHandle
; To better display the error state on the taskbar set the progress completed
Expand Down
34 changes: 34 additions & 0 deletions toolkit/mozapps/installer/windows/nsis/common.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -7851,6 +7851,40 @@ end:
!endif
!macroend

/**
* Copy the post-signing data, which was left alongside the installer
* by the self-extractor stub, into the global location for this data.
*
* If the post-signing data file doesn't exist, or is empty, "0" is
* pushed on the stack, and nothing is copied.
* Otherwise the first line of the post-signing data (including newline,
* if any) is pushed on the stack.
*/
!macro CopyPostSigningData
!ifndef ${_MOZFUNC_UN}CopyPostSigningData
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!define ${_MOZFUNC_UN}CopyPostSigningData "Call ${_MOZFUNC_UN}CopyPostSigningData"

Function CopyPostSigningData
Push $0 ; Stack: old $0

${LineRead} "$EXEDIR\postSigningData" "1" $0
${If} ${Errors}
ClearErrors
StrCpy $0 "0"
${Else}
CreateDirectory "$LOCALAPPDATA\Mozilla\Firefox"
CopyFiles /SILENT "$EXEDIR\postSigningData" "$LOCALAPPDATA\Mozilla\Firefox"
${Endif}

Exch $0 ; Stack: postSigningData
FunctionEnd

!verbose pop
!endif
!macroend

################################################################################
# Helpers for taskbar progress

Expand Down

0 comments on commit 4b27205

Please sign in to comment.