From 10ef9d5bfbf81f454113a1c2716009831a916222 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 10 Mar 2021 15:47:59 -0600 Subject: Determine whether to ignore forward compatible bundles during Plan. --- src/engine/plan.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'src/engine/plan.cpp') diff --git a/src/engine/plan.cpp b/src/engine/plan.cpp index 4f29209f..87607382 100644 --- a/src/engine/plan.cpp +++ b/src/engine/plan.cpp @@ -194,6 +194,8 @@ extern "C" void PlanReset( __in BURN_PACKAGES* pPackages ) { + PackageUninitialize(&pPlan->forwardCompatibleBundle); + if (pPlan->rgRegistrationActions) { for (DWORD i = 0; i < pPlan->cRegistrationActions; ++i) @@ -488,6 +490,72 @@ LExit: return hr; } +extern "C" HRESULT PlanForwardCompatibleBundles( + __in BURN_USER_EXPERIENCE* pUX, + __in BOOTSTRAPPER_COMMAND* pCommand, + __in BURN_PLAN* pPlan, + __in BURN_REGISTRATION* pRegistration, + __in BOOTSTRAPPER_ACTION action + ) +{ + HRESULT hr = S_OK; + BOOL fRecommendIgnore = TRUE; + BOOL fIgnoreBundle = FALSE; + + if (!pRegistration->fForwardCompatibleBundleExists) + { + ExitFunction(); + } + + // Only change the recommendation if an active parent was provided. + if (pRegistration->sczActiveParent && *pRegistration->sczActiveParent) + { + // On install, recommend running the forward compatible bundle because there is an active parent. This + // will essentially register the parent with the forward compatible bundle. + if (BOOTSTRAPPER_ACTION_INSTALL == action) + { + fRecommendIgnore = FALSE; + } + else if (BOOTSTRAPPER_ACTION_UNINSTALL == action || + BOOTSTRAPPER_ACTION_MODIFY == action || + BOOTSTRAPPER_ACTION_REPAIR == action) + { + // When modifying the bundle, only recommend running the forward compatible bundle if the parent + // is already registered as a dependent of the provider key. + if (pRegistration->fParentRegisteredAsDependent) + { + fRecommendIgnore = FALSE; + } + } + } + + for (DWORD iRelatedBundle = 0; iRelatedBundle < pRegistration->relatedBundles.cRelatedBundles; ++iRelatedBundle) + { + BURN_RELATED_BUNDLE* pRelatedBundle = pRegistration->relatedBundles.rgRelatedBundles + iRelatedBundle; + if (!pRelatedBundle->fForwardCompatible) + { + continue; + } + + fIgnoreBundle = fRecommendIgnore; + + hr = UserExperienceOnPlanForwardCompatibleBundle(pUX, pRelatedBundle->package.sczId, pRelatedBundle->relationType, pRelatedBundle->sczTag, pRelatedBundle->package.fPerMachine, pRelatedBundle->pVersion, &fIgnoreBundle); + ExitOnRootFailure(hr, "BA aborted plan forward compatible bundle."); + + if (!fIgnoreBundle) + { + hr = PseudoBundleInitializePassthrough(&pPlan->forwardCompatibleBundle, pCommand, NULL, pRegistration->sczActiveParent, pRegistration->sczAncestors, &pRelatedBundle->package); + ExitOnFailure(hr, "Failed to initialize pass through bundle."); + + pPlan->fEnabledForwardCompatibleBundle = TRUE; + break; + } + } + +LExit: + return hr; +} + extern "C" HRESULT PlanPackages( __in BURN_USER_EXPERIENCE* pUX, __in BURN_PACKAGES* pPackages, -- cgit v1.2.3-55-g6feb