aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine/plan.cpp
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2026-02-17 19:41:03 -0500
committerBob Arnson <bob@firegiant.com>2026-02-17 19:48:12 -0500
commit5658492062bf28ffb670ede15cbd1413bf1182d8 (patch)
tree7e959881fdabed13359ff8cb78e68d9c74b81931 /src/burn/engine/plan.cpp
parentde80ff1102a1b34e430bbc718fe65a42bab196cf (diff)
downloadwix-5658492062bf28ffb670ede15cbd1413bf1182d8.tar.gz
wix-5658492062bf28ffb670ede15cbd1413bf1182d8.tar.bz2
wix-5658492062bf28ffb670ede15cbd1413bf1182d8.zip
Lock upgrade bundles to original bundle's scope.bob/BundleLockUpgradeScope
Fixes https://github.com/wixtoolset/issues/issues/9236
Diffstat (limited to 'src/burn/engine/plan.cpp')
-rw-r--r--src/burn/engine/plan.cpp57
1 files changed, 56 insertions, 1 deletions
diff --git a/src/burn/engine/plan.cpp b/src/burn/engine/plan.cpp
index 889ad68c..2257b28c 100644
--- a/src/burn/engine/plan.cpp
+++ b/src/burn/engine/plan.cpp
@@ -144,6 +144,12 @@ static BOOL ForceCache(
144 __in BURN_PLAN* pPlan, 144 __in BURN_PLAN* pPlan,
145 __in BURN_PACKAGE* pPackage 145 __in BURN_PACKAGE* pPackage
146 ); 146 );
147static HRESULT GetUpgradedBundleScope(
148 __in DWORD cRelatedBundles,
149 __in BURN_RELATED_BUNDLE* rgRelatedBundles,
150 __in_z LPCWSTR wzUpgradeCode,
151 __inout BOOTSTRAPPER_SCOPE* pScope
152);
147 153
148// function definitions 154// function definitions
149 155
@@ -823,6 +829,9 @@ LExit:
823extern "C" HRESULT PlanPackagesAndBundleScope( 829extern "C" HRESULT PlanPackagesAndBundleScope(
824 __in BURN_PACKAGE* rgPackages, 830 __in BURN_PACKAGE* rgPackages,
825 __in DWORD cPackages, 831 __in DWORD cPackages,
832 __in_z LPCWSTR wzUpgradeCode,
833 __in BURN_RELATED_BUNDLE* rgRelatedBundles,
834 __in DWORD cRelatedBundles,
826 __in BOOTSTRAPPER_SCOPE scope, 835 __in BOOTSTRAPPER_SCOPE scope,
827 __in BOOTSTRAPPER_PACKAGE_SCOPE authoredScope, 836 __in BOOTSTRAPPER_PACKAGE_SCOPE authoredScope,
828 __in BOOTSTRAPPER_SCOPE commandLineScope, 837 __in BOOTSTRAPPER_SCOPE commandLineScope,
@@ -855,7 +864,11 @@ extern "C" HRESULT PlanPackagesAndBundleScope(
855 } 864 }
856 } 865 }
857 866
858 if (BOOTSTRAPPER_SCOPE_DEFAULT != detectedScope) 867 // If we're upgrading, lock the scope to that of the upgraded bundle.
868 hr = GetUpgradedBundleScope(cRelatedBundles, rgRelatedBundles, wzUpgradeCode, &scope);
869
870 // If we're in maintenance mode instead, lock the scope to the original scope.
871 if (S_FALSE == hr && BOOTSTRAPPER_SCOPE_DEFAULT != detectedScope)
859 { 872 {
860 scope = detectedScope; 873 scope = detectedScope;
861 874
@@ -888,6 +901,48 @@ extern "C" HRESULT PlanPackagesAndBundleScope(
888} 901}
889 902
890 903
904static HRESULT GetUpgradedBundleScope(
905 __in DWORD cRelatedBundles,
906 __in BURN_RELATED_BUNDLE* rgRelatedBundles,
907 __in_z LPCWSTR wzUpgradeCode,
908 __inout BOOTSTRAPPER_SCOPE* pScope
909 )
910{
911 HRESULT hr = S_OK;
912
913 for (DWORD i = 0; i < cRelatedBundles; ++i)
914 {
915 BURN_RELATED_BUNDLE* pRelatedBundle = rgRelatedBundles + i;
916
917 if (BOOTSTRAPPER_RELATION_UPGRADE == pRelatedBundle->detectRelationType)
918 {
919 for (DWORD j = 0; j < pRelatedBundle->package.Bundle.cUpgradeCodes; ++j)
920 {
921 LPCWSTR wzRelatedUpgradeCode = *(pRelatedBundle->package.Bundle.rgsczUpgradeCodes + j);
922
923 // Is the related bundle's upgrade code the same as ours?
924 // If so, lock our scope to the "original" bundle's scope.
925 if (CSTR_EQUAL == ::CompareStringOrdinal(wzRelatedUpgradeCode, -1, wzUpgradeCode, -1, FALSE))
926 if (CSTR_EQUAL == ::CompareStringOrdinal(wzRelatedUpgradeCode, -1, wzUpgradeCode, -1, TRUE))
927 {
928 *pScope = pRelatedBundle->detectedScope;
929
930 LogId(REPORT_STANDARD, MSG_PLAN_UPGRADE_SCOPE, pRelatedBundle->package.Bundle.sczBundleCode, LoggingBundleScopeToString(*pScope));
931
932 ExitFunction();
933 }
934 }
935 }
936 }
937
938 // No upgrade codes or none match, which is fine. But note it via S_FALSE
939 // so we can distinguish the upgrade case from the maintenance case.
940 hr = S_FALSE;
941
942LExit:
943 return hr;
944}
945
891static HRESULT PlanPackagesHelper( 946static HRESULT PlanPackagesHelper(
892 __in BURN_PACKAGE* rgPackages, 947 __in BURN_PACKAGE* rgPackages,
893 __in DWORD cPackages, 948 __in DWORD cPackages,