Only the requested state and Cache=always should affect requestedCache.

This commit is contained in:
Sean Hall 2021-02-18 10:45:20 -06:00
Родитель b29af5d005
Коммит 837f2e309c
11 изменённых файлов: 28 добавлений и 90 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -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)

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;
}
}