diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-01-05 21:51:00 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-01-06 23:02:07 -0600 |
commit | c2b00d75493798d9f2452d5e5014b14afcb14889 (patch) | |
tree | 7788e6a9caf38ff1e921112cd893e53cccb8efbf /src/burn/engine/relatedbundle.cpp | |
parent | 5b48edfd77da6a7f1c499ad30ea95b66f26ee56d (diff) | |
download | wix-c2b00d75493798d9f2452d5e5014b14afcb14889.tar.gz wix-c2b00d75493798d9f2452d5e5014b14afcb14889.tar.bz2 wix-c2b00d75493798d9f2452d5e5014b14afcb14889.zip |
Always run upgrade related bundles last.
#5128
Diffstat (limited to 'src/burn/engine/relatedbundle.cpp')
-rw-r--r-- | src/burn/engine/relatedbundle.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/burn/engine/relatedbundle.cpp b/src/burn/engine/relatedbundle.cpp index e2380aab..1eafef07 100644 --- a/src/burn/engine/relatedbundle.cpp +++ b/src/burn/engine/relatedbundle.cpp | |||
@@ -4,6 +4,11 @@ | |||
4 | 4 | ||
5 | // internal function declarations | 5 | // internal function declarations |
6 | 6 | ||
7 | static __callback int __cdecl CompareRelatedBundles( | ||
8 | __in void* pvContext, | ||
9 | __in const void* pvLeft, | ||
10 | __in const void* pvRight | ||
11 | ); | ||
7 | static HRESULT LoadIfRelatedBundle( | 12 | static HRESULT LoadIfRelatedBundle( |
8 | __in BOOL fPerMachine, | 13 | __in BOOL fPerMachine, |
9 | __in HKEY hkUninstallKey, | 14 | __in HKEY hkUninstallKey, |
@@ -128,9 +133,59 @@ LExit: | |||
128 | return hr; | 133 | return hr; |
129 | } | 134 | } |
130 | 135 | ||
136 | extern "C" void RelatedBundlesSort( | ||
137 | __in BURN_RELATED_BUNDLES* pRelatedBundles | ||
138 | ) | ||
139 | { | ||
140 | qsort_s(pRelatedBundles->rgRelatedBundles, pRelatedBundles->cRelatedBundles, sizeof(BURN_RELATED_BUNDLE), CompareRelatedBundles, NULL); | ||
141 | } | ||
142 | |||
131 | 143 | ||
132 | // internal helper functions | 144 | // internal helper functions |
133 | 145 | ||
146 | static __callback int __cdecl CompareRelatedBundles( | ||
147 | __in void* /*pvContext*/, | ||
148 | __in const void* pvLeft, | ||
149 | __in const void* pvRight | ||
150 | ) | ||
151 | { | ||
152 | int ret = 0; | ||
153 | const BURN_RELATED_BUNDLE* pBundleLeft = static_cast<const BURN_RELATED_BUNDLE*>(pvLeft); | ||
154 | const BURN_RELATED_BUNDLE* pBundleRight = static_cast<const BURN_RELATED_BUNDLE*>(pvRight); | ||
155 | |||
156 | // Sort by relation type, then version, then bundle id. | ||
157 | if (pBundleLeft->relationType != pBundleRight->relationType) | ||
158 | { | ||
159 | // Upgrade bundles last, everything else according to the enum. | ||
160 | if (BOOTSTRAPPER_RELATION_UPGRADE == pBundleLeft->relationType) | ||
161 | { | ||
162 | ret = 1; | ||
163 | } | ||
164 | else if (BOOTSTRAPPER_RELATION_UPGRADE == pBundleRight->relationType) | ||
165 | { | ||
166 | ret = -1; | ||
167 | } | ||
168 | else if (pBundleLeft->relationType < pBundleRight->relationType) | ||
169 | { | ||
170 | ret = -1; | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | ret = 1; | ||
175 | } | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | VerCompareParsedVersions(pBundleLeft->pVersion, pBundleRight->pVersion, &ret); | ||
180 | if (0 == ret) | ||
181 | { | ||
182 | ret = ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pBundleLeft->package.sczId, -1, pBundleRight->package.sczId, -1) - 2; | ||
183 | } | ||
184 | } | ||
185 | |||
186 | return ret; | ||
187 | } | ||
188 | |||
134 | static HRESULT LoadIfRelatedBundle( | 189 | static HRESULT LoadIfRelatedBundle( |
135 | __in BOOL fPerMachine, | 190 | __in BOOL fPerMachine, |
136 | __in HKEY hkUninstallKey, | 191 | __in HKEY hkUninstallKey, |