From 32602bb04be4a01e4b857d2071e07dd4cc2b38d4 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 1 Apr 2022 19:29:10 -0500 Subject: Use Burn's parent switch with BundlePackages. --- src/burn/engine/bundlepackageengine.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/burn/engine/bundlepackageengine.cpp') diff --git a/src/burn/engine/bundlepackageengine.cpp b/src/burn/engine/bundlepackageengine.cpp index ef08d417..6336bd27 100644 --- a/src/burn/engine/bundlepackageengine.cpp +++ b/src/burn/engine/bundlepackageengine.cpp @@ -23,6 +23,7 @@ static HRESULT ExecuteBundle( __in BOOTSTRAPPER_ACTION_STATE action, __in BOOTSTRAPPER_RELATION_TYPE relationType, __in BURN_PACKAGE* pPackage, + __in_z_opt LPCWSTR wzParent, __in_z_opt LPCWSTR wzIgnoreDependencies, __in_z_opt LPCWSTR wzAncestors, __in_z_opt LPCWSTR wzEngineWorkingDirectory, @@ -239,7 +240,7 @@ extern "C" void BundlePackageEnginePackageUninitialize( extern "C" HRESULT BundlePackageEngineDetectPackage( __in BURN_PACKAGE* pPackage, - __in BURN_REGISTRATION* /*pRegistration*/, + __in BURN_REGISTRATION* pRegistration, __in BURN_USER_EXPERIENCE* pUserExperience ) { @@ -291,9 +292,8 @@ extern "C" HRESULT BundlePackageEngineDetectPackage( pPackage->installRegistrationState = BOOTSTRAPPER_PACKAGE_STATE_ABSENT < pPackage->currentState ? BURN_PACKAGE_REGISTRATION_STATE_PRESENT : BURN_PACKAGE_REGISTRATION_STATE_ABSENT; } - // TODO: The bundle is registering itself as a dependent when installed as a chain package, which prevents us from uninstalling it. - //hr = DependencyDetectChainPackage(pPackage, pRegistration); - //ExitOnFailure(hr, "Failed to detect dependencies for BUNDLE package."); + hr = DependencyDetectChainPackage(pPackage, pRegistration); + ExitOnFailure(hr, "Failed to detect dependencies for BUNDLE package."); // TODO: uninstalling compatible Bundles like MsiEngine supports? @@ -447,6 +447,9 @@ extern "C" HRESULT BundlePackageEnginePlanAddPackage( pAction->bundlePackage.pPackage = pPackage; pAction->bundlePackage.action = pPackage->rollback; + hr = StrAllocString(&pAction->bundlePackage.sczParent, pPlan->wzBundleId, 0); + ExitOnFailure(hr, "Failed to allocate the parent."); + if (pPackage->Bundle.wzAncestors) { hr = StrAllocString(&pAction->bundlePackage.sczAncestors, pPackage->Bundle.wzAncestors, 0); @@ -475,6 +478,9 @@ extern "C" HRESULT BundlePackageEnginePlanAddPackage( pAction->bundlePackage.pPackage = pPackage; pAction->bundlePackage.action = pPackage->execute; + hr = StrAllocString(&pAction->bundlePackage.sczParent, pPlan->wzBundleId, 0); + ExitOnFailure(hr, "Failed to allocate the parent."); + if (pPackage->Bundle.wzAncestors) { hr = StrAllocString(&pAction->bundlePackage.sczAncestors, pPackage->Bundle.wzAncestors, 0); @@ -597,13 +603,14 @@ extern "C" HRESULT BundlePackageEngineExecutePackage( ) { BOOTSTRAPPER_ACTION_STATE action = pExecuteAction->bundlePackage.action; + LPCWSTR wzParent = pExecuteAction->bundlePackage.sczParent; LPCWSTR wzIgnoreDependencies = pExecuteAction->bundlePackage.sczIgnoreDependencies; LPCWSTR wzAncestors = pExecuteAction->bundlePackage.sczAncestors; LPCWSTR wzEngineWorkingDirectory = pExecuteAction->bundlePackage.sczEngineWorkingDirectory; BOOTSTRAPPER_RELATION_TYPE relationType = BOOTSTRAPPER_RELATION_CHAIN_PACKAGE; BURN_PACKAGE* pPackage = pExecuteAction->bundlePackage.pPackage; - return ExecuteBundle(pCache, pVariables, fRollback, pfnGenericMessageHandler, pvContext, action, relationType, pPackage, wzIgnoreDependencies, wzAncestors, wzEngineWorkingDirectory, pRestart); + return ExecuteBundle(pCache, pVariables, fRollback, pfnGenericMessageHandler, pvContext, action, relationType, pPackage, wzParent, wzIgnoreDependencies, wzAncestors, wzEngineWorkingDirectory, pRestart); } extern "C" HRESULT BundlePackageEngineExecuteRelatedBundle( @@ -617,6 +624,7 @@ extern "C" HRESULT BundlePackageEngineExecuteRelatedBundle( ) { BOOTSTRAPPER_ACTION_STATE action = pExecuteAction->relatedBundle.action; + LPCWSTR wzParent = NULL; LPCWSTR wzIgnoreDependencies = pExecuteAction->relatedBundle.sczIgnoreDependencies; LPCWSTR wzAncestors = pExecuteAction->relatedBundle.sczAncestors; LPCWSTR wzEngineWorkingDirectory = pExecuteAction->relatedBundle.sczEngineWorkingDirectory; @@ -624,7 +632,7 @@ extern "C" HRESULT BundlePackageEngineExecuteRelatedBundle( BOOTSTRAPPER_RELATION_TYPE relationType = ConvertRelationType(pRelatedBundle->planRelationType); BURN_PACKAGE* pPackage = &pRelatedBundle->package; - return ExecuteBundle(pCache, pVariables, fRollback, pfnGenericMessageHandler, pvContext, action, relationType, pPackage, wzIgnoreDependencies, wzAncestors, wzEngineWorkingDirectory, pRestart); + return ExecuteBundle(pCache, pVariables, fRollback, pfnGenericMessageHandler, pvContext, action, relationType, pPackage, wzParent, wzIgnoreDependencies, wzAncestors, wzEngineWorkingDirectory, pRestart); } extern "C" void BundlePackageEngineUpdateInstallRegistrationState( @@ -721,6 +729,7 @@ static HRESULT ExecuteBundle( __in BOOTSTRAPPER_ACTION_STATE action, __in BOOTSTRAPPER_RELATION_TYPE relationType, __in BURN_PACKAGE* pPackage, + __in_z_opt LPCWSTR wzParent, __in_z_opt LPCWSTR wzIgnoreDependencies, __in_z_opt LPCWSTR wzAncestors, __in_z_opt LPCWSTR wzEngineWorkingDirectory, @@ -848,6 +857,15 @@ static HRESULT ExecuteBundle( ExitOnFailure(hr, "Failed to append relation type argument."); } + if (wzParent) + { + hr = StrAllocConcatFormatted(&sczBaseCommand, L" -%ls", BURN_COMMANDLINE_SWITCH_PARENT); + ExitOnFailure(hr, "Failed to append the parent switch to the command line."); + + hr = AppAppendCommandLineArgument(&sczBaseCommand, wzParent); + ExitOnFailure(hr, "Failed to append the parent to the command line."); + } + // Add the list of dependencies to ignore, if any, to the burn command line. if (BOOTSTRAPPER_RELATION_CHAIN_PACKAGE == relationType) { -- cgit v1.2.3-55-g6feb