Add logging for patch target products.

This commit is contained in:
Sean Hall 2021-02-21 11:54:54 -06:00
Родитель 837f2e309c
Коммит d0d93beac0
9 изменённых файлов: 98 добавлений и 31 удалений

Просмотреть файл

@ -1822,6 +1822,17 @@ static void LogPackages(
LogId(REPORT_STANDARD, MSG_PLANNED_MSI_FEATURE, pFeature->sczId, LoggingMsiFeatureStateToString(pFeature->currentState), LoggingMsiFeatureStateToString(pFeature->defaultRequested), LoggingMsiFeatureStateToString(pFeature->requested), LoggingMsiFeatureActionToString(pFeature->execute), LoggingMsiFeatureActionToString(pFeature->rollback));
}
}
else if (BURN_PACKAGE_TYPE_MSP == pPackage->type && pPackage->Msp.cTargetProductCodes)
{
LogId(REPORT_STANDARD, MSG_PLANNED_MSP_TARGETS, pPackage->Msp.cTargetProductCodes, pPackage->sczId);
for (DWORD j = 0; j < pPackage->Msp.cTargetProductCodes; ++j)
{
const BURN_MSPTARGETPRODUCT* pTargetProduct = &pPackage->Msp.rgTargetProducts[j];
LogId(REPORT_STANDARD, MSG_PLANNED_MSP_TARGET, pTargetProduct->wzTargetProductCode, LoggingPackageStateToString(pTargetProduct->patchPackageState), LoggingRequestStateToString(pTargetProduct->defaultRequested), LoggingRequestStateToString(pTargetProduct->requested), LoggingMspTargetActionToString(pTargetProduct->execute, pTargetProduct->executeSkip), LoggingMspTargetActionToString(pTargetProduct->rollback, pTargetProduct->rollbackSkip));
}
}
}
// Display related bundles last if caching, installing, modifying, or repairing.

Просмотреть файл

@ -855,7 +855,6 @@ extern "C" HRESULT ElevationExecuteMsiPackage(
DWORD dwResult = 0;
// serialize message data
// TODO: for patching we might not have a package
hr = BuffWriteString(&pbData, &cbData, pExecuteAction->msiPackage.pPackage->sczId);
ExitOnFailure(hr, "Failed to write package id to message buffer.");
@ -964,9 +963,6 @@ extern "C" HRESULT ElevationExecuteMspPackage(
for (DWORD i = 0; i < pExecuteAction->mspTarget.cOrderedPatches; ++i)
{
hr = BuffWriteNumber(&pbData, &cbData, pExecuteAction->mspTarget.rgOrderedPatches[i].dwOrder);
ExitOnFailure(hr, "Failed to write ordered patch order to message buffer.");
hr = BuffWriteString(&pbData, &cbData, pExecuteAction->mspTarget.rgOrderedPatches[i].pPackage->sczId);
ExitOnFailure(hr, "Failed to write ordered patch id to message buffer.");
}
@ -2404,9 +2400,6 @@ static HRESULT OnExecuteMspPackage(
for (DWORD i = 0; i < executeAction.mspTarget.cOrderedPatches; ++i)
{
hr = BuffReadNumber(pbData, cbData, &iData, &executeAction.mspTarget.rgOrderedPatches[i].dwOrder);
ExitOnFailure(hr, "Failed to read ordered patch order number.");
hr = BuffReadString(pbData, cbData, &iData, &sczPackage);
ExitOnFailure(hr, "Failed to read ordered patch package id.");

Просмотреть файл

@ -415,6 +415,20 @@ Language=English
Plan skipped dependent bundle repair: %1!ls!, type: %2!hs!, because no packages are being executed during this uninstall operation.
.
MessageId=218
Severity=Success
SymbolicName=MSG_PLANNED_MSP_TARGETS
Language=English
Plan %1!u! patch targets for package: %2!ls!
.
MessageId=219
Severity=Success
SymbolicName=MSG_PLANNED_MSP_TARGET
Language=English
Planned patch target: %1!ls!, state: %2!hs!, default requested: %3!hs!, ba requested: %4!hs!, execute: %5!hs!, rollback: %6!hs!
.
MessageId=299
Severity=Success
SymbolicName=MSG_PLAN_COMPLETE

Просмотреть файл

@ -531,6 +531,24 @@ extern "C" LPCWSTR LoggingBurnMsiPropertyToString(
}
}
extern "C" LPCSTR LoggingMspTargetActionToString(
__in BOOTSTRAPPER_ACTION_STATE action,
__in BURN_PATCH_SKIP_STATE skipState
)
{
switch (skipState)
{
case BURN_PATCH_SKIP_STATE_NONE:
return LoggingActionStateToString(action);
case BURN_PATCH_SKIP_STATE_TARGET_UNINSTALL:
return "Skipped (target uninstall)";
case BURN_PATCH_SKIP_STATE_SLIPSTREAM:
return "Skipped (slipstream)";
default:
return "Invalid";
}
}
extern "C" LPCSTR LoggingPerMachineToString(
__in BOOL fPerMachine
)

Просмотреть файл

@ -114,6 +114,11 @@ LPCWSTR LoggingBurnMsiPropertyToString(
__in BURN_MSI_PROPERTY burnMsiProperty
);
LPCSTR LoggingMspTargetActionToString(
__in BOOTSTRAPPER_ACTION_STATE action,
__in BURN_PATCH_SKIP_STATE skipState
);
LPCSTR LoggingPerMachineToString(
__in BOOL fPerMachine
);

Просмотреть файл

@ -290,7 +290,7 @@ extern "C" HRESULT MspEnginePlanInitializePackage(
{
BURN_MSPTARGETPRODUCT* pTargetProduct = pPackage->Msp.rgTargetProducts + i;
pTargetProduct->requested = pPackage->requested;
pTargetProduct->defaultRequested = pTargetProduct->requested = pPackage->requested;
hr = UserExperienceOnPlanPatchTarget(pUserExperience, pPackage->sczId, pTargetProduct->wzTargetProductCode, &pTargetProduct->requested);
ExitOnRootFailure(hr, "BA aborted plan patch target.");
@ -1086,14 +1086,14 @@ static HRESULT PlanTargetProduct(
hr = MemEnsureArraySize(reinterpret_cast<LPVOID*>(&pAction->mspTarget.rgOrderedPatches), pAction->mspTarget.cOrderedPatches + 1, sizeof(BURN_ORDERED_PATCHES), 2);
ExitOnFailure(hr, "Failed grow array of ordered patches.");
pAction->mspTarget.rgOrderedPatches[pAction->mspTarget.cOrderedPatches].dwOrder = pTargetProduct->dwOrder;
pAction->mspTarget.rgOrderedPatches[pAction->mspTarget.cOrderedPatches].pTargetProduct = pTargetProduct;
pAction->mspTarget.rgOrderedPatches[pAction->mspTarget.cOrderedPatches].pPackage = pPackage;
++pAction->mspTarget.cOrderedPatches;
// Insertion sort to keep the patches ordered.
for (DWORD i = pAction->mspTarget.cOrderedPatches - 1; i > 0; --i)
{
if (pAction->mspTarget.rgOrderedPatches[i].dwOrder < pAction->mspTarget.rgOrderedPatches[i - 1].dwOrder)
if (pAction->mspTarget.rgOrderedPatches[i].pTargetProduct->dwOrder < pAction->mspTarget.rgOrderedPatches[i - 1].pTargetProduct->dwOrder)
{
BURN_ORDERED_PATCHES temp = pAction->mspTarget.rgOrderedPatches[i - 1];
pAction->mspTarget.rgOrderedPatches[i - 1] = pAction->mspTarget.rgOrderedPatches[i];

Просмотреть файл

@ -86,6 +86,13 @@ enum BURN_PACKAGE_REGISTRATION_STATE
BURN_PACKAGE_REGISTRATION_STATE_PRESENT,
};
enum BURN_PATCH_SKIP_STATE
{
BURN_PATCH_SKIP_STATE_NONE,
BURN_PATCH_SKIP_STATE_TARGET_UNINSTALL,
BURN_PATCH_SKIP_STATE_SLIPSTREAM,
};
// structs
typedef struct _BURN_EXE_EXIT_CODE
@ -112,9 +119,12 @@ typedef struct _BURN_MSPTARGETPRODUCT
BOOL fSlipstream;
BOOTSTRAPPER_PACKAGE_STATE patchPackageState; // only valid after Detect.
BOOTSTRAPPER_REQUEST_STATE defaultRequested; // only valid during Plan.
BOOTSTRAPPER_REQUEST_STATE requested; // only valid during Plan.
BOOTSTRAPPER_ACTION_STATE execute; // only valid during Plan.
BOOTSTRAPPER_ACTION_STATE rollback; // only valid during Plan.
BURN_PATCH_SKIP_STATE executeSkip; // only valid during Plan.
BURN_PATCH_SKIP_STATE rollbackSkip; // only valid during Plan.
BURN_PACKAGE_REGISTRATION_STATE registrationState; // initialized during Detect, updated during Apply.
BURN_PACKAGE_REGISTRATION_STATE transactionRegistrationState;// only valid during Apply inside an MSI transaction.

Просмотреть файл

@ -149,7 +149,7 @@ static BURN_CACHE_ACTION* ProcessSharedPayload(
__in BURN_PLAN* pPlan,
__in BURN_PAYLOAD* pPayload
);
static HRESULT RemoveUnnecessaryActions(
static void RemoveUnnecessaryActions(
__in BOOL fExecute,
__in BURN_EXECUTE_ACTION* rgActions,
__in DWORD cActions
@ -302,7 +302,6 @@ extern "C" void PlanUninitializeExecuteAction(
ReleaseStr(pExecuteAction->msiPackage.sczLogPath);
ReleaseMem(pExecuteAction->msiPackage.rgFeatures);
ReleaseMem(pExecuteAction->msiPackage.rgSlipstreamPatches);
ReleaseMem(pExecuteAction->msiPackage.rgOrderedPatches);
break;
case BURN_EXECUTE_ACTION_TYPE_MSP_TARGET:
@ -1499,11 +1498,9 @@ extern "C" HRESULT PlanFinalizeActions(
{
HRESULT hr = S_OK;
hr = RemoveUnnecessaryActions(TRUE, pPlan->rgExecuteActions, pPlan->cExecuteActions);
ExitOnFailure(hr, "Failed to remove unnecessary execute actions.");
RemoveUnnecessaryActions(TRUE, pPlan->rgExecuteActions, pPlan->cExecuteActions);
hr = RemoveUnnecessaryActions(FALSE, pPlan->rgRollbackActions, pPlan->cRollbackActions);
ExitOnFailure(hr, "Failed to remove unnecessary execute actions.");
RemoveUnnecessaryActions(FALSE, pPlan->rgRollbackActions, pPlan->cRollbackActions);
hr = FinalizeSlipstreamPatchActions(TRUE, pPlan->rgExecuteActions, pPlan->cExecuteActions);
ExitOnFailure(hr, "Failed to finalize slipstream execute actions.");
@ -1890,9 +1887,12 @@ static void ResetPlannedPackageState(
{
BURN_MSPTARGETPRODUCT* pTargetProduct = &pPackage->Msp.rgTargetProducts[i];
pTargetProduct->defaultRequested = BOOTSTRAPPER_REQUEST_STATE_NONE;
pTargetProduct->requested = BOOTSTRAPPER_REQUEST_STATE_NONE;
pTargetProduct->execute = BOOTSTRAPPER_ACTION_STATE_NONE;
pTargetProduct->rollback = BOOTSTRAPPER_ACTION_STATE_NONE;
pTargetProduct->executeSkip = BURN_PATCH_SKIP_STATE_NONE;
pTargetProduct->rollbackSkip = BURN_PATCH_SKIP_STATE_NONE;
}
}
}
@ -2704,13 +2704,12 @@ static BURN_CACHE_ACTION* ProcessSharedPayload(
return pAcquireAction;
}
static HRESULT RemoveUnnecessaryActions(
static void RemoveUnnecessaryActions(
__in BOOL fExecute,
__in BURN_EXECUTE_ACTION* rgActions,
__in DWORD cActions
)
{
HRESULT hr = S_OK;
LPCSTR szExecuteOrRollback = fExecute ? "execute" : "rollback";
for (DWORD i = 0; i < cActions; ++i)
@ -2722,10 +2721,11 @@ static HRESULT RemoveUnnecessaryActions(
if (BURN_EXECUTE_ACTION_TYPE_MSP_TARGET == pAction->type && pAction->mspTarget.pChainedTargetPackage)
{
BOOTSTRAPPER_ACTION_STATE chainedTargetPackageAction = fExecute ? pAction->mspTarget.pChainedTargetPackage->execute : pAction->mspTarget.pChainedTargetPackage->rollback;
BURN_PATCH_SKIP_STATE skipState = BURN_PATCH_SKIP_STATE_NONE;
if (BOOTSTRAPPER_ACTION_STATE_UNINSTALL == chainedTargetPackageAction)
{
skipState = BURN_PATCH_SKIP_STATE_TARGET_UNINSTALL;
LogId(REPORT_STANDARD, MSG_PLAN_SKIP_PATCH_ACTION, pAction->mspTarget.pPackage->sczId, LoggingActionStateToString(pAction->mspTarget.action), pAction->mspTarget.pChainedTargetPackage->sczId, LoggingActionStateToString(chainedTargetPackageAction), szExecuteOrRollback);
pAction->fDeleted = TRUE;
}
else if (BOOTSTRAPPER_ACTION_STATE_UNINSTALL < chainedTargetPackageAction && pAction->mspTarget.fSlipstream && BOOTSTRAPPER_ACTION_STATE_UNINSTALL < pAction->mspTarget.action)
{
@ -2737,14 +2737,31 @@ static HRESULT RemoveUnnecessaryActions(
// is already on the machine. The slipstream must be installed standalone if the MSI is being repaired.
if (BOOTSTRAPPER_ACTION_STATE_REPAIR != chainedTargetPackageAction || BOOTSTRAPPER_ACTION_STATE_REPAIR == pAction->mspTarget.action)
{
skipState = BURN_PATCH_SKIP_STATE_SLIPSTREAM;
LogId(REPORT_STANDARD, MSG_PLAN_SKIP_SLIPSTREAM_ACTION, pAction->mspTarget.pPackage->sczId, LoggingActionStateToString(pAction->mspTarget.action), pAction->mspTarget.pChainedTargetPackage->sczId, LoggingActionStateToString(chainedTargetPackageAction), szExecuteOrRollback);
pAction->fDeleted = TRUE;
}
}
if (BURN_PATCH_SKIP_STATE_NONE != skipState)
{
pAction->fDeleted = TRUE;
for (DWORD j = 0; j < pAction->mspTarget.cOrderedPatches; ++j)
{
BURN_MSPTARGETPRODUCT* pTargetProduct = pAction->mspTarget.rgOrderedPatches[j].pTargetProduct;
if (fExecute)
{
pTargetProduct->executeSkip = skipState;
}
else
{
pTargetProduct->rollbackSkip = skipState;
}
}
}
}
}
return hr;
}
static HRESULT FinalizeSlipstreamPatchActions(
@ -3047,17 +3064,13 @@ static void ExecuteActionLog(
case BURN_EXECUTE_ACTION_TYPE_MSI_PACKAGE:
LogStringLine(PlanDumpLevel, "%ls action[%u]: MSI_PACKAGE package id: %ls, action: %hs, action msi property: %ls, ui level: %u, disable externaluihandler: %ls, log path: %ls, logging attrib: %u", wzBase, iAction, pAction->msiPackage.pPackage->sczId, LoggingActionStateToString(pAction->msiPackage.action), LoggingBurnMsiPropertyToString(pAction->msiPackage.actionMsiProperty), pAction->msiPackage.uiLevel, pAction->msiPackage.fDisableExternalUiHandler ? L"yes" : L"no", pAction->msiPackage.sczLogPath, pAction->msiPackage.dwLoggingAttributes);
for (DWORD j = 0; j < pAction->msiPackage.cPatches; ++j)
{
LogStringLine(PlanDumpLevel, " Patch[%u]: order: %u, msp package id: %ls", j, pAction->msiPackage.rgOrderedPatches[j].dwOrder, pAction->msiPackage.rgOrderedPatches[j].pPackage->sczId);
}
break;
case BURN_EXECUTE_ACTION_TYPE_MSP_TARGET:
LogStringLine(PlanDumpLevel, "%ls action[%u]: MSP_TARGET package id: %ls, action: %hs, target product code: %ls, target per-machine: %ls, action msi property: %ls, ui level: %u, disable externaluihandler: %ls, log path: %ls", wzBase, iAction, pAction->mspTarget.pPackage->sczId, LoggingActionStateToString(pAction->mspTarget.action), pAction->mspTarget.sczTargetProductCode, pAction->mspTarget.fPerMachineTarget ? L"yes" : L"no", LoggingBurnMsiPropertyToString(pAction->mspTarget.actionMsiProperty), pAction->mspTarget.uiLevel, pAction->mspTarget.fDisableExternalUiHandler ? L"yes" : L"no", pAction->mspTarget.sczLogPath);
for (DWORD j = 0; j < pAction->mspTarget.cOrderedPatches; ++j)
{
LogStringLine(PlanDumpLevel, " Patch[%u]: order: %u, msp package id: %ls", j, pAction->mspTarget.rgOrderedPatches[j].dwOrder, pAction->mspTarget.rgOrderedPatches[j].pPackage->sczId);
LogStringLine(PlanDumpLevel, " Patch[%u]: order: %u, msp package id: %ls", j, pAction->mspTarget.rgOrderedPatches[j].pTargetProduct->dwOrder, pAction->mspTarget.rgOrderedPatches[j].pPackage->sczId);
}
break;
@ -3089,6 +3102,11 @@ static void ExecuteActionLog(
AssertSz(FALSE, "Unknown execute action type.");
break;
}
if (pAction->fDeleted)
{
LogStringLine(PlanDumpLevel, " (deleted action)");
}
}
extern "C" void PlanDump(

Просмотреть файл

@ -208,8 +208,9 @@ typedef struct _BURN_CACHE_ACTION
typedef struct _BURN_ORDERED_PATCHES
{
DWORD dwOrder;
BURN_PACKAGE* pPackage;
BURN_MSPTARGETPRODUCT* pTargetProduct; // only valid in the unelevated engine.
} BURN_ORDERED_PATCHES;
typedef struct _BURN_EXECUTE_ACTION_CHECKPOINT
@ -253,9 +254,6 @@ typedef struct _BURN_EXECUTE_ACTION
BOOTSTRAPPER_FEATURE_ACTION* rgFeatures;
BOOTSTRAPPER_ACTION_STATE* rgSlipstreamPatches;
BURN_ORDERED_PATCHES* rgOrderedPatches;
DWORD cPatches;
} msiPackage;
struct
{