aboutsummaryrefslogtreecommitdiff
path: root/src/api/burn/balutil
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-07-02 10:18:08 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-07-02 12:50:09 -0500
commitf43d176f95601ff7524e06247166d4f3b6e61c05 (patch)
tree2e3580ca60c85e1d07a0ab4a2b1279d25fd41f6c /src/api/burn/balutil
parent9bdf3730cd43e1af8a4ea9be6cf2fba77fcff2d2 (diff)
downloadwix-f43d176f95601ff7524e06247166d4f3b6e61c05.tar.gz
wix-f43d176f95601ff7524e06247166d4f3b6e61c05.tar.bz2
wix-f43d176f95601ff7524e06247166d4f3b6e61c05.zip
Make the BA responsible for parsing restart prompt behavior.
Fixes #4975
Diffstat (limited to 'src/api/burn/balutil')
-rw-r--r--src/api/burn/balutil/balinfo.cpp36
-rw-r--r--src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h28
-rw-r--r--src/api/burn/balutil/inc/balinfo.h12
3 files changed, 63 insertions, 13 deletions
diff --git a/src/api/burn/balutil/balinfo.cpp b/src/api/burn/balutil/balinfo.cpp
index f71784a5..2746f49e 100644
--- a/src/api/burn/balutil/balinfo.cpp
+++ b/src/api/burn/balutil/balinfo.cpp
@@ -19,7 +19,7 @@ static HRESULT ParseOverridableVariablesFromXml(
19 19
20DAPI_(HRESULT) BalInfoParseCommandLine( 20DAPI_(HRESULT) BalInfoParseCommandLine(
21 __in BAL_INFO_COMMAND* pCommand, 21 __in BAL_INFO_COMMAND* pCommand,
22 __in LPCWSTR wzCommandLine 22 __in const BOOTSTRAPPER_COMMAND* pBootstrapperCommand
23 ) 23 )
24{ 24{
25 HRESULT hr = S_OK; 25 HRESULT hr = S_OK;
@@ -29,13 +29,13 @@ DAPI_(HRESULT) BalInfoParseCommandLine(
29 29
30 BalInfoUninitializeCommandLine(pCommand); 30 BalInfoUninitializeCommandLine(pCommand);
31 31
32 if (!wzCommandLine || !*wzCommandLine) 32 if (!pBootstrapperCommand->wzCommandLine || !*pBootstrapperCommand->wzCommandLine)
33 { 33 {
34 ExitFunction(); 34 ExitFunction();
35 } 35 }
36 36
37 hr = AppParseCommandLine(wzCommandLine, &argc, &argv); 37 hr = AppParseCommandLine(pBootstrapperCommand->wzCommandLine, &argc, &argv);
38 ExitOnFailure(hr, "Failed to parse command line."); 38 BalExitOnFailure(hr, "Failed to parse command line.");
39 39
40 for (int i = 0; i < argc; ++i) 40 for (int i = 0; i < argc; ++i)
41 { 41 {
@@ -43,7 +43,24 @@ DAPI_(HRESULT) BalInfoParseCommandLine(
43 43
44 if (argv[i][0] == L'-' || argv[i][0] == L'/') 44 if (argv[i][0] == L'-' || argv[i][0] == L'/')
45 { 45 {
46 fUnknownArg = TRUE; 46 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"norestart", -1))
47 {
48 if (BAL_INFO_RESTART_UNKNOWN == pCommand->restart)
49 {
50 pCommand->restart = BAL_INFO_RESTART_NEVER;
51 }
52 }
53 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"forcerestart", -1))
54 {
55 if (BAL_INFO_RESTART_UNKNOWN == pCommand->restart)
56 {
57 pCommand->restart = BAL_INFO_RESTART_ALWAYS;
58 }
59 }
60 else
61 {
62 fUnknownArg = TRUE;
63 }
47 } 64 }
48 else 65 else
49 { 66 {
@@ -55,10 +72,10 @@ DAPI_(HRESULT) BalInfoParseCommandLine(
55 else 72 else
56 { 73 {
57 hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(&pCommand->rgVariableNames), pCommand->cVariables, 1, sizeof(LPWSTR), 5); 74 hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(&pCommand->rgVariableNames), pCommand->cVariables, 1, sizeof(LPWSTR), 5);
58 ExitOnFailure(hr, "Failed to ensure size for variable names."); 75 BalExitOnFailure(hr, "Failed to ensure size for variable names.");
59 76
60 hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(&pCommand->rgVariableValues), pCommand->cVariables, 1, sizeof(LPWSTR), 5); 77 hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(&pCommand->rgVariableValues), pCommand->cVariables, 1, sizeof(LPWSTR), 5);
61 ExitOnFailure(hr, "Failed to ensure size for variable values."); 78 BalExitOnFailure(hr, "Failed to ensure size for variable values.");
62 79
63 LPWSTR* psczVariableName = pCommand->rgVariableNames + pCommand->cVariables; 80 LPWSTR* psczVariableName = pCommand->rgVariableNames + pCommand->cVariables;
64 LPWSTR* psczVariableValue = pCommand->rgVariableValues + pCommand->cVariables; 81 LPWSTR* psczVariableValue = pCommand->rgVariableValues + pCommand->cVariables;
@@ -86,6 +103,11 @@ DAPI_(HRESULT) BalInfoParseCommandLine(
86 } 103 }
87 104
88LExit: 105LExit:
106 if (BAL_INFO_RESTART_UNKNOWN == pCommand->restart)
107 {
108 pCommand->restart = BOOTSTRAPPER_DISPLAY_FULL > pBootstrapperCommand->display ? BAL_INFO_RESTART_AUTOMATIC : BAL_INFO_RESTART_PROMPT;
109 }
110
89 if (argv) 111 if (argv)
90 { 112 {
91 AppFreeCommandLineArgs(argv); 113 AppFreeCommandLineArgs(argv);
diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h
index 393987ba..53fa369b 100644
--- a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h
+++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h
@@ -9,6 +9,7 @@
9#include "IBootstrapperApplication.h" 9#include "IBootstrapperApplication.h"
10 10
11#include "balutil.h" 11#include "balutil.h"
12#include "balinfo.h"
12#include "balretry.h" 13#include "balretry.h"
13 14
14class CBalBaseBootstrapperApplication : public IBootstrapperApplication 15class CBalBaseBootstrapperApplication : public IBootstrapperApplication
@@ -794,7 +795,7 @@ public: // IBootstrapperApplication
794 { 795 {
795 HRESULT hr = S_OK; 796 HRESULT hr = S_OK;
796 BOOL fRestartRequired = BOOTSTRAPPER_APPLY_RESTART_REQUIRED == restart; 797 BOOL fRestartRequired = BOOTSTRAPPER_APPLY_RESTART_REQUIRED == restart;
797 BOOL fShouldBlockRestart = BOOTSTRAPPER_DISPLAY_FULL <= m_display && BOOTSTRAPPER_RESTART_PROMPT >= m_restart; 798 BOOL fShouldBlockRestart = BOOTSTRAPPER_DISPLAY_FULL <= m_display && BAL_INFO_RESTART_PROMPT >= m_BalInfoCommand.restart;
798 799
799 if (fRestartRequired && !fShouldBlockRestart) 800 if (fRestartRequired && !fShouldBlockRestart)
800 { 801 {
@@ -976,6 +977,22 @@ public: // IBootstrapperApplication
976 return S_OK; 977 return S_OK;
977 } 978 }
978 979
980public: //CBalBaseBootstrapperApplication
981 virtual STDMETHODIMP Initialize(
982 __in const BOOTSTRAPPER_CREATE_ARGS* pCreateArgs
983 )
984 {
985 HRESULT hr = S_OK;
986
987 m_display = pCreateArgs->pCommand->display;
988
989 hr = BalInfoParseCommandLine(&m_BalInfoCommand, pCreateArgs->pCommand);
990 BalExitOnFailure(hr, "Failed to parse command line with balutil.");
991
992 LExit:
993 return hr;
994 }
995
979protected: 996protected:
980 // 997 //
981 // PromptCancel - prompts the user to close (if not forced). 998 // PromptCancel - prompts the user to close (if not forced).
@@ -1029,20 +1046,19 @@ protected:
1029 1046
1030 CBalBaseBootstrapperApplication( 1047 CBalBaseBootstrapperApplication(
1031 __in IBootstrapperEngine* pEngine, 1048 __in IBootstrapperEngine* pEngine,
1032 __in const BOOTSTRAPPER_CREATE_ARGS* pArgs,
1033 __in DWORD dwRetryCount = 0, 1049 __in DWORD dwRetryCount = 0,
1034 __in DWORD dwRetryTimeout = 1000 1050 __in DWORD dwRetryTimeout = 1000
1035 ) 1051 )
1036 { 1052 {
1037 m_cReferences = 1; 1053 m_cReferences = 1;
1038 m_display = pArgs->pCommand->display; 1054 m_display = BOOTSTRAPPER_DISPLAY_UNKNOWN;
1039 m_restart = pArgs->pCommand->restart;
1040 1055
1041 pEngine->AddRef(); 1056 pEngine->AddRef();
1042 m_pEngine = pEngine; 1057 m_pEngine = pEngine;
1043 1058
1044 ::InitializeCriticalSection(&m_csCanceled); 1059 ::InitializeCriticalSection(&m_csCanceled);
1045 m_fCanceled = FALSE; 1060 m_fCanceled = FALSE;
1061 m_BalInfoCommand = { };
1046 m_fApplying = FALSE; 1062 m_fApplying = FALSE;
1047 m_fRollingBack = FALSE; 1063 m_fRollingBack = FALSE;
1048 1064
@@ -1054,6 +1070,7 @@ protected:
1054 1070
1055 virtual ~CBalBaseBootstrapperApplication() 1071 virtual ~CBalBaseBootstrapperApplication()
1056 { 1072 {
1073 BalInfoUninitializeCommandLine(&m_BalInfoCommand);
1057 BalRetryUninitialize(); 1074 BalRetryUninitialize();
1058 ::DeleteCriticalSection(&m_csCanceled); 1075 ::DeleteCriticalSection(&m_csCanceled);
1059 1076
@@ -1064,10 +1081,11 @@ protected:
1064 CRITICAL_SECTION m_csCanceled; 1081 CRITICAL_SECTION m_csCanceled;
1065 BOOL m_fCanceled; 1082 BOOL m_fCanceled;
1066 1083
1084 BAL_INFO_COMMAND m_BalInfoCommand;
1085
1067private: 1086private:
1068 long m_cReferences; 1087 long m_cReferences;
1069 BOOTSTRAPPER_DISPLAY m_display; 1088 BOOTSTRAPPER_DISPLAY m_display;
1070 BOOTSTRAPPER_RESTART m_restart;
1071 IBootstrapperEngine* m_pEngine; 1089 IBootstrapperEngine* m_pEngine;
1072 1090
1073 BOOL m_fApplying; 1091 BOOL m_fApplying;
diff --git a/src/api/burn/balutil/inc/balinfo.h b/src/api/burn/balutil/inc/balinfo.h
index 07a1cbb7..769becb2 100644
--- a/src/api/burn/balutil/inc/balinfo.h
+++ b/src/api/burn/balutil/inc/balinfo.h
@@ -18,6 +18,15 @@ typedef enum BAL_INFO_PACKAGE_TYPE
18 BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH, 18 BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH,
19} BAL_INFO_PACKAGE_TYPE; 19} BAL_INFO_PACKAGE_TYPE;
20 20
21typedef enum _BAL_INFO_RESTART
22{
23 BAL_INFO_RESTART_UNKNOWN,
24 BAL_INFO_RESTART_NEVER,
25 BAL_INFO_RESTART_PROMPT,
26 BAL_INFO_RESTART_AUTOMATIC,
27 BAL_INFO_RESTART_ALWAYS,
28} BAL_INFO_RESTART;
29
21typedef enum _BAL_INFO_VARIABLE_COMMAND_LINE_TYPE 30typedef enum _BAL_INFO_VARIABLE_COMMAND_LINE_TYPE
22{ 31{
23 BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_UPPER_CASE, 32 BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_UPPER_CASE,
@@ -85,6 +94,7 @@ typedef struct _BAL_INFO_COMMAND
85 DWORD cVariables; 94 DWORD cVariables;
86 LPWSTR* rgVariableNames; 95 LPWSTR* rgVariableNames;
87 LPWSTR* rgVariableValues; 96 LPWSTR* rgVariableValues;
97 BAL_INFO_RESTART restart;
88} BAL_INFO_COMMAND; 98} BAL_INFO_COMMAND;
89 99
90 100
@@ -94,7 +104,7 @@ typedef struct _BAL_INFO_COMMAND
94********************************************************************/ 104********************************************************************/
95HRESULT DAPI BalInfoParseCommandLine( 105HRESULT DAPI BalInfoParseCommandLine(
96 __in BAL_INFO_COMMAND* pCommand, 106 __in BAL_INFO_COMMAND* pCommand,
97 __in LPCWSTR wzCommandLine 107 __in const BOOTSTRAPPER_COMMAND* pBootstrapperCommand
98 ); 108 );
99 109
100 110