From 837f2e309c8ef0476668c342f612dfe1bb26cb87 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 18 Feb 2021 10:45:20 -0600 Subject: [PATCH] Only the requested state and Cache=always should affect requestedCache. --- src/engine/exeengine.cpp | 24 +----------------------- src/engine/exeengine.h | 3 +-- src/engine/msiengine.cpp | 14 +------------- src/engine/msiengine.h | 3 +-- src/engine/mspengine.cpp | 14 +------------- src/engine/mspengine.h | 3 +-- src/engine/msuengine.cpp | 13 +------------ src/engine/msuengine.h | 3 +-- src/engine/package.cpp | 1 - src/engine/package.h | 1 - src/engine/plan.cpp | 39 ++++++++++++++++++++------------------- 11 files changed, 28 insertions(+), 90 deletions(-) diff --git a/src/engine/exeengine.cpp b/src/engine/exeengine.cpp index f734edc..cee755e 100644 --- a/src/engine/exeengine.cpp +++ b/src/engine/exeengine.cpp @@ -157,25 +157,12 @@ LExit: // PlanCalculate - calculates the execute and rollback state for the requested package state. // extern "C" HRESULT ExeEnginePlanCalculatePackage( - __in BURN_PACKAGE* pPackage, - __out_opt BOOL* pfBARequestedCache + __in BURN_PACKAGE* pPackage ) { HRESULT hr = S_OK; - //BOOL fCondition = FALSE; - //BOOTSTRAPPER_PACKAGE_STATE expected = BOOTSTRAPPER_PACKAGE_STATE_UNKNOWN; BOOTSTRAPPER_ACTION_STATE execute = BOOTSTRAPPER_ACTION_STATE_NONE; BOOTSTRAPPER_ACTION_STATE rollback = BOOTSTRAPPER_ACTION_STATE_NONE; - BOOL fBARequestedCache = FALSE; - - //// evaluate rollback install condition - //if (pPackage->sczRollbackInstallCondition) - //{ - // hr = ConditionEvaluate(pVariables, pPackage->sczRollbackInstallCondition, &fCondition); - // ExitOnFailure(hr, "Failed to evaluate rollback install condition."); - - // expected = fCondition ? BOOTSTRAPPER_PACKAGE_STATE_PRESENT : BOOTSTRAPPER_PACKAGE_STATE_ABSENT; - //} // execute action switch (pPackage->currentState) @@ -209,10 +196,6 @@ extern "C" HRESULT ExeEnginePlanCalculatePackage( case BOOTSTRAPPER_REQUEST_STATE_REPAIR: execute = BOOTSTRAPPER_ACTION_STATE_INSTALL; break; - case BOOTSTRAPPER_REQUEST_STATE_CACHE: - execute = BOOTSTRAPPER_ACTION_STATE_NONE; - fBARequestedCache = TRUE; - break; default: execute = BOOTSTRAPPER_ACTION_STATE_NONE; break; @@ -273,11 +256,6 @@ extern "C" HRESULT ExeEnginePlanCalculatePackage( pPackage->execute = execute; pPackage->rollback = rollback; - if (pfBARequestedCache) - { - *pfBARequestedCache = fBARequestedCache; - } - LExit: return hr; } diff --git a/src/engine/exeengine.h b/src/engine/exeengine.h index 1eac423..88a884e 100644 --- a/src/engine/exeengine.h +++ b/src/engine/exeengine.h @@ -21,8 +21,7 @@ HRESULT ExeEngineDetectPackage( __in BURN_VARIABLES* pVariables ); HRESULT ExeEnginePlanCalculatePackage( - __in BURN_PACKAGE* pPackage, - __out_opt BOOL* pfBARequestedCache + __in BURN_PACKAGE* pPackage ); HRESULT ExeEnginePlanAddPackage( __in_opt DWORD *pdwInsertSequence, diff --git a/src/engine/msiengine.cpp b/src/engine/msiengine.cpp index 252a17b..801bf9a 100644 --- a/src/engine/msiengine.cpp +++ b/src/engine/msiengine.cpp @@ -714,8 +714,7 @@ LExit: // extern "C" HRESULT MsiEnginePlanCalculatePackage( __in BURN_PACKAGE* pPackage, - __in BOOL fInsideMsiTransaction, - __out_opt BOOL* pfBARequestedCache + __in BOOL fInsideMsiTransaction ) { Trace(REPORT_STANDARD, "Planning MSI package 0x%p", pPackage); @@ -728,7 +727,6 @@ extern "C" HRESULT MsiEnginePlanCalculatePackage( BOOTSTRAPPER_ACTION_STATE rollback = BOOTSTRAPPER_ACTION_STATE_NONE; BOOL fFeatureActionDelta = FALSE; BOOL fRollbackFeatureActionDelta = FALSE; - BOOL fBARequestedCache = FALSE; if (pPackage->Msi.cFeatures) { @@ -813,11 +811,6 @@ extern "C" HRESULT MsiEnginePlanCalculatePackage( execute = BOOTSTRAPPER_ACTION_STATE_INSTALL; break; - case BOOTSTRAPPER_REQUEST_STATE_CACHE: - execute = BOOTSTRAPPER_ACTION_STATE_NONE; - fBARequestedCache = TRUE; - break; - default: execute = BOOTSTRAPPER_ACTION_STATE_NONE; break; @@ -880,11 +873,6 @@ extern "C" HRESULT MsiEnginePlanCalculatePackage( pPackage->execute = execute; pPackage->rollback = rollback; - if (pfBARequestedCache) - { - *pfBARequestedCache = fBARequestedCache; - } - LExit: return hr; } diff --git a/src/engine/msiengine.h b/src/engine/msiengine.h index b06866c..fe742a1 100644 --- a/src/engine/msiengine.h +++ b/src/engine/msiengine.h @@ -38,8 +38,7 @@ HRESULT MsiEnginePlanInitializePackage( ); HRESULT MsiEnginePlanCalculatePackage( __in BURN_PACKAGE* pPackage, - __in BOOL fInsideMsiTransaction, - __out_opt BOOL* pfBARequestedCache + __in BOOL fInsideMsiTransaction ); HRESULT MsiEnginePlanAddPackage( __in BOOTSTRAPPER_DISPLAY display, diff --git a/src/engine/mspengine.cpp b/src/engine/mspengine.cpp index f742ece..81e85e4 100644 --- a/src/engine/mspengine.cpp +++ b/src/engine/mspengine.cpp @@ -305,12 +305,10 @@ LExit: // extern "C" HRESULT MspEnginePlanCalculatePackage( __in BURN_PACKAGE* pPackage, - __in BOOL fInsideMsiTransaction, - __out BOOL* pfBARequestedCache + __in BOOL fInsideMsiTransaction ) { HRESULT hr = S_OK; - BOOL fBARequestedCache = FALSE; for (DWORD i = 0; i < pPackage->Msp.cTargetProductCodes; ++i) { @@ -352,11 +350,6 @@ extern "C" HRESULT MspEnginePlanCalculatePackage( execute = BOOTSTRAPPER_ACTION_STATE_INSTALL; break; - case BOOTSTRAPPER_REQUEST_STATE_CACHE: - execute = BOOTSTRAPPER_ACTION_STATE_NONE; - fBARequestedCache = TRUE; - break; - default: execute = BOOTSTRAPPER_ACTION_STATE_NONE; break; @@ -419,11 +412,6 @@ extern "C" HRESULT MspEnginePlanCalculatePackage( } } - if (pfBARequestedCache) - { - *pfBARequestedCache = fBARequestedCache; - } - return hr; } diff --git a/src/engine/mspengine.h b/src/engine/mspengine.h index 7ee01e8..2868216 100644 --- a/src/engine/mspengine.h +++ b/src/engine/mspengine.h @@ -38,8 +38,7 @@ HRESULT MspEnginePlanInitializePackage( ); HRESULT MspEnginePlanCalculatePackage( __in BURN_PACKAGE* pPackage, - __in BOOL fInsideMsiTransaction, - __out_opt BOOL* pfBARequestedCache + __in BOOL fInsideMsiTransaction ); HRESULT MspEnginePlanAddPackage( __in BOOTSTRAPPER_DISPLAY display, diff --git a/src/engine/msuengine.cpp b/src/engine/msuengine.cpp index 499e1da..91bbf36 100644 --- a/src/engine/msuengine.cpp +++ b/src/engine/msuengine.cpp @@ -82,14 +82,12 @@ LExit: // PlanCalculate - calculates the execute and rollback state for the requested package state. // extern "C" HRESULT MsuEnginePlanCalculatePackage( - __in BURN_PACKAGE* pPackage, - __out_opt BOOL* pfBARequestedCache + __in BURN_PACKAGE* pPackage ) { HRESULT hr = S_OK; BOOTSTRAPPER_ACTION_STATE execute = BOOTSTRAPPER_ACTION_STATE_NONE; BOOTSTRAPPER_ACTION_STATE rollback = BOOTSTRAPPER_ACTION_STATE_NONE; - BOOL fBARequestedCache = FALSE; BOOL fAllowUninstall = FALSE; // We can only uninstall MSU packages if they have a KB and we are on Win7 or newer. @@ -129,10 +127,6 @@ extern "C" HRESULT MsuEnginePlanCalculatePackage( execute = BOOTSTRAPPER_ACTION_STATE_INSTALL; break; - case BOOTSTRAPPER_REQUEST_STATE_CACHE: - execute = BOOTSTRAPPER_ACTION_STATE_NONE; - fBARequestedCache = TRUE; - default: execute = BOOTSTRAPPER_ACTION_STATE_NONE; break; @@ -187,11 +181,6 @@ extern "C" HRESULT MsuEnginePlanCalculatePackage( pPackage->execute = execute; pPackage->rollback = rollback; - if (pfBARequestedCache) - { - *pfBARequestedCache = fBARequestedCache; - } - LExit: return hr; } diff --git a/src/engine/msuengine.h b/src/engine/msuengine.h index 7f57a08..cd966b0 100644 --- a/src/engine/msuengine.h +++ b/src/engine/msuengine.h @@ -21,8 +21,7 @@ HRESULT MsuEngineDetectPackage( __in BURN_VARIABLES* pVariables ); HRESULT MsuEnginePlanCalculatePackage( - __in BURN_PACKAGE* pPackage, - __out_opt BOOL* pfBARequestedCache + __in BURN_PACKAGE* pPackage ); HRESULT MsuEnginePlanAddPackage( __in BURN_PACKAGE* pPackage, diff --git a/src/engine/package.cpp b/src/engine/package.cpp index b27b1e0..bb61cdc 100644 --- a/src/engine/package.cpp +++ b/src/engine/package.cpp @@ -317,7 +317,6 @@ extern "C" void PackageUninitialize( ReleaseStr(pPackage->sczLogPathVariable); ReleaseStr(pPackage->sczRollbackLogPathVariable); ReleaseStr(pPackage->sczInstallCondition); - ReleaseStr(pPackage->sczRollbackInstallCondition); ReleaseStr(pPackage->sczCacheId); if (pPackage->rgDependencyProviders) diff --git a/src/engine/package.h b/src/engine/package.h index a728fcc..5feb3f4 100644 --- a/src/engine/package.h +++ b/src/engine/package.h @@ -201,7 +201,6 @@ typedef struct _BURN_PACKAGE LPWSTR sczRollbackLogPathVariable; // name of the variable that will be set to the rollback path. LPWSTR sczInstallCondition; - LPWSTR sczRollbackInstallCondition; BOOL fPerMachine; BOOL fUninstallable; BOOL fVital; diff --git a/src/engine/plan.cpp b/src/engine/plan.cpp index 29adfb4..d99fdde 100644 --- a/src/engine/plan.cpp +++ b/src/engine/plan.cpp @@ -166,11 +166,11 @@ static HRESULT PlanDependencyActions( ); static HRESULT CalculateExecuteActions( __in BURN_PACKAGE* pPackage, - __in_opt BURN_ROLLBACK_BOUNDARY* pActiveRollbackBoundary, - __out_opt BOOL* pfBARequestedCache + __in_opt BURN_ROLLBACK_BOUNDARY* pActiveRollbackBoundary ); static BOOL NeedsCache( - __in BURN_PACKAGE* pPackage + __in BURN_PACKAGE* pPackage, + __in BOOL fExecute ); static HRESULT CreateContainerProgress( __in BURN_PLAN* pPlan, @@ -1081,24 +1081,24 @@ extern "C" HRESULT PlanExecutePackage( ) { HRESULT hr = S_OK; - BOOL fBARequestedCache = FALSE; + BOOL fRequestedCache = BOOTSTRAPPER_REQUEST_STATE_CACHE == pPackage->requested || + BOOTSTRAPPER_REQUEST_STATE_ABSENT < pPackage->requested && BURN_CACHE_TYPE_ALWAYS == pPackage->cacheType; - hr = CalculateExecuteActions(pPackage, pPlan->pActiveRollbackBoundary, &fBARequestedCache); + hr = CalculateExecuteActions(pPackage, pPlan->pActiveRollbackBoundary); ExitOnFailure(hr, "Failed to calculate plan actions for package: %ls", pPackage->sczId); // Calculate package states based on reference count and plan certain dependency actions prior to planning the package execute action. hr = DependencyPlanPackageBegin(fPerMachine, pPackage, pPlan); ExitOnFailure(hr, "Failed to begin plan dependency actions for package: %ls", pPackage->sczId); - if (fBARequestedCache || NeedsCache(pPackage)) + if (fRequestedCache || NeedsCache(pPackage, TRUE)) { hr = AddCachePackage(pPlan, pPackage, phSyncpointEvent); ExitOnFailure(hr, "Failed to plan cache package."); } - else if (BURN_CACHE_STATE_COMPLETE != pPackage->cache && // if the package is not in the cache, disable any rollback that would require the package from the cache. - (BOOTSTRAPPER_ACTION_STATE_UNINSTALL < pPackage->rollback || (BURN_PACKAGE_TYPE_EXE == pPackage->type && BOOTSTRAPPER_ACTION_STATE_NONE != pPackage->rollback)) - ) + else if (BURN_CACHE_STATE_COMPLETE != pPackage->cache && NeedsCache(pPackage, FALSE)) { + // If the package is not in the cache, disable any rollback that would require the package from the cache. LogId(REPORT_STANDARD, MSG_PLAN_DISABLING_ROLLBACK_NO_CACHE, pPackage->sczId, LoggingCacheStateToString(pPackage->cache), LoggingActionStateToString(pPackage->rollback)); pPackage->rollback = BOOTSTRAPPER_ACTION_STATE_NONE; } @@ -1431,7 +1431,7 @@ extern "C" HRESULT PlanRelatedBundlesComplete( if (BOOTSTRAPPER_REQUEST_STATE_NONE != pRelatedBundle->package.requested) { - hr = ExeEnginePlanCalculatePackage(&pRelatedBundle->package, NULL); + hr = ExeEnginePlanCalculatePackage(&pRelatedBundle->package); ExitOnFailure(hr, "Failed to calcuate plan for related bundle: %ls", pRelatedBundle->package.sczId); // Calculate package states based on reference count for addon and patch related bundles. @@ -2819,8 +2819,7 @@ LExit: static HRESULT CalculateExecuteActions( __in BURN_PACKAGE* pPackage, - __in_opt BURN_ROLLBACK_BOUNDARY* pActiveRollbackBoundary, - __out_opt BOOL* pfBARequestedCache + __in_opt BURN_ROLLBACK_BOUNDARY* pActiveRollbackBoundary ) { HRESULT hr = S_OK; @@ -2830,19 +2829,19 @@ static HRESULT CalculateExecuteActions( switch (pPackage->type) { case BURN_PACKAGE_TYPE_EXE: - hr = ExeEnginePlanCalculatePackage(pPackage, pfBARequestedCache); + hr = ExeEnginePlanCalculatePackage(pPackage); break; case BURN_PACKAGE_TYPE_MSI: - hr = MsiEnginePlanCalculatePackage(pPackage, fInsideMsiTransaction, pfBARequestedCache); + hr = MsiEnginePlanCalculatePackage(pPackage, fInsideMsiTransaction); break; case BURN_PACKAGE_TYPE_MSP: - hr = MspEnginePlanCalculatePackage(pPackage, fInsideMsiTransaction, pfBARequestedCache); + hr = MspEnginePlanCalculatePackage(pPackage, fInsideMsiTransaction); break; case BURN_PACKAGE_TYPE_MSU: - hr = MsuEnginePlanCalculatePackage(pPackage, pfBARequestedCache); + hr = MsuEnginePlanCalculatePackage(pPackage); break; default: @@ -2855,16 +2854,18 @@ LExit: } static BOOL NeedsCache( - __in BURN_PACKAGE* pPackage + __in BURN_PACKAGE* pPackage, + __in BOOL fExecute ) { + BOOTSTRAPPER_ACTION_STATE action = fExecute ? pPackage->execute : pPackage->rollback; if (BURN_PACKAGE_TYPE_EXE == pPackage->type) // Exe packages require the package for all operations (even uninstall). { - return BOOTSTRAPPER_ACTION_STATE_NONE != pPackage->execute; + return BOOTSTRAPPER_ACTION_STATE_NONE != action; } else // The other package types can uninstall without the original package. { - return BOOTSTRAPPER_ACTION_STATE_UNINSTALL < pPackage->execute; + return BOOTSTRAPPER_ACTION_STATE_UNINSTALL < action; } }