From 6e63953b4c8c0f50a102d7ea4847352a6aedc346 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Tue, 5 Aug 2008 10:28:27 -0500 Subject: [PATCH] msi: Also check the LocalPackage install property when searching for the product package. --- dlls/msi/msi.c | 59 +++++++++++++++++++++++++++++++++++++++--------- dlls/msi/tests/install.c | 16 ++++--------- 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c index c5dd57da07e..9055c599a79 100644 --- a/dlls/msi/msi.c +++ b/dlls/msi/msi.c @@ -372,6 +372,53 @@ done: return r; } +static UINT msi_open_package(LPCWSTR product, MSIINSTALLCONTEXT context, + MSIPACKAGE **package) +{ + UINT r; + DWORD sz; + HKEY props; + LPWSTR localpack; + WCHAR sourcepath[MAX_PATH]; + WCHAR filename[MAX_PATH]; + + static const WCHAR szLocalPackage[] = { + 'L','o','c','a','l','P','a','c','k','a','g','e',0}; + + if (context == MSIINSTALLCONTEXT_MACHINE) + r = MSIREG_OpenLocalSystemInstallProps(product, &props, FALSE); + else + r = MSIREG_OpenCurrentUserInstallProps(product, &props, FALSE); + + if (r != ERROR_SUCCESS) + return ERROR_BAD_CONFIGURATION; + + localpack = msi_reg_get_val_str(props, szLocalPackage); + if (localpack) + { + lstrcpyW(sourcepath, localpack); + msi_free(localpack); + } + + if (!localpack || GetFileAttributesW(sourcepath) == INVALID_FILE_ATTRIBUTES) + { + sz = sizeof(sourcepath); + MsiSourceListGetInfoW(product, NULL, context, MSICODE_PRODUCT, + INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz); + + sz = sizeof(filename); + MsiSourceListGetInfoW(product, NULL, context, MSICODE_PRODUCT, + INSTALLPROPERTY_PACKAGENAMEW, filename, &sz); + + lstrcatW(sourcepath, filename); + } + + if (GetFileAttributesW(sourcepath) == INVALID_FILE_ATTRIBUTES) + return ERROR_INSTALL_SOURCE_ABSENT; + + return MSI_OpenPackageW(sourcepath, package); +} + UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel, INSTALLSTATE eInstallState, LPCWSTR szCommandLine) { @@ -380,7 +427,6 @@ UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel, UINT r; DWORD sz; WCHAR sourcepath[MAX_PATH]; - WCHAR filename[MAX_PATH]; LPWSTR commandline; static const WCHAR szInstalled[] = { @@ -407,16 +453,7 @@ UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel, if (r != ERROR_SUCCESS) return r; - sz = sizeof(sourcepath); - MsiSourceListGetInfoW(szProduct, NULL, context, MSICODE_PRODUCT, - INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz); - - sz = sizeof(filename); - MsiSourceListGetInfoW(szProduct, NULL, context, MSICODE_PRODUCT, - INSTALLPROPERTY_PACKAGENAMEW, filename, &sz); - - lstrcatW(sourcepath, filename); - r = MSI_OpenPackageW(sourcepath, &package); + r = msi_open_package(szProduct, context, &package); if (r != ERROR_SUCCESS) return r; diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c index cf65abe7cfe..6f15720036b 100644 --- a/dlls/msi/tests/install.c +++ b/dlls/msi/tests/install.c @@ -5118,9 +5118,9 @@ static void test_MsiConfigureProductEx(void) r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT, "PROPVAR=42"); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); todo_wine { - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n"); ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n"); ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n"); @@ -5154,11 +5154,8 @@ static void test_MsiConfigureProductEx(void) r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT, "PROPVAR=42"); - todo_wine - { - ok(r == ERROR_INSTALL_SOURCE_ABSENT, - "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r); - } + ok(r == ERROR_INSTALL_SOURCE_ABSENT, + "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r); ok(pf_exists("msitest\\hydrogen"), "File not installed\n"); ok(pf_exists("msitest\\helium"), "File not installed\n"); ok(pf_exists("msitest\\lithium"), "File not installed\n"); @@ -5219,11 +5216,8 @@ static void test_MsiConfigureProductEx(void) r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT, "PROPVAR=42"); - todo_wine - { - ok(r == ERROR_INSTALL_SOURCE_ABSENT, - "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r); - } + ok(r == ERROR_INSTALL_SOURCE_ABSENT, + "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r); ok(pf_exists("msitest\\hydrogen"), "File not installed\n"); ok(pf_exists("msitest\\helium"), "File not installed\n"); ok(pf_exists("msitest\\lithium"), "File not installed\n"); -- 2.11.4.GIT