diff options
Diffstat (limited to 'src/burn/engine/plan.cpp')
-rw-r--r-- | src/burn/engine/plan.cpp | 79 |
1 files changed, 36 insertions, 43 deletions
diff --git a/src/burn/engine/plan.cpp b/src/burn/engine/plan.cpp index 812dcd15..f850d49c 100644 --- a/src/burn/engine/plan.cpp +++ b/src/burn/engine/plan.cpp | |||
@@ -67,7 +67,6 @@ static HRESULT ProcessPackageRollbackBoundary( | |||
67 | ); | 67 | ); |
68 | static HRESULT GetActionDefaultRequestState( | 68 | static HRESULT GetActionDefaultRequestState( |
69 | __in BOOTSTRAPPER_ACTION action, | 69 | __in BOOTSTRAPPER_ACTION action, |
70 | __in BOOL fPermanent, | ||
71 | __in BOOTSTRAPPER_PACKAGE_STATE currentState, | 70 | __in BOOTSTRAPPER_PACKAGE_STATE currentState, |
72 | __out BOOTSTRAPPER_REQUEST_STATE* pRequestState | 71 | __out BOOTSTRAPPER_REQUEST_STATE* pRequestState |
73 | ); | 72 | ); |
@@ -318,7 +317,6 @@ LExit: | |||
318 | extern "C" HRESULT PlanDefaultPackageRequestState( | 317 | extern "C" HRESULT PlanDefaultPackageRequestState( |
319 | __in BURN_PACKAGE_TYPE packageType, | 318 | __in BURN_PACKAGE_TYPE packageType, |
320 | __in BOOTSTRAPPER_PACKAGE_STATE currentState, | 319 | __in BOOTSTRAPPER_PACKAGE_STATE currentState, |
321 | __in BOOL fPermanent, | ||
322 | __in BOOTSTRAPPER_ACTION action, | 320 | __in BOOTSTRAPPER_ACTION action, |
323 | __in BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, | 321 | __in BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, |
324 | __in BOOTSTRAPPER_RELATION_TYPE relationType, | 322 | __in BOOTSTRAPPER_RELATION_TYPE relationType, |
@@ -333,6 +331,20 @@ extern "C" HRESULT PlanDefaultPackageRequestState( | |||
333 | { | 331 | { |
334 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_CACHE; | 332 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_CACHE; |
335 | } | 333 | } |
334 | else if (BOOTSTRAPPER_ACTION_CACHE == action) | ||
335 | { | ||
336 | switch (currentState) | ||
337 | { | ||
338 | case BOOTSTRAPPER_PACKAGE_STATE_PRESENT: __fallthrough; | ||
339 | case BOOTSTRAPPER_PACKAGE_STATE_SUPERSEDED: | ||
340 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT; | ||
341 | break; | ||
342 | |||
343 | default: | ||
344 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_CACHE; | ||
345 | break; | ||
346 | } | ||
347 | } | ||
336 | else if (BOOTSTRAPPER_RELATION_PATCH == relationType && BURN_PACKAGE_TYPE_MSP == packageType) | 348 | else if (BOOTSTRAPPER_RELATION_PATCH == relationType && BURN_PACKAGE_TYPE_MSP == packageType) |
337 | { | 349 | { |
338 | // For patch related bundles, only install a patch if currently absent during install, modify, or repair. | 350 | // For patch related bundles, only install a patch if currently absent during install, modify, or repair. |
@@ -345,33 +357,30 @@ extern "C" HRESULT PlanDefaultPackageRequestState( | |||
345 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; | 357 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; |
346 | } | 358 | } |
347 | } | 359 | } |
348 | else if (BOOTSTRAPPER_PACKAGE_STATE_SUPERSEDED == currentState && BOOTSTRAPPER_ACTION_UNINSTALL != action) | ||
349 | { | ||
350 | // Superseded means the package is on the machine but not active, so only uninstall operations are allowed. | ||
351 | // All other operations do nothing. | ||
352 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; | ||
353 | } | ||
354 | else if (BOOTSTRAPPER_PACKAGE_STATE_OBSOLETE == currentState && !(BOOTSTRAPPER_ACTION_UNINSTALL == action && BURN_PACKAGE_TYPE_MSP == packageType)) | ||
355 | { | ||
356 | // Obsolete means the package is not on the machine and should not be installed, *except* patches can be obsolete | ||
357 | // and present so allow them to be removed during uninstall. Everyone else, gets nothing. | ||
358 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; | ||
359 | } | ||
360 | else // pick the best option for the action state and install condition. | 360 | else // pick the best option for the action state and install condition. |
361 | { | 361 | { |
362 | hr = GetActionDefaultRequestState(action, fPermanent, currentState, &defaultRequestState); | 362 | hr = GetActionDefaultRequestState(action, currentState, &defaultRequestState); |
363 | ExitOnFailure(hr, "Failed to get default request state for action."); | 363 | ExitOnFailure(hr, "Failed to get default request state for action."); |
364 | 364 | ||
365 | // If we're doing an install, use the install condition | 365 | if (BOOTSTRAPPER_ACTION_UNINSTALL != action) |
366 | // to determine whether to use the default request state or make the package absent. | ||
367 | if (BOOTSTRAPPER_ACTION_UNINSTALL != action && BOOTSTRAPPER_PACKAGE_CONDITION_FALSE == installCondition) | ||
368 | { | ||
369 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_ABSENT; | ||
370 | } | ||
371 | else // just set the package to the default request state. | ||
372 | { | 366 | { |
373 | *pRequestState = defaultRequestState; | 367 | // If we're not doing an uninstall, use the install condition |
368 | // to determine whether to use the default request state or make the package absent. | ||
369 | if (BOOTSTRAPPER_PACKAGE_CONDITION_FALSE == installCondition) | ||
370 | { | ||
371 | defaultRequestState = BOOTSTRAPPER_REQUEST_STATE_ABSENT; | ||
372 | } | ||
373 | // Obsolete means the package is not on the machine and should not be installed, | ||
374 | // *except* patches can be obsolete and present. | ||
375 | // Superseded means the package is on the machine but not active, so only uninstall operations are allowed. | ||
376 | // All other operations do nothing. | ||
377 | else if (BOOTSTRAPPER_PACKAGE_STATE_OBSOLETE == currentState || BOOTSTRAPPER_PACKAGE_STATE_SUPERSEDED == currentState) | ||
378 | { | ||
379 | defaultRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT <= defaultRequestState ? BOOTSTRAPPER_REQUEST_STATE_NONE : defaultRequestState; | ||
380 | } | ||
374 | } | 381 | } |
382 | |||
383 | *pRequestState = defaultRequestState; | ||
375 | } | 384 | } |
376 | 385 | ||
377 | LExit: | 386 | LExit: |
@@ -873,7 +882,7 @@ static HRESULT InitializePackage( | |||
873 | } | 882 | } |
874 | 883 | ||
875 | // Remember the default requested state so the engine doesn't get blamed for planning the wrong thing if the BA changes it. | 884 | // Remember the default requested state so the engine doesn't get blamed for planning the wrong thing if the BA changes it. |
876 | hr = PlanDefaultPackageRequestState(pPackage->type, pPackage->currentState, pPackage->fPermanent, pPlan->action, installCondition, relationType, &pPackage->defaultRequested); | 885 | hr = PlanDefaultPackageRequestState(pPackage->type, pPackage->currentState, pPlan->action, installCondition, relationType, &pPackage->defaultRequested); |
877 | ExitOnFailure(hr, "Failed to set default package state."); | 886 | ExitOnFailure(hr, "Failed to set default package state."); |
878 | 887 | ||
879 | pPackage->requested = pPackage->defaultRequested; | 888 | pPackage->requested = pPackage->defaultRequested; |
@@ -1993,7 +2002,6 @@ static void ResetPlannedRollbackBoundaryState( | |||
1993 | 2002 | ||
1994 | static HRESULT GetActionDefaultRequestState( | 2003 | static HRESULT GetActionDefaultRequestState( |
1995 | __in BOOTSTRAPPER_ACTION action, | 2004 | __in BOOTSTRAPPER_ACTION action, |
1996 | __in BOOL fPermanent, | ||
1997 | __in BOOTSTRAPPER_PACKAGE_STATE currentState, | 2005 | __in BOOTSTRAPPER_PACKAGE_STATE currentState, |
1998 | __out BOOTSTRAPPER_REQUEST_STATE* pRequestState | 2006 | __out BOOTSTRAPPER_REQUEST_STATE* pRequestState |
1999 | ) | 2007 | ) |
@@ -2002,22 +2010,7 @@ static HRESULT GetActionDefaultRequestState( | |||
2002 | 2010 | ||
2003 | switch (action) | 2011 | switch (action) |
2004 | { | 2012 | { |
2005 | case BOOTSTRAPPER_ACTION_CACHE: | 2013 | case BOOTSTRAPPER_ACTION_INSTALL: |
2006 | switch (currentState) | ||
2007 | { | ||
2008 | case BOOTSTRAPPER_PACKAGE_STATE_PRESENT: | ||
2009 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT; | ||
2010 | break; | ||
2011 | |||
2012 | default: | ||
2013 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_CACHE; | ||
2014 | break; | ||
2015 | } | ||
2016 | break; | ||
2017 | |||
2018 | case BOOTSTRAPPER_ACTION_INSTALL: __fallthrough; | ||
2019 | case BOOTSTRAPPER_ACTION_UPDATE_REPLACE: __fallthrough; | ||
2020 | case BOOTSTRAPPER_ACTION_UPDATE_REPLACE_EMBEDDED: | ||
2021 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT; | 2014 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT; |
2022 | break; | 2015 | break; |
2023 | 2016 | ||
@@ -2026,7 +2019,7 @@ static HRESULT GetActionDefaultRequestState( | |||
2026 | break; | 2019 | break; |
2027 | 2020 | ||
2028 | case BOOTSTRAPPER_ACTION_UNINSTALL: | 2021 | case BOOTSTRAPPER_ACTION_UNINSTALL: |
2029 | *pRequestState = fPermanent ? BOOTSTRAPPER_REQUEST_STATE_NONE : BOOTSTRAPPER_REQUEST_STATE_ABSENT; | 2022 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_ABSENT; |
2030 | break; | 2023 | break; |
2031 | 2024 | ||
2032 | case BOOTSTRAPPER_ACTION_MODIFY: | 2025 | case BOOTSTRAPPER_ACTION_MODIFY: |
@@ -2052,7 +2045,7 @@ static HRESULT GetActionDefaultRequestState( | |||
2052 | } | 2045 | } |
2053 | 2046 | ||
2054 | LExit: | 2047 | LExit: |
2055 | return hr; | 2048 | return hr; |
2056 | } | 2049 | } |
2057 | 2050 | ||
2058 | static HRESULT AddRegistrationAction( | 2051 | static HRESULT AddRegistrationAction( |