diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-02-03 17:09:50 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-02-04 22:16:10 -0600 |
commit | c6c17104b50936432a3fe9ca214ba9a3dfa32780 (patch) | |
tree | 7ad23896fd7e1768a5f81ebb4dc2abe99718eadb /src/engine/core.cpp | |
parent | fd8c2b0899bfbce07386af245c04eb21dc01cbdf (diff) | |
download | wix-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 '')
-rw-r--r-- | src/engine/core.cpp | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/src/engine/core.cpp b/src/engine/core.cpp index 36471e93..1503f8d8 100644 --- a/src/engine/core.cpp +++ b/src/engine/core.cpp | |||
@@ -300,7 +300,7 @@ extern "C" HRESULT CoreDetect( | |||
300 | ExitOnFailure(hr, "Failed to detect provider key bundle id."); | 300 | ExitOnFailure(hr, "Failed to detect provider key bundle id."); |
301 | 301 | ||
302 | // Report the related bundles. | 302 | // Report the related bundles. |
303 | hr = DetectReportRelatedBundles(&pEngineState->userExperience, &pEngineState->registration, pEngineState->command.relationType, pEngineState->command.action); | 303 | hr = DetectReportRelatedBundles(&pEngineState->userExperience, &pEngineState->registration, pEngineState->command.relationType, pEngineState->command.action, &pEngineState->registration.fEligibleForCleanup); |
304 | ExitOnFailure(hr, "Failed to report detected related bundles."); | 304 | ExitOnFailure(hr, "Failed to report detected related bundles."); |
305 | 305 | ||
306 | // Do update detection. | 306 | // Do update detection. |
@@ -344,6 +344,14 @@ extern "C" HRESULT CoreDetect( | |||
344 | { | 344 | { |
345 | pPackage = pEngineState->packages.rgPackages + iPackage; | 345 | pPackage = pEngineState->packages.rgPackages + iPackage; |
346 | 346 | ||
347 | // If any packages that can affect registration are present, then the bundle should not automatically be uninstalled. | ||
348 | if (pEngineState->registration.fEligibleForCleanup && pPackage->fCanAffectRegistration && | ||
349 | (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->cacheRegistrationState || | ||
350 | BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->installRegistrationState)) | ||
351 | { | ||
352 | pEngineState->registration.fEligibleForCleanup = FALSE; | ||
353 | } | ||
354 | |||
347 | LogId(REPORT_STANDARD, MSG_DETECTED_PACKAGE, pPackage->sczId, LoggingPackageStateToString(pPackage->currentState), LoggingCacheStateToString(pPackage->cache), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->installRegistrationState), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->cacheRegistrationState)); | 355 | LogId(REPORT_STANDARD, MSG_DETECTED_PACKAGE, pPackage->sczId, LoggingPackageStateToString(pPackage->currentState), LoggingCacheStateToString(pPackage->cache), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->installRegistrationState), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->cacheRegistrationState)); |
348 | 356 | ||
349 | if (BURN_PACKAGE_TYPE_MSI == pPackage->type) | 357 | if (BURN_PACKAGE_TYPE_MSI == pPackage->type) |
@@ -377,12 +385,12 @@ LExit: | |||
377 | 385 | ||
378 | if (fDetectBegan) | 386 | if (fDetectBegan) |
379 | { | 387 | { |
380 | UserExperienceOnDetectComplete(&pEngineState->userExperience, hr); | 388 | UserExperienceOnDetectComplete(&pEngineState->userExperience, hr, pEngineState->registration.fEligibleForCleanup); |
381 | } | 389 | } |
382 | 390 | ||
383 | pEngineState->userExperience.hwndDetect = NULL; | 391 | pEngineState->userExperience.hwndDetect = NULL; |
384 | 392 | ||
385 | LogId(REPORT_STANDARD, MSG_DETECT_COMPLETE, hr); | 393 | LogId(REPORT_STANDARD, MSG_DETECT_COMPLETE, hr, !fDetectBegan ? "(failed)" : LoggingBoolToString(pEngineState->registration.fInstalled), FAILED(hr) ? "(failed)" : LoggingBoolToString(pEngineState->registration.fEligibleForCleanup)); |
386 | 394 | ||
387 | return hr; | 395 | return hr; |
388 | } | 396 | } |
@@ -1053,6 +1061,54 @@ LExit: | |||
1053 | return hr; | 1061 | return hr; |
1054 | } | 1062 | } |
1055 | 1063 | ||
1064 | extern "C" HRESULT CoreCleanup( | ||
1065 | __in BURN_ENGINE_STATE* pEngineState | ||
1066 | ) | ||
1067 | { | ||
1068 | HRESULT hr = S_OK; | ||
1069 | LONGLONG llValue = 0; | ||
1070 | BOOL fNeedsElevation = pEngineState->registration.fPerMachine && INVALID_HANDLE_VALUE == pEngineState->companionConnection.hPipe; | ||
1071 | |||
1072 | if (fNeedsElevation) | ||
1073 | { | ||
1074 | hr = VariableGetNumeric(&pEngineState->variables, BURN_BUNDLE_ELEVATED, &llValue); | ||
1075 | ExitOnFailure(hr, "Failed to get value of WixBundleElevated variable during cleanup"); | ||
1076 | |||
1077 | if (llValue) | ||
1078 | { | ||
1079 | fNeedsElevation = FALSE; | ||
1080 | } | ||
1081 | } | ||
1082 | |||
1083 | if (pEngineState->fApplied && BOOTSTRAPPER_ACTION_LAYOUT < pEngineState->plan.action && BOOTSTRAPPER_ACTION_UPDATE_REPLACE > pEngineState->plan.action || | ||
1084 | fNeedsElevation) | ||
1085 | { | ||
1086 | ExitFunction(); | ||
1087 | } | ||
1088 | |||
1089 | if (!pEngineState->fDetected) | ||
1090 | { | ||
1091 | hr = CoreDetect(pEngineState, pEngineState->hMessageWindow); | ||
1092 | ExitOnFailure(hr, "Detect during cleanup failed"); | ||
1093 | } | ||
1094 | |||
1095 | if (!pEngineState->registration.fEligibleForCleanup) | ||
1096 | { | ||
1097 | ExitFunction(); | ||
1098 | } | ||
1099 | |||
1100 | hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); | ||
1101 | ExitOnFailure(hr, "Plan during cleanup failed"); | ||
1102 | |||
1103 | hr = CoreApply(pEngineState, pEngineState->hMessageWindow); | ||
1104 | ExitOnFailure(hr, "Apply during cleanup failed"); | ||
1105 | |||
1106 | // Need to think about cache=always | ||
1107 | |||
1108 | LExit: | ||
1109 | return hr; | ||
1110 | } | ||
1111 | |||
1056 | // internal helper functions | 1112 | // internal helper functions |
1057 | 1113 | ||
1058 | static HRESULT ParseCommandLine( | 1114 | static HRESULT ParseCommandLine( |