Commit c5075435 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Set the SourceDir and SOURCEDIR properties in the ResolveSource action.

parent 58870ce8
......@@ -573,7 +573,6 @@ UINT MSI_InstallPackage( MSIPACKAGE *package, LPCWSTR szPackagePath,
{
LPWSTR p, check, path;
package->PackagePath = strdupW(szPackagePath);
path = strdupW(szPackagePath);
p = strrchrW(path,'\\');
if (p)
......@@ -592,8 +591,10 @@ UINT MSI_InstallPackage( MSIPACKAGE *package, LPCWSTR szPackagePath,
check = msi_dup_property( package, cszSourceDir );
if (!check)
MSI_SetPropertyW(package, cszSourceDir, path);
package->PackagePath = path;
msi_free(check);
msi_free(path);
}
msi_parse_command_line( package, szCommandLine );
......@@ -3851,8 +3852,10 @@ static UINT ACTION_ForceReboot(MSIPACKAGE *package)
static UINT ACTION_ResolveSource(MSIPACKAGE* package)
{
DWORD attrib;
DWORD attrib, len;
LPWSTR ptr, source;
UINT rc;
/*
* we are currently doing what should be done here in the top level Install
* however for Adminastrative and uninstalls this step will be needed
......@@ -3860,6 +3863,19 @@ static UINT ACTION_ResolveSource(MSIPACKAGE* package)
if (!package->PackagePath)
return ERROR_SUCCESS;
ptr = strrchrW(package->PackagePath, '\\');
if (!ptr)
return ERROR_SUCCESS;
len = ptr - package->PackagePath + 2;
source = msi_alloc(len * sizeof(WCHAR));
lstrcpynW(source, package->PackagePath, len);
MSI_SetPropertyW(package, cszSourceDir, source);
MSI_SetPropertyW(package, cszSOURCEDIR, source);
msi_free(source);
attrib = GetFileAttributesW(package->PackagePath);
if (attrib == INVALID_FILE_ATTRIBUTES)
{
......
......@@ -40,6 +40,7 @@ static const WCHAR cszTargetDir[] = {'T','A','R','G','E','T','D','I','R',0};
static const WCHAR cszDatabase[]={'D','A','T','A','B','A','S','E',0};
const WCHAR cszSourceDir[] = {'S','o','u','r','c','e','D','i','r',0};
const WCHAR cszSOURCEDIR[] = {'S','O','U','R','C','E','D','I','R',0};
const WCHAR cszRootDrive[] = {'R','O','O','T','D','R','I','V','E',0};
const WCHAR cszbs[]={'\\',0};
......
......@@ -768,6 +768,7 @@ extern void ui_actiondata(MSIPACKAGE *, LPCWSTR, MSIRECORD *);
/* string consts use a number of places and defined in helpers.c*/
extern const WCHAR cszSourceDir[];
extern const WCHAR cszSOURCEDIR[];
extern const WCHAR szProductCode[];
extern const WCHAR cszRootDrive[];
extern const WCHAR cszbs[];
......
......@@ -424,6 +424,7 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db )
list_init( &package->RunningActions );
package->WordCount = msi_get_word_count( package );
package->PackagePath = strdupW( db->path );
/* OK, here is where we do a slew of things to the database to
* prep for all that is to come as a package */
......
......@@ -2728,6 +2728,68 @@ static void test_installprops(void)
MsiCloseHandle(hpkg);
}
static void test_sourcedirprop(void)
{
MSIHANDLE hpkg, hdb;
CHAR source_dir[MAX_PATH];
CHAR path[MAX_PATH];
DWORD size;
UINT r;
hdb = create_package_db();
ok ( hdb, "failed to create package database\n" );
r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
hpkg = package_from_db( hdb );
ok( hpkg, "failed to create package\n");
MsiCloseHandle( hdb );
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
r = MsiDoAction( hpkg, "CostInitialize");
ok( r == ERROR_SUCCESS, "cost init failed\n");
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
r = MsiDoAction( hpkg, "ResolveSource");
ok( r == ERROR_SUCCESS, "file cost failed\n");
GetCurrentDirectory(MAX_PATH, path);
lstrcatA(path, "\\");
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
MsiCloseHandle(hpkg);
DeleteFileA(msifile);
}
START_TEST(package)
{
test_createpackage();
......@@ -2746,4 +2808,5 @@ START_TEST(package)
test_appsearch();
test_featureparents();
test_installprops();
test_sourcedirprop();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment