msi: Always ignore disabled components.

This commit is contained in:
Hans Leidekker 2010-11-30 15:18:00 +01:00 committed by Alexandre Julliard
parent 4881a354c2
commit c47ecd1ccc
4 changed files with 69 additions and 18 deletions

View File

@ -1220,7 +1220,8 @@ static UINT load_component( MSIRECORD *row, LPVOID param )
comp->KeyPath = msi_dup_record_field( row, 6 ); comp->KeyPath = msi_dup_record_field( row, 6 );
comp->Installed = INSTALLSTATE_UNKNOWN; comp->Installed = INSTALLSTATE_UNKNOWN;
msi_component_set_state(package, comp, INSTALLSTATE_UNKNOWN); comp->Action = INSTALLSTATE_UNKNOWN;
comp->ActionRequest = INSTALLSTATE_UNKNOWN;
comp->assembly = load_assembly( package, comp ); comp->assembly = load_assembly( package, comp );
return ERROR_SUCCESS; return ERROR_SUCCESS;
@ -1733,7 +1734,7 @@ static void ACTION_GetComponentInstallStates(MSIPACKAGE *package)
LIST_FOR_EACH_ENTRY(comp, &package->components, MSICOMPONENT, entry) LIST_FOR_EACH_ENTRY(comp, &package->components, MSICOMPONENT, entry)
{ {
if (!comp->ComponentId) if (!comp->Enabled || !comp->ComponentId)
continue; continue;
if (state != INSTALLSTATE_LOCAL && state != INSTALLSTATE_DEFAULT) if (state != INSTALLSTATE_LOCAL && state != INSTALLSTATE_DEFAULT)
@ -1928,6 +1929,8 @@ UINT MSI_SetFeatureStates(MSIPACKAGE *package)
/* features with components that have compressed files are made local */ /* features with components that have compressed files are made local */
LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry ) LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
{ {
if (!cl->component->Enabled) continue;
if (cl->component->ForceLocalState && if (cl->component->ForceLocalState &&
feature->ActionRequest == INSTALLSTATE_SOURCE) feature->ActionRequest == INSTALLSTATE_SOURCE)
{ {
@ -1940,6 +1943,8 @@ UINT MSI_SetFeatureStates(MSIPACKAGE *package)
{ {
component = cl->component; component = cl->component;
if (!component->Enabled) continue;
switch (feature->ActionRequest) switch (feature->ActionRequest)
{ {
case INSTALLSTATE_ABSENT: case INSTALLSTATE_ABSENT:
@ -1970,6 +1975,8 @@ UINT MSI_SetFeatureStates(MSIPACKAGE *package)
LIST_FOR_EACH_ENTRY( component, &package->components, MSICOMPONENT, entry ) LIST_FOR_EACH_ENTRY( component, &package->components, MSICOMPONENT, entry )
{ {
if (!component->Enabled) continue;
/* check if it's local or source */ /* check if it's local or source */
if (!(component->Attributes & msidbComponentAttributesOptional) && if (!(component->Attributes & msidbComponentAttributesOptional) &&
(component->hasLocalFeature || component->hasSourceFeature)) (component->hasLocalFeature || component->hasSourceFeature))
@ -2008,6 +2015,8 @@ UINT MSI_SetFeatureStates(MSIPACKAGE *package)
LIST_FOR_EACH_ENTRY( component, &package->components, MSICOMPONENT, entry ) LIST_FOR_EACH_ENTRY( component, &package->components, MSICOMPONENT, entry )
{ {
if (!component->Enabled) continue;
if (component->ActionRequest == INSTALLSTATE_DEFAULT) if (component->ActionRequest == INSTALLSTATE_DEFAULT)
{ {
TRACE("%s was default, setting to local\n", debugstr_w(component->Component)); TRACE("%s was default, setting to local\n", debugstr_w(component->Component));
@ -2283,6 +2292,18 @@ static UINT ACTION_CostFinalize(MSIPACKAGE *package)
msiobj_release(&view->hdr); msiobj_release(&view->hdr);
} }
TRACE("Evaluating component conditions\n");
LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
{
if (MSI_EvaluateConditionW( package, comp->Condition ) == MSICONDITION_FALSE)
{
TRACE("Disabling component %s\n", debugstr_w(comp->Component));
comp->Enabled = FALSE;
}
else
comp->Enabled = TRUE;
}
/* read components states from the registry */ /* read components states from the registry */
ACTION_GetComponentInstallStates(package); ACTION_GetComponentInstallStates(package);
ACTION_GetFeatureInstallStates(package); ACTION_GetFeatureInstallStates(package);
@ -2298,18 +2319,6 @@ static UINT ACTION_CostFinalize(MSIPACKAGE *package)
msiobj_release( &view->hdr ); msiobj_release( &view->hdr );
} }
} }
TRACE("Evaluating component conditions\n");
LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
{
if (MSI_EvaluateConditionW( package, comp->Condition ) == MSICONDITION_FALSE)
{
TRACE("Disabling component %s\n", debugstr_w(comp->Component));
comp->Enabled = FALSE;
}
else
comp->Enabled = TRUE;
}
TRACE("Calculating file install states\n"); TRACE("Calculating file install states\n");
set_file_install_states( package ); set_file_install_states( package );

View File

@ -658,13 +658,12 @@ void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature)
{ {
MSICOMPONENT* component = cl->component; MSICOMPONENT* component = cl->component;
if (!component->Enabled) continue;
TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n", TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n",
newstate, debugstr_w(component->Component), component->Installed, newstate, debugstr_w(component->Component), component->Installed,
component->Action, component->ActionRequest); component->Action, component->ActionRequest);
if (!component->Enabled)
continue;
if (newstate == INSTALLSTATE_LOCAL) if (newstate == INSTALLSTATE_LOCAL)
msi_component_set_state(package, component, INSTALLSTATE_LOCAL); msi_component_set_state(package, component, INSTALLSTATE_LOCAL);
else else

View File

@ -1158,7 +1158,8 @@ static UINT MSI_SetComponentStateW(MSIPACKAGE *package, LPCWSTR szComponent,
if (!comp) if (!comp)
return ERROR_UNKNOWN_COMPONENT; return ERROR_UNKNOWN_COMPONENT;
comp->Installed = iState; if (comp->Enabled)
comp->Installed = iState;
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }

View File

@ -7707,6 +7707,7 @@ static void test_removefiles(void)
MSIHANDLE hpkg; MSIHANDLE hpkg;
UINT r; UINT r;
MSIHANDLE hdb; MSIHANDLE hdb;
INSTALLSTATE installed, action;
hdb = create_package_db(); hdb = create_package_db();
ok ( hdb, "failed to create package database\n" ); ok ( hdb, "failed to create package database\n" );
@ -7741,6 +7742,9 @@ static void test_removefiles(void)
r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" ); r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r ); ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
r = add_component_entry( hdb, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
r = create_feature_components_table( hdb ); r = create_feature_components_table( hdb );
ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r ); ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
@ -7762,6 +7766,9 @@ static void test_removefiles(void)
r = add_feature_components_entry( hdb, "'one', 'carbon'" ); r = add_feature_components_entry( hdb, "'one', 'carbon'" );
ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r ); ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
r = add_feature_components_entry( hdb, "'one', 'oxygen'" );
ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
r = create_file_table( hdb ); r = create_file_table( hdb );
ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r ); ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
@ -7783,6 +7790,9 @@ static void test_removefiles(void)
r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" ); r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r); ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
r = add_file_entry( hdb, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
r = create_remove_file_table( hdb ); r = create_remove_file_table( hdb );
ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r); ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
@ -7803,18 +7813,28 @@ static void test_removefiles(void)
create_test_file( "beryllium.txt" ); create_test_file( "beryllium.txt" );
create_test_file( "boron.txt" ); create_test_file( "boron.txt" );
create_test_file( "carbon.txt" ); create_test_file( "carbon.txt" );
create_test_file( "oxygen.txt" );
r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR ); r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
ok( r == ERROR_SUCCESS, "set property failed\n"); ok( r == ERROR_SUCCESS, "set property failed\n");
MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
ok( r == ERROR_UNKNOWN_COMPONENT, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
r = MsiDoAction( hpkg, "CostInitialize"); r = MsiDoAction( hpkg, "CostInitialize");
ok( r == ERROR_SUCCESS, "cost init failed\n"); ok( r == ERROR_SUCCESS, "cost init failed\n");
r = MsiDoAction( hpkg, "FileCost"); r = MsiDoAction( hpkg, "FileCost");
ok( r == ERROR_SUCCESS, "cost finalize failed\n"); ok( r == ERROR_SUCCESS, "cost finalize failed\n");
installed = action = 0xdeadbeef;
r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
r = MsiDoAction( hpkg, "CostFinalize"); r = MsiDoAction( hpkg, "CostFinalize");
ok( r == ERROR_SUCCESS, "cost finalize failed\n"); ok( r == ERROR_SUCCESS, "cost finalize failed\n");
@ -7839,15 +7859,37 @@ static void test_removefiles(void)
r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE ); r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r); ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
installed = action = 0xdeadbeef;
r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
r = MsiSetComponentState( hpkg, "oxygen", INSTALLSTATE_ABSENT );
ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
installed = action = 0xdeadbeef;
r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
r = MsiDoAction( hpkg, "RemoveFiles"); r = MsiDoAction( hpkg, "RemoveFiles");
ok( r == ERROR_SUCCESS, "remove files failed\n"); ok( r == ERROR_SUCCESS, "remove files failed\n");
installed = action = 0xdeadbeef;
r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n"); ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n"); ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n"); ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n"); ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n"); ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n"); ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
MsiCloseHandle( hpkg ); MsiCloseHandle( hpkg );
DeleteFileA(msifile); DeleteFileA(msifile);