Skip to content

Commit

Permalink
[NSIS installer] Better handling of possible "reboot needed" situation
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Jul 19, 2020
1 parent c797e6b commit 4c1543d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/CI_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ jobs:
New-Item -ItemType Directory -Force -Path "${{ github.workspace }}\output\installer"
New-Item -ItemType Directory -Force -Path "${{ github.workspace }}\output\debugsymbols"
New-Item -ItemType Directory -Force -Path "${{ github.workspace }}\output\archive"
New-Item -ItemType Directory -Force -Path "${{ github.workspace }}\output\error_logs"
- name: Build vcpkg + dependencies
working-directory: '${{ github.workspace }}\build'
run: |
Expand Down Expand Up @@ -330,6 +331,20 @@ jobs:
Move-Item -LiteralPath ".\build\warzone2100_portable.exe" -Destination ".\output\portable\warzone2100_$($env:WZ_BUILD_DESC)_portable.exe"
# Package the portable .pdb and .sym files into a "DEBUGSYMBOLS" .7z archive (do not include metadata / timestamps)
cmd /c 7z a -t7z -m0=lzma -mx=9 -mtc=off -mtm=off -mta=off ".\output\debugsymbols\warzone2100_$($env:WZ_BUILD_DESC)_portable.DEBUGSYMBOLS.7z" "$($pwd)\build\src\*.pdb" "$($pwd)\build\src\*.sym"
- name: Collect Failure Logs
if: failure()
run: |
$NSIS_Log = "build\_CPack_Packages\win32\NSIS\NSISOutput.log"
if (Test-Path $NSIS_Log -PathType Leaf)
{
Copy-Item -LiteralPath "$NSIS_Log" -Destination ".\output\error_logs"
}
- name: Upload Failure Logs Artifact
uses: actions/upload-artifact@v1
if: failure()
with:
name: win_${{ matrix.architecture }}_error_logs
path: '${{ github.workspace }}\output\error_logs'
- name: CMake Configure (Regular Installer)
working-directory: '${{ github.workspace }}\build'
run: |
Expand Down
34 changes: 31 additions & 3 deletions pkg/nsis/NSIS.template.in
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ ${EndIf}
Var MSVCRT16_x64_NotPresent
Var MSVCRT16_ARM64_NotPresent
Var Result_MSVCDownload
Var MSVCRT16_NeedsReboot

!ifndef PORTABLE
; Provide option to download and install missing / outdated system libraries
Expand All @@ -417,7 +418,11 @@ ${EndIf}
${If} $Result_MSVCDownload == "OK"
; Download succeeded
DetailPrint "vc_redist.x86.exe ..."
ExecWait '"$PLUGINSDIR\vc_redist.x86.exe" /q'
ExecWait '"$PLUGINSDIR\vc_redist.x86.exe" /q /norestart' $0
${If} $0 <> 0
StrCpy $MSVCRT16_NeedsReboot 1
${EndIf}
DetailPrint "vc_redist.x86.exe returned: $0"
${Else}
MessageBox MB_OK|MB_ICONSTOP "Download of system library (x86) failed: $Result_MSVCDownload"
${EndIf}
Expand All @@ -428,7 +433,11 @@ ${EndIf}
${If} $Result_MSVCDownload == "OK"
; Download succeeded
DetailPrint "vc_redist.x64.exe ..."
ExecWait '"$PLUGINSDIR\vc_redist.x64.exe" /q'
ExecWait '"$PLUGINSDIR\vc_redist.x64.exe" /q /norestart' $0
${If} $0 <> 0
StrCpy $MSVCRT16_NeedsReboot 1
${EndIf}
DetailPrint "vc_redist.x64.exe returned: $0"
${Else}
MessageBox MB_OK|MB_ICONSTOP "Download of system library (x64) failed: $Result_MSVCDownload"
${EndIf}
Expand All @@ -439,7 +448,11 @@ ${EndIf}
${If} $Result_MSVCDownload == "OK"
; Download succeeded
DetailPrint "VC_redist.arm64.exe ..."
ExecWait '"$PLUGINSDIR\VC_redist.arm64.exe" /q'
ExecWait '"$PLUGINSDIR\VC_redist.arm64.exe" /q /norestart' $0
${If} $0 <> 0
StrCpy $MSVCRT16_NeedsReboot 1
${EndIf}
DetailPrint "VC_redist.arm64.exe returned: $0"
${Else}
MessageBox MB_OK|MB_ICONSTOP "Download of system library (ARM64) failed: $Result_MSVCDownload"
${EndIf}
Expand Down Expand Up @@ -559,6 +572,7 @@ Function .onInit
StrCpy $MSVCRT16_x86_NotPresent 0
StrCpy $MSVCRT16_x64_NotPresent 0
StrCpy $MSVCRT16_ARM64_NotPresent 0
StrCpy $MSVCRT16_NeedsReboot 0

!ifndef PORTABLE

Expand Down Expand Up @@ -654,6 +668,20 @@ ${EndIf}
FunctionEnd
!endif

Function .onInstSuccess
!ifdef MSVCRUNTIME
${If} $MSVCRT16_NeedsReboot <> 0
; Needs a reboot
MessageBox MB_YESNO|MB_ICONQUESTION "A reboot is needed to finish the installation. Do you wish to reboot the system now?" IDNO NoReboot
Reboot
NoReboot:
${EndIf}
!endif
FunctionEnd

Function .onRebootFailed
MessageBox MB_OK|MB_ICONSTOP "Reboot failed. Please reboot manually." /SD IDOK
FunctionEnd

;--------------------------------
;Descriptions
Expand Down

0 comments on commit 4c1543d

Please sign in to comment.