From fd8c2b0899bfbce07386af245c04eb21dc01cbdf Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 2 Feb 2021 18:09:58 -0600 Subject: Update the logic for determining when the bundle should be registered. The basic rule is that if a non-permanent package is present at the end of the chain, then the bundle should be registered. If no non-permanent packages are present at the end of the chain, then the bundle should not be registered. This required tracking what actually happened with each package during Apply. Include cache status in registration calculation. Include dependency ref-counting when determining whether the bundle should be registered. --- src/engine/dependency.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/engine/dependency.cpp') diff --git a/src/engine/dependency.cpp b/src/engine/dependency.cpp index 1c33aaf2..a6a8fe4d 100644 --- a/src/engine/dependency.cpp +++ b/src/engine/dependency.cpp @@ -708,6 +708,9 @@ static HRESULT DetectPackageDependents( { HRESULT hr = S_OK; HKEY hkHive = pPackage->fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + BOOL fCanIgnorePresence = pPackage->fCanAffectRegistration && 0 < pPackage->cDependencyProviders && + (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->cacheRegistrationState || BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->installRegistrationState); + BOOL fBundleRegisteredAsDependent = FALSE; // There's currently no point in getting the dependents if the scope doesn't match, // because they will just get ignored. @@ -729,6 +732,20 @@ static HRESULT DetectPackageDependents( { pPackage->fPackageProviderExists = TRUE; } + + if (fCanIgnorePresence && !fBundleRegisteredAsDependent) + { + for (DWORD iDependent = 0; iDependent < pProvider->cDependents; ++iDependent) + { + DEPENDENCY* pDependent = pProvider->rgDependents + iDependent; + + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pRegistration->sczId, -1, pDependent->sczKey, -1)) + { + fBundleRegisteredAsDependent = TRUE; + break; + } + } + } } else { @@ -747,6 +764,18 @@ static HRESULT DetectPackageDependents( pPackage->fPackageProviderExists = TRUE; } + if (fCanIgnorePresence && !fBundleRegisteredAsDependent) + { + if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->cacheRegistrationState) + { + pPackage->cacheRegistrationState = BURN_PACKAGE_REGISTRATION_STATE_IGNORED; + } + if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->installRegistrationState) + { + pPackage->installRegistrationState = BURN_PACKAGE_REGISTRATION_STATE_IGNORED; + } + } + LExit: return hr; } -- cgit v1.2.3-55-g6feb