From 4c1543dc94d72693a1fcdf368d03f2d65f757daa Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Sat, 18 Jul 2020 20:25:44 -0400 Subject: [PATCH] [NSIS installer] Better handling of possible "reboot needed" situation --- .github/workflows/CI_windows.yml | 15 ++++++++++++++ pkg/nsis/NSIS.template.in | 34 +++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI_windows.yml b/.github/workflows/CI_windows.yml index 7cd648805d8..32c2f81900a 100644 --- a/.github/workflows/CI_windows.yml +++ b/.github/workflows/CI_windows.yml @@ -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: | @@ -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: | diff --git a/pkg/nsis/NSIS.template.in b/pkg/nsis/NSIS.template.in index 1dda91f3ea3..4cbf03a5a8c 100644 --- a/pkg/nsis/NSIS.template.in +++ b/pkg/nsis/NSIS.template.in @@ -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 @@ -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} @@ -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} @@ -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} @@ -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 @@ -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