aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Bal
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-03-16 15:20:15 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-03-16 20:14:37 -0500
commit8c9ca787bee29f969cd7ca9aeaa46626d557d196 (patch)
tree8a7278a4035b584e1f1585e3215766af3ca0a62b /src/ext/Bal
parentc1694843f7c54c7f9feb3f7074a31ff8499c9644 (diff)
downloadwix-8c9ca787bee29f969cd7ca9aeaa46626d557d196.tar.gz
wix-8c9ca787bee29f969cd7ca9aeaa46626d557d196.tar.bz2
wix-8c9ca787bee29f969cd7ca9aeaa46626d557d196.zip
Add WixBundleCommandLineAction, don't set dynamic variables at startup.
Fixes 6736
Diffstat (limited to 'src/ext/Bal')
-rw-r--r--src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp103
1 files changed, 58 insertions, 45 deletions
diff --git a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
index 2a5d839a..84e32867 100644
--- a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
+++ b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
@@ -242,6 +242,60 @@ public: // IBootstrapperApplication
242 return hr; 242 return hr;
243 } 243 }
244 244
245 virtual STDMETHODIMP OnDetectBegin(
246 __in BOOL fCached,
247 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType,
248 __in DWORD cPackages,
249 __inout BOOL* pfCancel
250 )
251 {
252 HRESULT hr = S_OK;
253 BOOL fInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == registrationType;
254
255 if (m_fPrereq)
256 {
257 // Pre-req BA should only show help or do an install (to launch the Managed BA which can then do the right action).
258 if (BOOTSTRAPPER_ACTION_HELP != m_command.action)
259 {
260 m_command.action = BOOTSTRAPPER_ACTION_INSTALL;
261 }
262 }
263 else // maybe modify the action state if the bundle is or is not already installed.
264 {
265 if (fInstalled && BOOTSTRAPPER_RESUME_TYPE_REBOOT != m_command.resumeType && BOOTSTRAPPER_ACTION_INSTALL == m_command.action)
266 {
267 m_command.action = BOOTSTRAPPER_ACTION_MODIFY;
268 }
269 else if (!fInstalled && (BOOTSTRAPPER_ACTION_MODIFY == m_command.action || BOOTSTRAPPER_ACTION_REPAIR == m_command.action))
270 {
271 m_command.action = BOOTSTRAPPER_ACTION_INSTALL;
272 }
273 }
274
275 // When resuming from restart doing some install-like operation, try to find the package that forced the
276 // restart. We'll use this information during planning.
277 if (BOOTSTRAPPER_RESUME_TYPE_REBOOT == m_command.resumeType && BOOTSTRAPPER_ACTION_UNINSTALL < m_command.action)
278 {
279 // Ensure the forced restart package variable is null when it is an empty string.
280 hr = BalGetStringVariable(L"WixBundleForcedRestartPackage", &m_sczAfterForcedRestartPackage);
281 if (FAILED(hr) || !m_sczAfterForcedRestartPackage || !*m_sczAfterForcedRestartPackage)
282 {
283 ReleaseNullStr(m_sczAfterForcedRestartPackage);
284 }
285
286 hr = S_OK;
287 }
288
289 // If the UI should be visible, display it now and hide the splash screen
290 if (BOOTSTRAPPER_DISPLAY_NONE < m_command.display)
291 {
292 ::ShowWindow(m_pTheme->hwndParent, SW_SHOW);
293 }
294
295 m_pEngine->CloseSplashScreen();
296
297 return __super::OnDetectBegin(fCached, registrationType, cPackages, pfCancel);
298 }
245 299
246 virtual STDMETHODIMP OnDetectRelatedBundle( 300 virtual STDMETHODIMP OnDetectRelatedBundle(
247 __in LPCWSTR wzBundleId, 301 __in LPCWSTR wzBundleId,
@@ -2123,7 +2177,6 @@ public: //CBalBaseBootstrapperApplication
2123 ) 2177 )
2124 { 2178 {
2125 HRESULT hr = S_OK; 2179 HRESULT hr = S_OK;
2126 LONGLONG llInstalled = 0;
2127 2180
2128 hr = __super::Initialize(pCreateArgs); 2181 hr = __super::Initialize(pCreateArgs);
2129 BalExitOnFailure(hr, "CBalBaseBootstrapperApplication initialization failed."); 2182 BalExitOnFailure(hr, "CBalBaseBootstrapperApplication initialization failed.");
@@ -2132,39 +2185,6 @@ public: //CBalBaseBootstrapperApplication
2132 memcpy_s(&m_createArgs, sizeof(m_createArgs), pCreateArgs, sizeof(BOOTSTRAPPER_CREATE_ARGS)); 2185 memcpy_s(&m_createArgs, sizeof(m_createArgs), pCreateArgs, sizeof(BOOTSTRAPPER_CREATE_ARGS));
2133 m_createArgs.pCommand = &m_command; 2186 m_createArgs.pCommand = &m_command;
2134 2187
2135 if (m_fPrereq)
2136 {
2137 // Pre-req BA should only show help or do an install (to launch the Managed BA which can then do the right action).
2138 if (BOOTSTRAPPER_ACTION_HELP != m_command.action)
2139 {
2140 m_command.action = BOOTSTRAPPER_ACTION_INSTALL;
2141 }
2142 }
2143 else // maybe modify the action state if the bundle is or is not already installed.
2144 {
2145 hr = BalGetNumericVariable(L"WixBundleInstalled", &llInstalled);
2146 if (SUCCEEDED(hr) && BOOTSTRAPPER_RESUME_TYPE_REBOOT != m_command.resumeType && llInstalled && BOOTSTRAPPER_ACTION_INSTALL == m_command.action)
2147 {
2148 m_command.action = BOOTSTRAPPER_ACTION_MODIFY;
2149 }
2150 else if (!llInstalled && (BOOTSTRAPPER_ACTION_MODIFY == m_command.action || BOOTSTRAPPER_ACTION_REPAIR == m_command.action))
2151 {
2152 m_command.action = BOOTSTRAPPER_ACTION_INSTALL;
2153 }
2154 }
2155
2156 // When resuming from restart doing some install-like operation, try to find the package that forced the
2157 // restart. We'll use this information during planning.
2158 if (BOOTSTRAPPER_RESUME_TYPE_REBOOT == m_command.resumeType && BOOTSTRAPPER_ACTION_UNINSTALL < m_command.action)
2159 {
2160 // Ensure the forced restart package variable is null when it is an empty string.
2161 hr = BalGetStringVariable(L"WixBundleForcedRestartPackage", &m_sczAfterForcedRestartPackage);
2162 if (FAILED(hr) || !m_sczAfterForcedRestartPackage || !*m_sczAfterForcedRestartPackage)
2163 {
2164 ReleaseNullStr(m_sczAfterForcedRestartPackage);
2165 }
2166 }
2167
2168 hr = BalGetStringVariable(L"WixBundleVersion", &m_sczBundleVersion); 2188 hr = BalGetStringVariable(L"WixBundleVersion", &m_sczBundleVersion);
2169 BalExitOnFailure(hr, "CWixStandardBootstrapperApplication initialization failed."); 2189 BalExitOnFailure(hr, "CWixStandardBootstrapperApplication initialization failed.");
2170 2190
@@ -2320,7 +2340,7 @@ private:
2320 BalExitOnFailure(hr, "Failed to read bootstrapper application data."); 2340 BalExitOnFailure(hr, "Failed to read bootstrapper application data.");
2321 } 2341 }
2322 2342
2323 if (BOOTSTRAPPER_ACTION_CACHE == m_plannedAction) 2343 if (m_fRequestedCacheOnly)
2324 { 2344 {
2325 if (m_fSupportCacheOnly) 2345 if (m_fSupportCacheOnly)
2326 { 2346 {
@@ -2335,7 +2355,6 @@ private:
2335 else 2355 else
2336 { 2356 {
2337 BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Ignoring attempt to only cache a bundle that does not explicitly support it."); 2357 BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Ignoring attempt to only cache a bundle that does not explicitly support it.");
2338 m_plannedAction = BOOTSTRAPPER_ACTION_UNKNOWN;
2339 } 2358 }
2340 } 2359 }
2341 2360
@@ -2385,7 +2404,7 @@ private:
2385 } 2404 }
2386 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"cache", -1)) 2405 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"cache", -1))
2387 { 2406 {
2388 m_plannedAction = BOOTSTRAPPER_ACTION_CACHE; 2407 m_fRequestedCacheOnly = TRUE;
2389 } 2408 }
2390 else 2409 else
2391 { 2410 {
@@ -3227,14 +3246,6 @@ private:
3227 3246
3228 SetState(WIXSTDBA_STATE_DETECTING, hr); 3247 SetState(WIXSTDBA_STATE_DETECTING, hr);
3229 3248
3230 // If the UI should be visible, display it now and hide the splash screen
3231 if (BOOTSTRAPPER_DISPLAY_NONE < m_command.display)
3232 {
3233 ::ShowWindow(m_pTheme->hwndParent, SW_SHOW);
3234 }
3235
3236 m_pEngine->CloseSplashScreen();
3237
3238 // Tell the core we're ready for the packages to be processed now. 3249 // Tell the core we're ready for the packages to be processed now.
3239 hr = m_pEngine->Detect(); 3250 hr = m_pEngine->Detect();
3240 BalExitOnFailure(hr, "Failed to start detecting chain."); 3251 BalExitOnFailure(hr, "Failed to start detecting chain.");
@@ -4232,6 +4243,7 @@ public:
4232 m_fSuppressDowngradeFailure = FALSE; 4243 m_fSuppressDowngradeFailure = FALSE;
4233 m_fSuppressRepair = FALSE; 4244 m_fSuppressRepair = FALSE;
4234 m_fSupportCacheOnly = FALSE; 4245 m_fSupportCacheOnly = FALSE;
4246 m_fRequestedCacheOnly = FALSE;
4235 4247
4236 m_pTaskbarList = NULL; 4248 m_pTaskbarList = NULL;
4237 m_uTaskbarButtonCreatedMessage = UINT_MAX; 4249 m_uTaskbarButtonCreatedMessage = UINT_MAX;
@@ -4536,6 +4548,7 @@ private:
4536 BOOL m_fSuppressDowngradeFailure; 4548 BOOL m_fSuppressDowngradeFailure;
4537 BOOL m_fSuppressRepair; 4549 BOOL m_fSuppressRepair;
4538 BOOL m_fSupportCacheOnly; 4550 BOOL m_fSupportCacheOnly;
4551 BOOL m_fRequestedCacheOnly;
4539 4552
4540 BOOL m_fPrereq; 4553 BOOL m_fPrereq;
4541 BOOL m_fPrereqInstalled; 4554 BOOL m_fPrereqInstalled;