aboutsummaryrefslogtreecommitdiff
path: root/src/engine/detect.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-02-03 17:09:50 -0600
committerSean Hall <r.sean.hall@gmail.com>2021-02-04 22:16:10 -0600
commitc6c17104b50936432a3fe9ca214ba9a3dfa32780 (patch)
tree7ad23896fd7e1768a5f81ebb4dc2abe99718eadb /src/engine/detect.cpp
parentfd8c2b0899bfbce07386af245c04eb21dc01cbdf (diff)
downloadwix-c6c17104b50936432a3fe9ca214ba9a3dfa32780.tar.gz
wix-c6c17104b50936432a3fe9ca214ba9a3dfa32780.tar.bz2
wix-c6c17104b50936432a3fe9ca214ba9a3dfa32780.zip
Automatically uninstall the bundle after Quit if eligible.
For now, the requirements are: * The bundle is installed and * The bundle is per-user or has already elevated and * No non-permanent packages are installed and * No non-permanent packages are cached and * No related bundle would run by default during uninstall and * The bundle didn't Uninstall/Cache/Install/Modify/Repair and * The BA didn't opt out of this behavior
Diffstat (limited to 'src/engine/detect.cpp')
-rw-r--r--src/engine/detect.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/engine/detect.cpp b/src/engine/detect.cpp
index 159df3d0..b702306e 100644
--- a/src/engine/detect.cpp
+++ b/src/engine/detect.cpp
@@ -42,6 +42,7 @@ extern "C" void DetectReset(
42 pRegistration->fEnabledForwardCompatibleBundle = FALSE; 42 pRegistration->fEnabledForwardCompatibleBundle = FALSE;
43 PackageUninitialize(&pRegistration->forwardCompatibleBundle); 43 PackageUninitialize(&pRegistration->forwardCompatibleBundle);
44 pRegistration->fSelfRegisteredAsDependent = FALSE; 44 pRegistration->fSelfRegisteredAsDependent = FALSE;
45 pRegistration->fEligibleForCleanup = FALSE;
45 46
46 if (pRegistration->rgIgnoredDependencies) 47 if (pRegistration->rgIgnoredDependencies)
47 { 48 {
@@ -184,11 +185,14 @@ extern "C" HRESULT DetectReportRelatedBundles(
184 __in BURN_USER_EXPERIENCE* pUX, 185 __in BURN_USER_EXPERIENCE* pUX,
185 __in BURN_REGISTRATION* pRegistration, 186 __in BURN_REGISTRATION* pRegistration,
186 __in BOOTSTRAPPER_RELATION_TYPE relationType, 187 __in BOOTSTRAPPER_RELATION_TYPE relationType,
187 __in BOOTSTRAPPER_ACTION action 188 __in BOOTSTRAPPER_ACTION action,
189 __out BOOL* pfEligibleForCleanup
188 ) 190 )
189{ 191{
190 HRESULT hr = S_OK; 192 HRESULT hr = S_OK;
191 int nCompareResult = 0; 193 int nCompareResult = 0;
194 BOOTSTRAPPER_REQUEST_STATE uninstallRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE;
195 *pfEligibleForCleanup = pRegistration->fInstalled;
192 196
193 for (DWORD iRelatedBundle = 0; iRelatedBundle < pRegistration->relatedBundles.cRelatedBundles; ++iRelatedBundle) 197 for (DWORD iRelatedBundle = 0; iRelatedBundle < pRegistration->relatedBundles.cRelatedBundles; ++iRelatedBundle)
194 { 198 {
@@ -201,7 +205,7 @@ extern "C" HRESULT DetectReportRelatedBundles(
201 if (BOOTSTRAPPER_RELATION_UPGRADE != relationType && BOOTSTRAPPER_ACTION_UNINSTALL < action) 205 if (BOOTSTRAPPER_RELATION_UPGRADE != relationType && BOOTSTRAPPER_ACTION_UNINSTALL < action)
202 { 206 {
203 hr = VerCompareParsedVersions(pRegistration->pVersion, pRelatedBundle->pVersion, &nCompareResult); 207 hr = VerCompareParsedVersions(pRegistration->pVersion, pRelatedBundle->pVersion, &nCompareResult);
204 ExitOnFailure(hr, "Failed to compare bundle version '%ls' to related bundle version '%ls'", pRegistration->pVersion, pRelatedBundle->pVersion); 208 ExitOnFailure(hr, "Failed to compare bundle version '%ls' to related bundle version '%ls'", pRegistration->pVersion->sczVersion, pRelatedBundle->pVersion->sczVersion);
205 209
206 if (nCompareResult < 0) 210 if (nCompareResult < 0)
207 { 211 {
@@ -244,6 +248,19 @@ extern "C" HRESULT DetectReportRelatedBundles(
244 248
245 hr = UserExperienceOnDetectRelatedBundle(pUX, pRelatedBundle->package.sczId, pRelatedBundle->relationType, pRelatedBundle->sczTag, pRelatedBundle->package.fPerMachine, pRelatedBundle->pVersion, operation); 249 hr = UserExperienceOnDetectRelatedBundle(pUX, pRelatedBundle->package.sczId, pRelatedBundle->relationType, pRelatedBundle->sczTag, pRelatedBundle->package.fPerMachine, pRelatedBundle->pVersion, operation);
246 ExitOnRootFailure(hr, "BA aborted detect related bundle."); 250 ExitOnRootFailure(hr, "BA aborted detect related bundle.");
251
252 // For now, if any related bundles will be executed during uninstall by default then never automatically clean up the bundle.
253 if (*pfEligibleForCleanup)
254 {
255 uninstallRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE;
256 hr = PlanDefaultRelatedBundleRequestState(relationType, pRelatedBundle->relationType, BOOTSTRAPPER_ACTION_UNINSTALL, pRegistration->pVersion, pRelatedBundle->pVersion, &uninstallRequestState);
257 ExitOnFailure(hr, "Failed to get the default request state for related bundle for calculating fEligibleForCleanup");
258
259 if (BOOTSTRAPPER_REQUEST_STATE_NONE != uninstallRequestState)
260 {
261 *pfEligibleForCleanup = FALSE;
262 }
263 }
247 } 264 }
248 265
249LExit: 266LExit: