msi: Publish the UpgradeCode in PublishProduct.

oldstable
James Hawkins 2008-06-23 23:02:54 -05:00 committed by Alexandre Julliard
parent 5538fa0290
commit cdb33f8a39
5 changed files with 73 additions and 23 deletions

View File

@ -3473,6 +3473,34 @@ done:
return ERROR_SUCCESS;
}
static UINT msi_publish_upgrade_code(MSIPACKAGE *package)
{
UINT r;
HKEY hkey;
LPWSTR upgrade;
WCHAR squashed_pc[SQUISH_GUID_SIZE];
static const WCHAR szUpgradeCode[] =
{'U','p','g','r','a','d','e','C','o','d','e',0};
upgrade = msi_dup_property(package, szUpgradeCode);
if (!upgrade)
return ERROR_SUCCESS;
r = MSIREG_OpenUserUpgradeCodesKey(upgrade, &hkey, TRUE);
if (r != ERROR_SUCCESS)
goto done;
squash_guid(package->ProductCode, squashed_pc);
msi_reg_set_val_str(hkey, squashed_pc, NULL);
RegCloseKey(hkey);
done:
msi_free(upgrade);
return r;
}
static BOOL msi_check_publish(MSIPACKAGE *package)
{
MSIFEATURE *feature;
@ -3486,6 +3514,19 @@ static BOOL msi_check_publish(MSIPACKAGE *package)
return FALSE;
}
static BOOL msi_check_unpublish(MSIPACKAGE *package)
{
MSIFEATURE *feature;
LIST_FOR_EACH_ENTRY(feature, &package->features, MSIFEATURE, entry)
{
if (feature->ActionRequest != INSTALLSTATE_ABSENT)
return FALSE;
}
return TRUE;
}
/*
* 99% of the work done here is only done for
* advertised installs. However this is where the
@ -3531,7 +3572,9 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
if (rc != ERROR_SUCCESS)
goto end;
/* FIXME: Need to write more keys to the user registry */
rc = msi_publish_upgrade_code(package);
if (rc != ERROR_SUCCESS)
goto end;
rc = msi_publish_product_properties(package, hukey);
if (rc != ERROR_SUCCESS)
@ -3895,19 +3938,6 @@ static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature)
return ERROR_SUCCESS;
}
static BOOL msi_check_unpublish(MSIPACKAGE *package)
{
MSIFEATURE *feature;
LIST_FOR_EACH_ENTRY(feature, &package->features, MSIFEATURE, entry)
{
if (feature->ActionRequest != INSTALLSTATE_ABSENT)
return FALSE;
}
return TRUE;
}
static UINT ACTION_UnpublishFeatures(MSIPACKAGE *package)
{
MSIFEATURE *feature;
@ -4152,6 +4182,7 @@ static UINT ACTION_InstallExecute(MSIPACKAGE *package)
static UINT msi_unpublish_product(MSIPACKAGE *package)
{
LPWSTR upgrade;
LPWSTR remove = NULL;
LPWSTR *features = NULL;
BOOL full_uninstall = TRUE;
@ -4159,6 +4190,8 @@ static UINT msi_unpublish_product(MSIPACKAGE *package)
static const WCHAR szRemove[] = {'R','E','M','O','V','E',0};
static const WCHAR szAll[] = {'A','L','L',0};
static const WCHAR szUpgradeCode[] =
{'U','p','g','r','a','d','e','C','o','d','e',0};
remove = msi_dup_property(package, szRemove);
if (!remove)
@ -4192,6 +4225,13 @@ static UINT msi_unpublish_product(MSIPACKAGE *package)
MSIREG_DeleteUserFeaturesKey(package->ProductCode);
MSIREG_DeleteUninstallKey(package->ProductCode);
upgrade = msi_dup_property(package, szUpgradeCode);
if (upgrade)
{
MSIREG_DeleteUserUpgradeCodesKey(upgrade);
msi_free(upgrade);
}
done:
msi_free(remove);
msi_free(features);

View File

@ -791,6 +791,7 @@ extern UINT MSIREG_OpenLocalUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BO
extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct);
extern UINT MSIREG_DeleteLocalUserDataComponentKey(LPCWSTR szComponent);
extern UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent);
extern UINT MSIREG_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode);
extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );
extern BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val);

View File

@ -980,6 +980,21 @@ UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL creat
return rc;
}
UINT MSIREG_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode)
{
WCHAR squished_pc[GUID_SIZE];
WCHAR keypath[0x200];
TRACE("%s\n",debugstr_w(szUpgradeCode));
if (!squash_guid(szUpgradeCode,squished_pc))
return ERROR_FUNCTION_FAILED;
TRACE("squished (%s)\n", debugstr_w(squished_pc));
sprintfW(keypath,szInstaller_UserUpgradeCodes_fmt,squished_pc);
return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
}
UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
{
WCHAR squished_pc[GUID_SIZE];

View File

@ -2301,10 +2301,7 @@ static void test_Installer_InstallProduct(void)
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
res = RegDeleteKeyA(hkey, "UpgradeCodes\\D8E760ECA1E276347B43E42BDBDA5656");
todo_wine
{
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
}
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
RegCloseKey(hkey);

View File

@ -2569,12 +2569,9 @@ static void test_publish_publishproduct(void)
RegCloseKey(hkey);
res = RegOpenKeyA(HKEY_CURRENT_USER, cuupgrades, &hkey);
todo_wine
{
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
}
CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
RegDeleteKeyA(hkey, "");
RegCloseKey(hkey);