diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-02-18 10:44:49 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-02-22 20:25:06 -0600 |
| commit | b29af5d005c2cc802aa60a123d435042038ba8ef (patch) | |
| tree | cb86e61b6abb327f8e1ebc33162acfca28bb89e9 /src/engine/plan.cpp | |
| parent | dbd55be5e707f07eb044c8c7f13c3dfd246148c0 (diff) | |
| download | wix-b29af5d005c2cc802aa60a123d435042038ba8ef.tar.gz wix-b29af5d005c2cc802aa60a123d435042038ba8ef.tar.bz2 wix-b29af5d005c2cc802aa60a123d435042038ba8ef.zip | |
Get all request states up front before building the plan.
Diffstat (limited to 'src/engine/plan.cpp')
| -rw-r--r-- | src/engine/plan.cpp | 256 |
1 files changed, 167 insertions, 89 deletions
diff --git a/src/engine/plan.cpp b/src/engine/plan.cpp index 99c87163..29adfb42 100644 --- a/src/engine/plan.cpp +++ b/src/engine/plan.cpp | |||
| @@ -21,6 +21,26 @@ static void ResetPlannedPackageState( | |||
| 21 | static void ResetPlannedRollbackBoundaryState( | 21 | static void ResetPlannedRollbackBoundaryState( |
| 22 | __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary | 22 | __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary |
| 23 | ); | 23 | ); |
| 24 | static HRESULT PlanPackagesHelper( | ||
| 25 | __in BURN_PACKAGE* rgPackages, | ||
| 26 | __in DWORD cPackages, | ||
| 27 | __in BOOL fPlanCleanPackages, | ||
| 28 | __in BURN_USER_EXPERIENCE* pUX, | ||
| 29 | __in BURN_PLAN* pPlan, | ||
| 30 | __in BURN_LOGGING* pLog, | ||
| 31 | __in BURN_VARIABLES* pVariables, | ||
| 32 | __in BOOTSTRAPPER_DISPLAY display, | ||
| 33 | __in BOOTSTRAPPER_RELATION_TYPE relationType, | ||
| 34 | __in_z_opt LPCWSTR wzLayoutDirectory, | ||
| 35 | __inout HANDLE* phSyncpointEvent | ||
| 36 | ); | ||
| 37 | static HRESULT InitializePackage( | ||
| 38 | __in BURN_PLAN* pPlan, | ||
| 39 | __in BURN_USER_EXPERIENCE* pUX, | ||
| 40 | __in BURN_VARIABLES* pVariables, | ||
| 41 | __in BURN_PACKAGE* pPackage, | ||
| 42 | __in BOOTSTRAPPER_RELATION_TYPE relationType | ||
| 43 | ); | ||
| 24 | static HRESULT ProcessPackage( | 44 | static HRESULT ProcessPackage( |
| 25 | __in BOOL fBundlePerMachine, | 45 | __in BOOL fBundlePerMachine, |
| 26 | __in BURN_USER_EXPERIENCE* pUX, | 46 | __in BURN_USER_EXPERIENCE* pUX, |
| @@ -29,7 +49,6 @@ static HRESULT ProcessPackage( | |||
| 29 | __in BURN_LOGGING* pLog, | 49 | __in BURN_LOGGING* pLog, |
| 30 | __in BURN_VARIABLES* pVariables, | 50 | __in BURN_VARIABLES* pVariables, |
| 31 | __in BOOTSTRAPPER_DISPLAY display, | 51 | __in BOOTSTRAPPER_DISPLAY display, |
| 32 | __in BOOTSTRAPPER_RELATION_TYPE relationType, | ||
| 33 | __in_z_opt LPCWSTR wzLayoutDirectory, | 52 | __in_z_opt LPCWSTR wzLayoutDirectory, |
| 34 | __inout HANDLE* phSyncpointEvent, | 53 | __inout HANDLE* phSyncpointEvent, |
| 35 | __inout BURN_ROLLBACK_BOUNDARY** ppRollbackBoundary | 54 | __inout BURN_ROLLBACK_BOUNDARY** ppRollbackBoundary |
| @@ -146,9 +165,7 @@ static HRESULT PlanDependencyActions( | |||
| 146 | __in BURN_PACKAGE* pPackage | 165 | __in BURN_PACKAGE* pPackage |
| 147 | ); | 166 | ); |
| 148 | static HRESULT CalculateExecuteActions( | 167 | static HRESULT CalculateExecuteActions( |
| 149 | __in BURN_USER_EXPERIENCE* pUserExperience, | ||
| 150 | __in BURN_PACKAGE* pPackage, | 168 | __in BURN_PACKAGE* pPackage, |
| 151 | __in BURN_VARIABLES* pVariables, | ||
| 152 | __in_opt BURN_ROLLBACK_BOUNDARY* pActiveRollbackBoundary, | 169 | __in_opt BURN_ROLLBACK_BOUNDARY* pActiveRollbackBoundary, |
| 153 | __out_opt BOOL* pfBARequestedCache | 170 | __out_opt BOOL* pfBARequestedCache |
| 154 | ); | 171 | ); |
| @@ -324,15 +341,13 @@ extern "C" HRESULT PlanDefaultPackageRequestState( | |||
| 324 | __in BOOL fPermanent, | 341 | __in BOOL fPermanent, |
| 325 | __in BURN_CACHE_TYPE cacheType, | 342 | __in BURN_CACHE_TYPE cacheType, |
| 326 | __in BOOTSTRAPPER_ACTION action, | 343 | __in BOOTSTRAPPER_ACTION action, |
| 327 | __in BURN_VARIABLES* pVariables, | 344 | __in BOOL fInstallCondition, |
| 328 | __in_z_opt LPCWSTR wzInstallCondition, | ||
| 329 | __in BOOTSTRAPPER_RELATION_TYPE relationType, | 345 | __in BOOTSTRAPPER_RELATION_TYPE relationType, |
| 330 | __out BOOTSTRAPPER_REQUEST_STATE* pRequestState | 346 | __out BOOTSTRAPPER_REQUEST_STATE* pRequestState |
| 331 | ) | 347 | ) |
| 332 | { | 348 | { |
| 333 | HRESULT hr = S_OK; | 349 | HRESULT hr = S_OK; |
| 334 | BOOTSTRAPPER_REQUEST_STATE defaultRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; | 350 | BOOTSTRAPPER_REQUEST_STATE defaultRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; |
| 335 | BOOL fCondition = FALSE; | ||
| 336 | BOOL fFallbackToCache = BURN_CACHE_TYPE_ALWAYS == cacheType && BOOTSTRAPPER_ACTION_UNINSTALL != action && BOOTSTRAPPER_PACKAGE_STATE_CACHED > currentState; | 351 | BOOL fFallbackToCache = BURN_CACHE_TYPE_ALWAYS == cacheType && BOOTSTRAPPER_ACTION_UNINSTALL != action && BOOTSTRAPPER_PACKAGE_STATE_CACHED > currentState; |
| 337 | 352 | ||
| 338 | // If doing layout, then always default to requesting the file be cached. | 353 | // If doing layout, then always default to requesting the file be cached. |
| @@ -373,14 +388,11 @@ extern "C" HRESULT PlanDefaultPackageRequestState( | |||
| 373 | hr = GetActionDefaultRequestState(action, fPermanent, currentState, &defaultRequestState); | 388 | hr = GetActionDefaultRequestState(action, fPermanent, currentState, &defaultRequestState); |
| 374 | ExitOnFailure(hr, "Failed to get default request state for action."); | 389 | ExitOnFailure(hr, "Failed to get default request state for action."); |
| 375 | 390 | ||
| 376 | // If there is an install condition (and we're doing an install) evaluate the condition | 391 | // If we're doing an install, use the install condition |
| 377 | // to determine whether to use the default request state or make the package absent. | 392 | // to determine whether to use the default request state or make the package absent. |
| 378 | if (BOOTSTRAPPER_ACTION_UNINSTALL != action && wzInstallCondition && *wzInstallCondition) | 393 | if (BOOTSTRAPPER_ACTION_UNINSTALL != action && !fInstallCondition) |
| 379 | { | 394 | { |
| 380 | hr = ConditionEvaluate(pVariables, wzInstallCondition, &fCondition); | 395 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_ABSENT; |
| 381 | ExitOnFailure(hr, "Failed to evaluate install condition."); | ||
| 382 | |||
| 383 | *pRequestState = fCondition ? defaultRequestState : BOOTSTRAPPER_REQUEST_STATE_ABSENT; | ||
| 384 | } | 396 | } |
| 385 | else // just set the package to the default request state. | 397 | else // just set the package to the default request state. |
| 386 | { | 398 | { |
| @@ -475,13 +487,11 @@ LExit: | |||
| 475 | } | 487 | } |
| 476 | 488 | ||
| 477 | extern "C" HRESULT PlanPackages( | 489 | extern "C" HRESULT PlanPackages( |
| 478 | __in BURN_REGISTRATION* /*pRegistration*/, | ||
| 479 | __in BURN_USER_EXPERIENCE* pUX, | 490 | __in BURN_USER_EXPERIENCE* pUX, |
| 480 | __in BURN_PACKAGES* pPackages, | 491 | __in BURN_PACKAGES* pPackages, |
| 481 | __in BURN_PLAN* pPlan, | 492 | __in BURN_PLAN* pPlan, |
| 482 | __in BURN_LOGGING* pLog, | 493 | __in BURN_LOGGING* pLog, |
| 483 | __in BURN_VARIABLES* pVariables, | 494 | __in BURN_VARIABLES* pVariables, |
| 484 | __in BOOL /*fBundleInstalled*/, | ||
| 485 | __in BOOTSTRAPPER_DISPLAY display, | 495 | __in BOOTSTRAPPER_DISPLAY display, |
| 486 | __in BOOTSTRAPPER_RELATION_TYPE relationType, | 496 | __in BOOTSTRAPPER_RELATION_TYPE relationType, |
| 487 | __in_z_opt LPCWSTR wzLayoutDirectory, | 497 | __in_z_opt LPCWSTR wzLayoutDirectory, |
| @@ -489,39 +499,9 @@ extern "C" HRESULT PlanPackages( | |||
| 489 | ) | 499 | ) |
| 490 | { | 500 | { |
| 491 | HRESULT hr = S_OK; | 501 | HRESULT hr = S_OK; |
| 492 | BOOL fBundlePerMachine = pPlan->fPerMachine; // bundle is per-machine if plan starts per-machine. | 502 | |
| 493 | BURN_ROLLBACK_BOUNDARY* pRollbackBoundary = NULL; | 503 | hr = PlanPackagesHelper(pPackages->rgPackages, pPackages->cPackages, TRUE, pUX, pPlan, pLog, pVariables, display, relationType, wzLayoutDirectory, phSyncpointEvent); |
| 494 | |||
| 495 | // Plan the packages. | ||
| 496 | for (DWORD i = 0; i < pPackages->cPackages; ++i) | ||
| 497 | { | ||
| 498 | DWORD iPackage = (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) ? pPackages->cPackages - 1 - i : i; | ||
| 499 | BURN_PACKAGE* pPackage = pPackages->rgPackages + iPackage; | ||
| 500 | |||
| 501 | hr = ProcessPackage(fBundlePerMachine, pUX, pPlan, pPackage, pLog, pVariables, display, relationType, wzLayoutDirectory, phSyncpointEvent, &pRollbackBoundary); | ||
| 502 | ExitOnFailure(hr, "Failed to process package."); | ||
| 503 | } | ||
| 504 | 504 | ||
| 505 | // If we still have an open rollback boundary, complete it. | ||
| 506 | if (pRollbackBoundary) | ||
| 507 | { | ||
| 508 | hr = PlanRollbackBoundaryComplete(pPlan); | ||
| 509 | ExitOnFailure(hr, "Failed to plan rollback boundary begin."); | ||
| 510 | |||
| 511 | pRollbackBoundary = NULL; | ||
| 512 | } | ||
| 513 | |||
| 514 | // Plan clean up of packages. | ||
| 515 | for (DWORD i = 0; i < pPackages->cPackages; ++i) | ||
| 516 | { | ||
| 517 | DWORD iPackage = (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) ? pPackages->cPackages - 1 - i : i; | ||
| 518 | BURN_PACKAGE* pPackage = pPackages->rgPackages + iPackage; | ||
| 519 | |||
| 520 | hr = PlanCleanPackage(pPlan, pPackage); | ||
| 521 | ExitOnFailure(hr, "Failed to plan clean package."); | ||
| 522 | } | ||
| 523 | |||
| 524 | LExit: | ||
| 525 | return hr; | 505 | return hr; |
| 526 | } | 506 | } |
| 527 | 507 | ||
| @@ -735,24 +715,13 @@ extern "C" HRESULT PlanPassThroughBundle( | |||
| 735 | ) | 715 | ) |
| 736 | { | 716 | { |
| 737 | HRESULT hr = S_OK; | 717 | HRESULT hr = S_OK; |
| 738 | BOOL fBundlePerMachine = pPlan->fPerMachine; // bundle is per-machine if plan starts per-machine. | ||
| 739 | BURN_ROLLBACK_BOUNDARY* pRollbackBoundary = NULL; | ||
| 740 | 718 | ||
| 741 | // Plan passthrough package. | 719 | // Plan passthrough package. |
| 742 | hr = ProcessPackage(fBundlePerMachine, pUX, pPlan, pPackage, pLog, pVariables, display, relationType, NULL, phSyncpointEvent, &pRollbackBoundary); | 720 | // Passthrough packages are never cleaned up by the calling bundle (they delete themselves when appropriate) |
| 721 | // so we don't need to plan clean up. | ||
| 722 | hr = PlanPackagesHelper(pPackage, 1, FALSE, pUX, pPlan, pLog, pVariables, display, relationType, NULL, phSyncpointEvent); | ||
| 743 | ExitOnFailure(hr, "Failed to process passthrough package."); | 723 | ExitOnFailure(hr, "Failed to process passthrough package."); |
| 744 | 724 | ||
| 745 | // If we still have an open rollback boundary, complete it. | ||
| 746 | if (pRollbackBoundary) | ||
| 747 | { | ||
| 748 | hr = PlanRollbackBoundaryComplete(pPlan); | ||
| 749 | ExitOnFailure(hr, "Failed to plan rollback boundary for passthrough package."); | ||
| 750 | } | ||
| 751 | |||
| 752 | // Notice that the PlanCleanPackage() function is purposefully missing here. Passthrough packages | ||
| 753 | // are never cleaned up by the calling bundle (they delete themselves when appropriate) so we don't | ||
| 754 | // need to plan clean up. | ||
| 755 | |||
| 756 | LExit: | 725 | LExit: |
| 757 | return hr; | 726 | return hr; |
| 758 | } | 727 | } |
| @@ -769,28 +738,152 @@ extern "C" HRESULT PlanUpdateBundle( | |||
| 769 | ) | 738 | ) |
| 770 | { | 739 | { |
| 771 | HRESULT hr = S_OK; | 740 | HRESULT hr = S_OK; |
| 772 | BOOL fBundlePerMachine = pPlan->fPerMachine; // bundle is per-machine if plan starts per-machine. | ||
| 773 | BURN_ROLLBACK_BOUNDARY* pRollbackBoundary = NULL; | ||
| 774 | 741 | ||
| 775 | // Plan update package. | 742 | // Plan update package. |
| 776 | hr = ProcessPackage(fBundlePerMachine, pUX, pPlan, pPackage, pLog, pVariables, display, relationType, NULL, phSyncpointEvent, &pRollbackBoundary); | 743 | hr = PlanPackagesHelper(pPackage, 1, TRUE, pUX, pPlan, pLog, pVariables, display, relationType, NULL, phSyncpointEvent); |
| 777 | ExitOnFailure(hr, "Failed to process update package."); | 744 | ExitOnFailure(hr, "Failed to process update package."); |
| 778 | 745 | ||
| 746 | LExit: | ||
| 747 | return hr; | ||
| 748 | } | ||
| 749 | |||
| 750 | static HRESULT PlanPackagesHelper( | ||
| 751 | __in BURN_PACKAGE* rgPackages, | ||
| 752 | __in DWORD cPackages, | ||
| 753 | __in BOOL fPlanCleanPackages, | ||
| 754 | __in BURN_USER_EXPERIENCE* pUX, | ||
| 755 | __in BURN_PLAN* pPlan, | ||
| 756 | __in BURN_LOGGING* pLog, | ||
| 757 | __in BURN_VARIABLES* pVariables, | ||
| 758 | __in BOOTSTRAPPER_DISPLAY display, | ||
| 759 | __in BOOTSTRAPPER_RELATION_TYPE relationType, | ||
| 760 | __in_z_opt LPCWSTR wzLayoutDirectory, | ||
| 761 | __inout HANDLE* phSyncpointEvent | ||
| 762 | ) | ||
| 763 | { | ||
| 764 | HRESULT hr = S_OK; | ||
| 765 | BOOL fBundlePerMachine = pPlan->fPerMachine; // bundle is per-machine if plan starts per-machine. | ||
| 766 | BURN_ROLLBACK_BOUNDARY* pRollbackBoundary = NULL; | ||
| 767 | |||
| 768 | // Initialize the packages. | ||
| 769 | for (DWORD i = 0; i < cPackages; ++i) | ||
| 770 | { | ||
| 771 | DWORD iPackage = (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) ? cPackages - 1 - i : i; | ||
| 772 | BURN_PACKAGE* pPackage = rgPackages + iPackage; | ||
| 773 | |||
| 774 | hr = InitializePackage(pPlan, pUX, pVariables, pPackage, relationType); | ||
| 775 | ExitOnFailure(hr, "Failed to initialize package."); | ||
| 776 | } | ||
| 777 | |||
| 778 | // Initialize the patch targets after all packages, since they could rely on the requested state of packages that are after the patch's package in the chain. | ||
| 779 | for (DWORD i = 0; i < cPackages; ++i) | ||
| 780 | { | ||
| 781 | DWORD iPackage = (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) ? cPackages - 1 - i : i; | ||
| 782 | BURN_PACKAGE* pPackage = rgPackages + iPackage; | ||
| 783 | |||
| 784 | if (BURN_PACKAGE_TYPE_MSP == pPackage->type) | ||
| 785 | { | ||
| 786 | hr = MspEnginePlanInitializePackage(pPackage, pUX); | ||
| 787 | ExitOnFailure(hr, "Failed to initialize plan package: %ls", pPackage->sczId); | ||
| 788 | } | ||
| 789 | } | ||
| 790 | |||
| 791 | // Plan the packages. | ||
| 792 | for (DWORD i = 0; i < cPackages; ++i) | ||
| 793 | { | ||
| 794 | DWORD iPackage = (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) ? cPackages - 1 - i : i; | ||
| 795 | BURN_PACKAGE* pPackage = rgPackages + iPackage; | ||
| 796 | |||
| 797 | hr = ProcessPackage(fBundlePerMachine, pUX, pPlan, pPackage, pLog, pVariables, display, wzLayoutDirectory, phSyncpointEvent, &pRollbackBoundary); | ||
| 798 | ExitOnFailure(hr, "Failed to process package."); | ||
| 799 | } | ||
| 800 | |||
| 779 | // If we still have an open rollback boundary, complete it. | 801 | // If we still have an open rollback boundary, complete it. |
| 780 | if (pRollbackBoundary) | 802 | if (pRollbackBoundary) |
| 781 | { | 803 | { |
| 782 | hr = PlanRollbackBoundaryComplete(pPlan); | 804 | hr = PlanRollbackBoundaryComplete(pPlan); |
| 783 | ExitOnFailure(hr, "Failed to plan rollback boundary for update package."); | 805 | ExitOnFailure(hr, "Failed to plan final rollback boundary complete."); |
| 806 | |||
| 807 | pRollbackBoundary = NULL; | ||
| 784 | } | 808 | } |
| 785 | 809 | ||
| 786 | // Plan clean up of update package. | 810 | if (fPlanCleanPackages) |
| 787 | hr = PlanCleanPackage(pPlan, pPackage); | 811 | { |
| 788 | ExitOnFailure(hr, "Failed to plan clean of update package."); | 812 | // Plan clean up of packages. |
| 813 | for (DWORD i = 0; i < cPackages; ++i) | ||
| 814 | { | ||
| 815 | DWORD iPackage = (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) ? cPackages - 1 - i : i; | ||
| 816 | BURN_PACKAGE* pPackage = rgPackages + iPackage; | ||
| 817 | |||
| 818 | hr = PlanCleanPackage(pPlan, pPackage); | ||
| 819 | ExitOnFailure(hr, "Failed to plan clean package."); | ||
| 820 | } | ||
| 821 | } | ||
| 822 | |||
| 823 | // Remove unnecessary actions. | ||
| 824 | hr = PlanFinalizeActions(pPlan); | ||
| 825 | ExitOnFailure(hr, "Failed to remove unnecessary actions from plan."); | ||
| 826 | |||
| 827 | // Let the BA know the actions that were planned. | ||
| 828 | for (DWORD i = 0; i < cPackages; ++i) | ||
| 829 | { | ||
| 830 | DWORD iPackage = (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) ? cPackages - 1 - i : i; | ||
| 831 | BURN_PACKAGE* pPackage = rgPackages + iPackage; | ||
| 832 | |||
| 833 | UserExperienceOnPlannedPackage(pUX, pPackage->sczId, pPackage->execute, pPackage->rollback); | ||
| 834 | } | ||
| 789 | 835 | ||
| 790 | LExit: | 836 | LExit: |
| 791 | return hr; | 837 | return hr; |
| 792 | } | 838 | } |
| 793 | 839 | ||
| 840 | static HRESULT InitializePackage( | ||
| 841 | __in BURN_PLAN* pPlan, | ||
| 842 | __in BURN_USER_EXPERIENCE* pUX, | ||
| 843 | __in BURN_VARIABLES* pVariables, | ||
| 844 | __in BURN_PACKAGE* pPackage, | ||
| 845 | __in BOOTSTRAPPER_RELATION_TYPE relationType | ||
| 846 | ) | ||
| 847 | { | ||
| 848 | HRESULT hr = S_OK; | ||
| 849 | BOOL fInstallCondition = FALSE; | ||
| 850 | BOOL fBeginCalled = FALSE; | ||
| 851 | |||
| 852 | if (pPackage->sczInstallCondition && *pPackage->sczInstallCondition) | ||
| 853 | { | ||
| 854 | hr = ConditionEvaluate(pVariables, pPackage->sczInstallCondition, &fInstallCondition); | ||
| 855 | ExitOnFailure(hr, "Failed to evaluate install condition."); | ||
| 856 | } | ||
| 857 | else | ||
| 858 | { | ||
| 859 | fInstallCondition = TRUE; | ||
| 860 | } | ||
| 861 | |||
| 862 | // Remember the default requested state so the engine doesn't get blamed for planning the wrong thing if the BA changes it. | ||
| 863 | hr = PlanDefaultPackageRequestState(pPackage->type, pPackage->currentState, !pPackage->fUninstallable, pPackage->cacheType, pPlan->action, fInstallCondition, relationType, &pPackage->defaultRequested); | ||
| 864 | ExitOnFailure(hr, "Failed to set default package state."); | ||
| 865 | |||
| 866 | pPackage->requested = pPackage->defaultRequested; | ||
| 867 | fBeginCalled = TRUE; | ||
| 868 | |||
| 869 | hr = UserExperienceOnPlanPackageBegin(pUX, pPackage->sczId, pPackage->currentState, fInstallCondition, &pPackage->requested); | ||
| 870 | ExitOnRootFailure(hr, "BA aborted plan package begin."); | ||
| 871 | |||
| 872 | if (BURN_PACKAGE_TYPE_MSI == pPackage->type) | ||
| 873 | { | ||
| 874 | hr = MsiEnginePlanInitializePackage(pPackage, pVariables, pUX); | ||
| 875 | ExitOnFailure(hr, "Failed to initialize plan package: %ls", pPackage->sczId); | ||
| 876 | } | ||
| 877 | |||
| 878 | LExit: | ||
| 879 | if (fBeginCalled) | ||
| 880 | { | ||
| 881 | UserExperienceOnPlanPackageComplete(pUX, pPackage->sczId, hr, pPackage->requested); | ||
| 882 | } | ||
| 883 | |||
| 884 | return hr; | ||
| 885 | } | ||
| 886 | |||
| 794 | static HRESULT ProcessPackage( | 887 | static HRESULT ProcessPackage( |
| 795 | __in BOOL fBundlePerMachine, | 888 | __in BOOL fBundlePerMachine, |
| 796 | __in BURN_USER_EXPERIENCE* pUX, | 889 | __in BURN_USER_EXPERIENCE* pUX, |
| @@ -799,7 +892,6 @@ static HRESULT ProcessPackage( | |||
| 799 | __in BURN_LOGGING* pLog, | 892 | __in BURN_LOGGING* pLog, |
| 800 | __in BURN_VARIABLES* pVariables, | 893 | __in BURN_VARIABLES* pVariables, |
| 801 | __in BOOTSTRAPPER_DISPLAY display, | 894 | __in BOOTSTRAPPER_DISPLAY display, |
| 802 | __in BOOTSTRAPPER_RELATION_TYPE relationType, | ||
| 803 | __in_z_opt LPCWSTR wzLayoutDirectory, | 895 | __in_z_opt LPCWSTR wzLayoutDirectory, |
| 804 | __inout HANDLE* phSyncpointEvent, | 896 | __inout HANDLE* phSyncpointEvent, |
| 805 | __inout BURN_ROLLBACK_BOUNDARY** ppRollbackBoundary | 897 | __inout BURN_ROLLBACK_BOUNDARY** ppRollbackBoundary |
| @@ -807,17 +899,6 @@ static HRESULT ProcessPackage( | |||
| 807 | { | 899 | { |
| 808 | HRESULT hr = S_OK; | 900 | HRESULT hr = S_OK; |
| 809 | BURN_ROLLBACK_BOUNDARY* pEffectiveRollbackBoundary = NULL; | 901 | BURN_ROLLBACK_BOUNDARY* pEffectiveRollbackBoundary = NULL; |
| 810 | BOOL fPlanPackageBegan = FALSE; | ||
| 811 | |||
| 812 | // Remember the default requested state so the engine doesn't get blamed for planning the wrong thing if the BA changes it. | ||
| 813 | hr = PlanDefaultPackageRequestState(pPackage->type, pPackage->currentState, !pPackage->fUninstallable, pPackage->cacheType, pPlan->action, pVariables, pPackage->sczInstallCondition, relationType, &pPackage->defaultRequested); | ||
| 814 | ExitOnFailure(hr, "Failed to set default package state."); | ||
| 815 | |||
| 816 | pPackage->requested = pPackage->defaultRequested; | ||
| 817 | fPlanPackageBegan = TRUE; | ||
| 818 | |||
| 819 | hr = UserExperienceOnPlanPackageBegin(pUX, pPackage->sczId, &pPackage->requested); | ||
| 820 | ExitOnRootFailure(hr, "BA aborted plan package begin."); | ||
| 821 | 902 | ||
| 822 | pEffectiveRollbackBoundary = (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) ? pPackage->pRollbackBoundaryBackward : pPackage->pRollbackBoundaryForward; | 903 | pEffectiveRollbackBoundary = (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) ? pPackage->pRollbackBoundaryBackward : pPackage->pRollbackBoundaryForward; |
| 823 | hr = ProcessPackageRollbackBoundary(pPlan, pEffectiveRollbackBoundary, ppRollbackBoundary); | 904 | hr = ProcessPackageRollbackBoundary(pPlan, pEffectiveRollbackBoundary, ppRollbackBoundary); |
| @@ -896,11 +977,6 @@ static HRESULT ProcessPackage( | |||
| 896 | } | 977 | } |
| 897 | 978 | ||
| 898 | LExit: | 979 | LExit: |
| 899 | if (fPlanPackageBegan) | ||
| 900 | { | ||
| 901 | UserExperienceOnPlanPackageComplete(pUX, pPackage->sczId, hr, pPackage->currentState, pPackage->requested, pPackage->execute, pPackage->rollback); | ||
| 902 | } | ||
| 903 | |||
| 904 | return hr; | 980 | return hr; |
| 905 | } | 981 | } |
| 906 | 982 | ||
| @@ -1007,7 +1083,7 @@ extern "C" HRESULT PlanExecutePackage( | |||
| 1007 | HRESULT hr = S_OK; | 1083 | HRESULT hr = S_OK; |
| 1008 | BOOL fBARequestedCache = FALSE; | 1084 | BOOL fBARequestedCache = FALSE; |
| 1009 | 1085 | ||
| 1010 | hr = CalculateExecuteActions(pUserExperience, pPackage, pVariables, pPlan->pActiveRollbackBoundary, &fBARequestedCache); | 1086 | hr = CalculateExecuteActions(pPackage, pPlan->pActiveRollbackBoundary, &fBARequestedCache); |
| 1011 | ExitOnFailure(hr, "Failed to calculate plan actions for package: %ls", pPackage->sczId); | 1087 | ExitOnFailure(hr, "Failed to calculate plan actions for package: %ls", pPackage->sczId); |
| 1012 | 1088 | ||
| 1013 | // Calculate package states based on reference count and plan certain dependency actions prior to planning the package execute action. | 1089 | // Calculate package states based on reference count and plan certain dependency actions prior to planning the package execute action. |
| @@ -1801,6 +1877,9 @@ static void ResetPlannedPackageState( | |||
| 1801 | { | 1877 | { |
| 1802 | BURN_MSIFEATURE* pFeature = &pPackage->Msi.rgFeatures[i]; | 1878 | BURN_MSIFEATURE* pFeature = &pPackage->Msi.rgFeatures[i]; |
| 1803 | 1879 | ||
| 1880 | pFeature->expectedState = BOOTSTRAPPER_FEATURE_STATE_UNKNOWN; | ||
| 1881 | pFeature->defaultRequested = BOOTSTRAPPER_FEATURE_STATE_UNKNOWN; | ||
| 1882 | pFeature->requested = BOOTSTRAPPER_FEATURE_STATE_UNKNOWN; | ||
| 1804 | pFeature->execute = BOOTSTRAPPER_FEATURE_ACTION_NONE; | 1883 | pFeature->execute = BOOTSTRAPPER_FEATURE_ACTION_NONE; |
| 1805 | pFeature->rollback = BOOTSTRAPPER_FEATURE_ACTION_NONE; | 1884 | pFeature->rollback = BOOTSTRAPPER_FEATURE_ACTION_NONE; |
| 1806 | } | 1885 | } |
| @@ -1811,6 +1890,7 @@ static void ResetPlannedPackageState( | |||
| 1811 | { | 1890 | { |
| 1812 | BURN_MSPTARGETPRODUCT* pTargetProduct = &pPackage->Msp.rgTargetProducts[i]; | 1891 | BURN_MSPTARGETPRODUCT* pTargetProduct = &pPackage->Msp.rgTargetProducts[i]; |
| 1813 | 1892 | ||
| 1893 | pTargetProduct->requested = BOOTSTRAPPER_REQUEST_STATE_NONE; | ||
| 1814 | pTargetProduct->execute = BOOTSTRAPPER_ACTION_STATE_NONE; | 1894 | pTargetProduct->execute = BOOTSTRAPPER_ACTION_STATE_NONE; |
| 1815 | pTargetProduct->rollback = BOOTSTRAPPER_ACTION_STATE_NONE; | 1895 | pTargetProduct->rollback = BOOTSTRAPPER_ACTION_STATE_NONE; |
| 1816 | } | 1896 | } |
| @@ -2738,9 +2818,7 @@ LExit: | |||
| 2738 | } | 2818 | } |
| 2739 | 2819 | ||
| 2740 | static HRESULT CalculateExecuteActions( | 2820 | static HRESULT CalculateExecuteActions( |
| 2741 | __in BURN_USER_EXPERIENCE* pUserExperience, | ||
| 2742 | __in BURN_PACKAGE* pPackage, | 2821 | __in BURN_PACKAGE* pPackage, |
| 2743 | __in BURN_VARIABLES* pVariables, | ||
| 2744 | __in_opt BURN_ROLLBACK_BOUNDARY* pActiveRollbackBoundary, | 2822 | __in_opt BURN_ROLLBACK_BOUNDARY* pActiveRollbackBoundary, |
| 2745 | __out_opt BOOL* pfBARequestedCache | 2823 | __out_opt BOOL* pfBARequestedCache |
| 2746 | ) | 2824 | ) |
| @@ -2756,11 +2834,11 @@ static HRESULT CalculateExecuteActions( | |||
| 2756 | break; | 2834 | break; |
| 2757 | 2835 | ||
| 2758 | case BURN_PACKAGE_TYPE_MSI: | 2836 | case BURN_PACKAGE_TYPE_MSI: |
| 2759 | hr = MsiEnginePlanCalculatePackage(pPackage, pVariables, pUserExperience, fInsideMsiTransaction, pfBARequestedCache); | 2837 | hr = MsiEnginePlanCalculatePackage(pPackage, fInsideMsiTransaction, pfBARequestedCache); |
| 2760 | break; | 2838 | break; |
| 2761 | 2839 | ||
| 2762 | case BURN_PACKAGE_TYPE_MSP: | 2840 | case BURN_PACKAGE_TYPE_MSP: |
| 2763 | hr = MspEnginePlanCalculatePackage(pPackage, pUserExperience, fInsideMsiTransaction, pfBARequestedCache); | 2841 | hr = MspEnginePlanCalculatePackage(pPackage, fInsideMsiTransaction, pfBARequestedCache); |
| 2764 | break; | 2842 | break; |
| 2765 | 2843 | ||
| 2766 | case BURN_PACKAGE_TYPE_MSU: | 2844 | case BURN_PACKAGE_TYPE_MSU: |
