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

Alexandre Julliard julliard at wine.codeweavers.com
Wed Oct 11 05:52:30 CDT 2006


Module: wine
Branch: master
Commit: c507543554b519f0dc3c50756c7c207f0c9e988a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c507543554b519f0dc3c50756c7c207f0c9e988a

Author: James Hawkins <truiken at gmail.com>
Date:   Tue Oct 10 13:39:50 2006 -0700

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

---

 dlls/msi/action.c        |   22 ++++++++++++++--
 dlls/msi/helpers.c       |    1 +
 dlls/msi/msipriv.h       |    1 +
 dlls/msi/package.c       |    1 +
 dlls/msi/tests/package.c |   63 ++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 0f2c6f8..ab2bf03 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -573,7 +573,6 @@ UINT MSI_InstallPackage( MSIPACKAGE *pac
     {
         LPWSTR p, check, path;
  
-        package->PackagePath = strdupW(szPackagePath);
         path = strdupW(szPackagePath);
         p = strrchrW(path,'\\');    
         if (p)
@@ -592,8 +591,10 @@ UINT MSI_InstallPackage( MSIPACKAGE *pac
         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(MSIPACKAG
 
 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(MSIPACK
     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)
     {
diff --git a/dlls/msi/helpers.c b/dlls/msi/helpers.c
index 2ebc13a..bb4dcc4 100644
--- a/dlls/msi/helpers.c
+++ b/dlls/msi/helpers.c
@@ -40,6 +40,7 @@ static const WCHAR cszTargetDir[] = {'T'
 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};
 
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index ef0c033..d65e0ab 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -768,6 +768,7 @@ extern void ui_actiondata(MSIPACKAGE *, 
 
 /* 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[];
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index d0b0619..aae868c 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -424,6 +424,7 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABA
         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 */
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index 508dde4..cdb71f6 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -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();
 }




More information about the wine-cvs mailing list