aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine/plan.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-01-14 21:37:24 -0600
committerSean Hall <r.sean.hall@gmail.com>2022-01-16 10:30:28 -0600
commitda1d1376953ef1c9afb32d5eee02b785e52e372e (patch)
tree0df8550960259d7b13f5cd90f04d21b5576f16b7 /src/burn/engine/plan.cpp
parentabe316b80fae80eba54b0b79e76b6362105fa098 (diff)
downloadwix-da1d1376953ef1c9afb32d5eee02b785e52e372e.tar.gz
wix-da1d1376953ef1c9afb32d5eee02b785e52e372e.tar.bz2
wix-da1d1376953ef1c9afb32d5eee02b785e52e372e.zip
Remove orphan compatible MSI packages.
Reimplements #3190
Diffstat (limited to 'src/burn/engine/plan.cpp')
-rw-r--r--src/burn/engine/plan.cpp83
1 files changed, 74 insertions, 9 deletions
diff --git a/src/burn/engine/plan.cpp b/src/burn/engine/plan.cpp
index e0e9a82b..1dd78773 100644
--- a/src/burn/engine/plan.cpp
+++ b/src/burn/engine/plan.cpp
@@ -96,6 +96,10 @@ static HRESULT AppendRollbackCacheAction(
96 __in BURN_PLAN* pPlan, 96 __in BURN_PLAN* pPlan,
97 __out BURN_CACHE_ACTION** ppCacheAction 97 __out BURN_CACHE_ACTION** ppCacheAction
98 ); 98 );
99static HRESULT AppendCleanAction(
100 __in BURN_PLAN* pPlan,
101 __out BURN_CLEAN_ACTION** ppCleanAction
102 );
99static HRESULT ProcessPayloadGroup( 103static HRESULT ProcessPayloadGroup(
100 __in BURN_PLAN* pPlan, 104 __in BURN_PLAN* pPlan,
101 __in BURN_PAYLOAD_GROUP* pPayloadGroup 105 __in BURN_PAYLOAD_GROUP* pPayloadGroup
@@ -286,6 +290,10 @@ extern "C" void PlanUninitializeExecuteAction(
286 case BURN_EXECUTE_ACTION_TYPE_PACKAGE_DEPENDENCY: 290 case BURN_EXECUTE_ACTION_TYPE_PACKAGE_DEPENDENCY:
287 ReleaseStr(pExecuteAction->packageDependency.sczBundleProviderKey); 291 ReleaseStr(pExecuteAction->packageDependency.sczBundleProviderKey);
288 break; 292 break;
293
294 case BURN_EXECUTE_ACTION_TYPE_UNINSTALL_MSI_COMPATIBLE_PACKAGE:
295 ReleaseStr(pExecuteAction->uninstallMsiCompatiblePackage.sczLogPath);
296 break;
289 } 297 }
290} 298}
291 299
@@ -823,6 +831,11 @@ static HRESULT PlanPackagesHelper(
823 BURN_PACKAGE* pPackage = rgPackages + iPackage; 831 BURN_PACKAGE* pPackage = rgPackages + iPackage;
824 832
825 UserExperienceOnPlannedPackage(pUX, pPackage->sczId, pPackage->execute, pPackage->rollback, pPackage->fPlannedCache, pPackage->fPlannedUncache); 833 UserExperienceOnPlannedPackage(pUX, pPackage->sczId, pPackage->execute, pPackage->rollback, pPackage->fPlannedCache, pPackage->fPlannedUncache);
834
835 if (pPackage->compatiblePackage.fPlannable)
836 {
837 UserExperienceOnPlannedCompatiblePackage(pUX, pPackage->sczId, pPackage->compatiblePackage.compatibleEntry.sczId, pPackage->compatiblePackage.fRemove);
838 }
826 } 839 }
827 840
828LExit: 841LExit:
@@ -878,7 +891,7 @@ static HRESULT InitializePackage(
878 891
879 if (BURN_PACKAGE_TYPE_MSI == pPackage->type) 892 if (BURN_PACKAGE_TYPE_MSI == pPackage->type)
880 { 893 {
881 hr = MsiEnginePlanInitializePackage(pPackage, pVariables, pUX); 894 hr = MsiEnginePlanInitializePackage(pPackage, pPlan->action, pVariables, pUX);
882 ExitOnFailure(hr, "Failed to initialize plan package: %ls", pPackage->sczId); 895 ExitOnFailure(hr, "Failed to initialize plan package: %ls", pPackage->sczId);
883 } 896 }
884 897
@@ -918,7 +931,7 @@ static HRESULT ProcessPackage(
918 } 931 }
919 else 932 else
920 { 933 {
921 if (BOOTSTRAPPER_REQUEST_STATE_NONE != pPackage->requested) 934 if (BOOTSTRAPPER_REQUEST_STATE_NONE != pPackage->requested || pPackage->compatiblePackage.fRequested)
922 { 935 {
923 // If the package is in a requested state, plan it. 936 // If the package is in a requested state, plan it.
924 hr = PlanExecutePackage(fBundlePerMachine, pUX, pPlan, pPackage, pLog, pVariables); 937 hr = PlanExecutePackage(fBundlePerMachine, pUX, pPlan, pPackage, pLog, pVariables);
@@ -1151,7 +1164,7 @@ extern "C" HRESULT PlanExecutePackage(
1151 ExitOnFailure(hr, "Failed to complete plan dependency actions for package: %ls", pPackage->sczId); 1164 ExitOnFailure(hr, "Failed to complete plan dependency actions for package: %ls", pPackage->sczId);
1152 1165
1153 // If we are going to take any action on this package, add progress for it. 1166 // If we are going to take any action on this package, add progress for it.
1154 if (BOOTSTRAPPER_ACTION_STATE_NONE != pPackage->execute || BOOTSTRAPPER_ACTION_STATE_NONE != pPackage->rollback) 1167 if (BOOTSTRAPPER_ACTION_STATE_NONE != pPackage->execute || BOOTSTRAPPER_ACTION_STATE_NONE != pPackage->rollback || pPackage->compatiblePackage.fRemove)
1155 { 1168 {
1156 LoggingIncrementPackageSequence(); 1169 LoggingIncrementPackageSequence();
1157 1170
@@ -1560,12 +1573,10 @@ extern "C" HRESULT PlanCleanPackage(
1560 1573
1561 if (fPlanCleanPackage) 1574 if (fPlanCleanPackage)
1562 { 1575 {
1563 hr = MemEnsureArraySize(reinterpret_cast<LPVOID*>(&pPlan->rgCleanActions), pPlan->cCleanActions + 1, sizeof(BURN_CLEAN_ACTION), 5); 1576 hr = AppendCleanAction(pPlan, &pCleanAction);
1564 ExitOnFailure(hr, "Failed to grow plan's array of clean actions."); 1577 ExitOnFailure(hr, "Failed to append clean action to plan.");
1565
1566 pCleanAction = pPlan->rgCleanActions + pPlan->cCleanActions;
1567 ++pPlan->cCleanActions;
1568 1578
1579 pCleanAction->type = BURN_CLEAN_ACTION_TYPE_PACKAGE;
1569 pCleanAction->pPackage = pPackage; 1580 pCleanAction->pPackage = pPackage;
1570 1581
1571 pPackage->fPlannedUncache = TRUE; 1582 pPackage->fPlannedUncache = TRUE;
@@ -1576,6 +1587,15 @@ extern "C" HRESULT PlanCleanPackage(
1576 } 1587 }
1577 } 1588 }
1578 1589
1590 if (pPackage->compatiblePackage.fRemove)
1591 {
1592 hr = AppendCleanAction(pPlan, &pCleanAction);
1593 ExitOnFailure(hr, "Failed to append clean action to plan.");
1594
1595 pCleanAction->type = BURN_CLEAN_ACTION_TYPE_COMPATIBLE_PACKAGE;
1596 pCleanAction->pPackage = pPackage;
1597 }
1598
1579LExit: 1599LExit:
1580 return hr; 1600 return hr;
1581} 1601}
@@ -2229,6 +2249,24 @@ LExit:
2229 return hr; 2249 return hr;
2230} 2250}
2231 2251
2252static HRESULT AppendCleanAction(
2253 __in BURN_PLAN* pPlan,
2254 __out BURN_CLEAN_ACTION** ppCleanAction
2255 )
2256{
2257 HRESULT hr = S_OK;
2258
2259 hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(&pPlan->rgCleanActions), pPlan->cCleanActions, 1, sizeof(BURN_CLEAN_ACTION), 5);
2260 ExitOnFailure(hr, "Failed to grow plan's array of clean actions.");
2261
2262
2263 *ppCleanAction = pPlan->rgCleanActions + pPlan->cCleanActions;
2264 ++pPlan->cCleanActions;
2265
2266LExit:
2267 return hr;
2268}
2269
2232static HRESULT ProcessPayloadGroup( 2270static HRESULT ProcessPayloadGroup(
2233 __in BURN_PLAN* pPlan, 2271 __in BURN_PLAN* pPlan,
2234 __in BURN_PAYLOAD_GROUP* pPayloadGroup 2272 __in BURN_PAYLOAD_GROUP* pPayloadGroup
@@ -2505,6 +2543,8 @@ static HRESULT CalculateExecuteActions(
2505 ExitOnFailure(hr, "Invalid package type."); 2543 ExitOnFailure(hr, "Invalid package type.");
2506 } 2544 }
2507 2545
2546 pPackage->compatiblePackage.fRemove = pPackage->compatiblePackage.fPlannable && pPackage->compatiblePackage.fRequested;
2547
2508LExit: 2548LExit:
2509 return hr; 2549 return hr;
2510} 2550}
@@ -2622,6 +2662,10 @@ static void ExecuteActionLog(
2622 } 2662 }
2623 break; 2663 break;
2624 2664
2665 case BURN_EXECUTE_ACTION_TYPE_UNINSTALL_MSI_COMPATIBLE_PACKAGE:
2666 LogStringLine(PlanDumpLevel, "%ls action[%u]: UNINSTALL_MSI_COMPATIBLE_PACKAGE package id: %ls, compatible package id: %ls, cache id: %ls, log path: %ls, logging attrib: %u", wzBase, iAction, pAction->uninstallMsiCompatiblePackage.pParentPackage->sczId, pAction->uninstallMsiCompatiblePackage.pParentPackage->compatiblePackage.compatibleEntry.sczId, pAction->uninstallMsiCompatiblePackage.pParentPackage->compatiblePackage.sczCacheId, pAction->uninstallMsiCompatiblePackage.sczLogPath, pAction->uninstallMsiCompatiblePackage.dwLoggingAttributes);
2667 break;
2668
2625 case BURN_EXECUTE_ACTION_TYPE_MSP_TARGET: 2669 case BURN_EXECUTE_ACTION_TYPE_MSP_TARGET:
2626 LogStringLine(PlanDumpLevel, "%ls action[%u]: MSP_TARGET package id: %ls, action: %hs, target product code: %ls, target per-machine: %hs, action msi property: %ls, ui level: %u, disable externaluihandler: %hs, file versioning: %hs, log path: %ls", wzBase, iAction, pAction->mspTarget.pPackage->sczId, LoggingActionStateToString(pAction->mspTarget.action), pAction->mspTarget.sczTargetProductCode, LoggingBoolToString(pAction->mspTarget.fPerMachineTarget), LoggingBurnMsiPropertyToString(pAction->mspTarget.actionMsiProperty), pAction->mspTarget.uiLevel, LoggingBoolToString(pAction->mspTarget.fDisableExternalUiHandler), LoggingMsiFileVersioningToString(pAction->mspTarget.fileVersioning), pAction->mspTarget.sczLogPath); 2670 LogStringLine(PlanDumpLevel, "%ls action[%u]: MSP_TARGET package id: %ls, action: %hs, target product code: %ls, target per-machine: %hs, action msi property: %ls, ui level: %u, disable externaluihandler: %hs, file versioning: %hs, log path: %ls", wzBase, iAction, pAction->mspTarget.pPackage->sczId, LoggingActionStateToString(pAction->mspTarget.action), pAction->mspTarget.sczTargetProductCode, LoggingBoolToString(pAction->mspTarget.fPerMachineTarget), LoggingBurnMsiPropertyToString(pAction->mspTarget.actionMsiProperty), pAction->mspTarget.uiLevel, LoggingBoolToString(pAction->mspTarget.fDisableExternalUiHandler), LoggingMsiFileVersioningToString(pAction->mspTarget.fileVersioning), pAction->mspTarget.sczLogPath);
2627 for (DWORD j = 0; j < pAction->mspTarget.cOrderedPatches; ++j) 2671 for (DWORD j = 0; j < pAction->mspTarget.cOrderedPatches; ++j)
@@ -2669,6 +2713,27 @@ static void ExecuteActionLog(
2669 } 2713 }
2670} 2714}
2671 2715
2716static void CleanActionLog(
2717 __in DWORD iAction,
2718 __in BURN_CLEAN_ACTION* pAction
2719 )
2720{
2721 switch (pAction->type)
2722 {
2723 case BURN_CLEAN_ACTION_TYPE_COMPATIBLE_PACKAGE:
2724 LogStringLine(PlanDumpLevel, " Clean action[%u]: CLEAN_COMPATIBLE_PACKAGE package id: %ls", iAction, pAction->pPackage->sczId);
2725 break;
2726
2727 case BURN_CLEAN_ACTION_TYPE_PACKAGE:
2728 LogStringLine(PlanDumpLevel, " Clean action[%u]: CLEAN_PACKAGE package id: %ls", iAction, pAction->pPackage->sczId);
2729 break;
2730
2731 default:
2732 AssertSz(FALSE, "Unknown clean action type.");
2733 break;
2734 }
2735}
2736
2672extern "C" void PlanDump( 2737extern "C" void PlanDump(
2673 __in BURN_PLAN* pPlan 2738 __in BURN_PLAN* pPlan
2674 ) 2739 )
@@ -2709,7 +2774,7 @@ extern "C" void PlanDump(
2709 2774
2710 for (DWORD i = 0; i < pPlan->cCleanActions; ++i) 2775 for (DWORD i = 0; i < pPlan->cCleanActions; ++i)
2711 { 2776 {
2712 LogStringLine(PlanDumpLevel, " Clean action[%u]: CLEAN_PACKAGE package id: %ls", i, pPlan->rgCleanActions[i].pPackage->sczId); 2777 CleanActionLog(i, pPlan->rgCleanActions + i);
2713 } 2778 }
2714 2779
2715 for (DWORD i = 0; i < pPlan->cPlannedProviders; ++i) 2780 for (DWORD i = 0; i < pPlan->cPlannedProviders; ++i)