From edccb203c421d2bd820062024088c6698424d9ee Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Wed, 4 Feb 2026 20:47:04 -0500 Subject: Support dual-purpose packages in Burn. Fixes https://github.com/wixtoolset/issues/issues/8958 --- src/burn/engine/core.cpp | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'src/burn/engine/core.cpp') diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp index 2dfa4857..7937bd65 100644 --- a/src/burn/engine/core.cpp +++ b/src/burn/engine/core.cpp @@ -379,7 +379,7 @@ extern "C" HRESULT CoreDetect( pEngineState->registration.fEligibleForCleanup = FALSE; } - LogId(REPORT_STANDARD, MSG_DETECTED_PACKAGE, pPackage->sczId, LoggingPackageStateToString(pPackage->currentState), LoggingBoolToString(pPackage->fCached), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->installRegistrationState), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->cacheRegistrationState)); + LogId(REPORT_STANDARD, MSG_DETECTED_PACKAGE, pPackage->sczId, LoggingPackageStateToString(pPackage->currentState), LoggingBoolToString(pPackage->fCached), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->installRegistrationState), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->cacheRegistrationState), LoggingPackageScopeToString(pPackage->scope)); if (BURN_PACKAGE_TYPE_MSI == pPackage->type) { @@ -424,8 +424,9 @@ LExit: extern "C" HRESULT CorePlan( __in BURN_ENGINE_STATE* pEngineState, - __in BOOTSTRAPPER_ACTION action - ) + __in BOOTSTRAPPER_ACTION action, + __in BOOTSTRAPPER_SCOPE plannedScope +) { HRESULT hr = S_OK; BOOL fPlanBegan = FALSE; @@ -433,7 +434,7 @@ extern "C" HRESULT CorePlan( BURN_PACKAGE* pForwardCompatibleBundlePackage = NULL; BOOL fContinuePlanning = TRUE; // assume we won't skip planning due to dependencies. - LogId(REPORT_STANDARD, MSG_PLAN_BEGIN, pEngineState->packages.cPackages, LoggingBurnActionToString(action)); + LogId(REPORT_STANDARD, MSG_PLAN_BEGIN, pEngineState->packages.cPackages, LoggingBurnActionToString(action), LoggingBundleScopeToString(plannedScope)); fPlanBegan = TRUE; hr = BACallbackOnPlanBegin(&pEngineState->userExperience, pEngineState->packages.cPackages); @@ -452,12 +453,13 @@ extern "C" HRESULT CorePlan( pEngineState->fPlanned = FALSE; PlanReset(&pEngineState->plan, &pEngineState->variables, &pEngineState->containers, &pEngineState->packages, &pEngineState->layoutPayloads); - hr = PlanSetVariables(action, &pEngineState->variables); - ExitOnFailure(hr, "Failed to update action."); + hr = PlanSetVariables(action, pEngineState->registration.scope, pEngineState->plan.plannedScope, &pEngineState->variables); + ExitOnFailure(hr, "Failed to update plan variables."); // Remember the overall action state in the plan since it shapes the changes // we make everywhere. pEngineState->plan.action = action; + pEngineState->plan.plannedScope = plannedScope; pEngineState->plan.pCache = &pEngineState->cache; pEngineState->plan.pCommand = &pEngineState->command; pEngineState->plan.pInternalCommand = &pEngineState->internalCommand; @@ -467,6 +469,17 @@ extern "C" HRESULT CorePlan( pEngineState->plan.fDisableRollback = pEngineState->fDisableRollback || BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL == pEngineState->plan.action; pEngineState->plan.fPlanPackageCacheRollback = BOOTSTRAPPER_REGISTRATION_TYPE_NONE == pEngineState->registration.detectedRegistrationType; + hr = PlanPackagesAndBundleScope(pEngineState->packages.rgPackages, pEngineState->packages.cPackages, pEngineState->plan.plannedScope, pEngineState->registration.scope, pEngineState->command.commandLineScope, &pEngineState->plan.plannedScope, &pEngineState->registration.fPerMachine); + ExitOnFailure(hr, "Failed to determine packages and bundle scope."); + + if (BOOTSTRAPPER_PACKAGE_SCOPE_PER_MACHINE_OR_PER_USER == pEngineState->registration.scope || BOOTSTRAPPER_PACKAGE_SCOPE_PER_USER_OR_PER_MACHINE == pEngineState->registration.scope) + { + LogId(REPORT_STANDARD, MSG_PLAN_CONFIGURED_SCOPE, LoggingInstallScopeToString(pEngineState->registration.fPerMachine)); + } + + hr = RegistrationSetPaths(&pEngineState->registration, &pEngineState->cache); + ExitOnFailure(hr, "Failed to set registration paths."); + // Set resume commandline hr = PlanSetResumeCommand(&pEngineState->plan, &pEngineState->registration, &pEngineState->log); ExitOnFailure(hr, "Failed to set resume command"); @@ -475,7 +488,7 @@ extern "C" HRESULT CorePlan( ExitOnFailure(hr, "Failed to initialize the dependencies for the plan."); hr = RegistrationPlanInitialize(&pEngineState->registration); - ExitOnFailure(hr, "Failed to initialize registration for the plan."); + ExitOnFailure(hr, "Failed to initialize the plan for registration."); if (BOOTSTRAPPER_ACTION_LAYOUT == action) { @@ -556,6 +569,9 @@ extern "C" HRESULT CorePlan( LogPackages(pUpgradeBundlePackage, pForwardCompatibleBundlePackage, &pEngineState->packages, &pEngineState->registration.relatedBundles, action); } + hr = PlanSetVariables(action, pEngineState->registration.scope, pEngineState->plan.plannedScope, &pEngineState->variables); + ExitOnFailure(hr, "Failed to update plan variables after planning."); + PlanDump(&pEngineState->plan); LExit: @@ -1331,7 +1347,7 @@ extern "C" void CoreCleanup( ExitFunction(); } - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); ExitOnFailure(hr, "Plan during cleanup failed"); hr = CoreApply(pEngineState, pEngineState->hMessageWindow); @@ -1470,6 +1486,14 @@ extern "C" HRESULT CoreParseCommandLine( { pInternalCommand->fDisableSystemRestore = TRUE; } + else if (CSTR_EQUAL == ::CompareStringOrdinal(&argv[i][1], -1, L"peruser", -1, TRUE)) + { + pCommand->commandLineScope = BOOTSTRAPPER_SCOPE_PER_USER; + } + else if (CSTR_EQUAL == ::CompareStringOrdinal(&argv[i][1], -1, L"permachine", -1, TRUE)) + { + pCommand->commandLineScope = BOOTSTRAPPER_SCOPE_PER_MACHINE; + } else if (CSTR_EQUAL == ::CompareStringOrdinal(&argv[i][1], -1, L"originalsource", -1, TRUE)) { if (i + 1 >= argc) @@ -2346,7 +2370,7 @@ static void LogPackages( LogRollbackBoundary(pPackage->pRollbackBoundaryBackward); } - LogId(REPORT_STANDARD, MSG_PLANNED_PACKAGE, pPackage->sczId, LoggingPackageStateToString(pPackage->currentState), LoggingRequestStateToString(pPackage->defaultRequested), LoggingRequestStateToString(pPackage->requested), LoggingActionStateToString(pPackage->execute), LoggingActionStateToString(pPackage->rollback), LoggingCacheTypeToString(pPackage->authoredCacheType), LoggingCacheTypeToString(pPackage->cacheType), LoggingPlannedCacheToString(pPackage), LoggingBoolToString(pPackage->fPlannedUncache), LoggingDependencyActionToString(pPackage->dependencyExecute), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->expectedInstallRegistrationState), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->expectedCacheRegistrationState)); + LogId(REPORT_STANDARD, MSG_PLANNED_PACKAGE, pPackage->sczId, LoggingPackageStateToString(pPackage->currentState), LoggingRequestStateToString(pPackage->defaultRequested), LoggingRequestStateToString(pPackage->requested), LoggingActionStateToString(pPackage->execute), LoggingActionStateToString(pPackage->rollback), LoggingCacheTypeToString(pPackage->authoredCacheType), LoggingCacheTypeToString(pPackage->cacheType), LoggingPlannedCacheToString(pPackage), LoggingBoolToString(pPackage->fPlannedUncache), LoggingDependencyActionToString(pPackage->dependencyExecute), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->expectedInstallRegistrationState), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->expectedCacheRegistrationState), LoggingInstallScopeToString(pPackage->fPerMachine)); if (BURN_PACKAGE_TYPE_MSI == pPackage->type) { -- cgit v1.2.3-55-g6feb