Skip to content

Commit a237138

Browse files
winesynclearn-more
authored andcommitted
[WINESYNC] msi: Add support for re-caching package.
Signed-off-by: Piotr Caban <[email protected]> Signed-off-by: Hans Leidekker <[email protected]> Signed-off-by: Alexandre Julliard <[email protected]> wine commit id 5924321ad63edc1d3fabf22d7b047e4efacbce66 by Piotr Caban <[email protected]>
1 parent b7b9c0c commit a237138

File tree

5 files changed

+77
-16
lines changed

5 files changed

+77
-16
lines changed

dll/win32/msi/action.c

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,18 @@ static int parse_prop( const WCHAR *str, WCHAR *value, int *quotes )
301301

302302
default: break;
303303
}
304-
if (!ignore) *out++ = *p;
304+
if (!ignore && value) *out++ = *p;
305305
if (!count) in_quotes = FALSE;
306306
}
307307

308308
done:
309-
if (!len) *value = 0;
310-
else *out = 0;
309+
if (value)
310+
{
311+
if (!len) *value = 0;
312+
else *out = 0;
313+
}
311314

312-
*quotes = count;
315+
if(quotes) *quotes = count;
313316
return p - str;
314317
}
315318

@@ -385,6 +388,37 @@ UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine,
385388
return ERROR_SUCCESS;
386389
}
387390

391+
const WCHAR *msi_get_command_line_option(const WCHAR *cmd, const WCHAR *option, UINT *len)
392+
{
393+
DWORD opt_len = strlenW(option);
394+
395+
if (!cmd)
396+
return NULL;
397+
398+
while (*cmd)
399+
{
400+
BOOL found = FALSE;
401+
402+
while (*cmd == ' ') cmd++;
403+
if (!*cmd) break;
404+
405+
if(!strncmpiW(cmd, option, opt_len))
406+
found = TRUE;
407+
408+
cmd = strchrW( cmd, '=' );
409+
if(!cmd) break;
410+
cmd++;
411+
while (*cmd == ' ') cmd++;
412+
if (!*cmd) break;
413+
414+
*len = parse_prop( cmd, NULL, NULL);
415+
if (found) return cmd;
416+
cmd += *len;
417+
}
418+
419+
return NULL;
420+
}
421+
388422
WCHAR **msi_split_string( const WCHAR *str, WCHAR sep )
389423
{
390424
LPCWSTR pc;

dll/win32/msi/msi.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static UINT MSI_OpenProductW(LPCWSTR szProduct, MSIPACKAGE **package)
137137
goto done;
138138
}
139139

140-
r = MSI_OpenPackageW(path, package);
140+
r = MSI_OpenPackageW(path, 0, package);
141141

142142
done:
143143
RegCloseKey(props);
@@ -236,7 +236,9 @@ UINT WINAPI MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
236236
UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
237237
{
238238
MSIPACKAGE *package = NULL;
239-
UINT r;
239+
const WCHAR *reinstallmode;
240+
DWORD options = 0;
241+
UINT r, len;
240242

241243
TRACE("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
242244

@@ -246,7 +248,20 @@ UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
246248
if (!*szPackagePath)
247249
return ERROR_PATH_NOT_FOUND;
248250

249-
r = MSI_OpenPackageW( szPackagePath, &package );
251+
reinstallmode = msi_get_command_line_option(szCommandLine, szReinstallMode, &len);
252+
if (reinstallmode)
253+
{
254+
while (len > 0)
255+
{
256+
if (reinstallmode[--len] == 'v' || reinstallmode[len] == 'V')
257+
{
258+
options |= WINE_OPENPACKAGEFLAGS_RECACHE;
259+
break;
260+
}
261+
}
262+
}
263+
264+
r = MSI_OpenPackageW( szPackagePath, options, &package );
250265
if (r == ERROR_SUCCESS)
251266
{
252267
r = MSI_InstallPackage( package, szPackagePath, szCommandLine );
@@ -732,7 +747,7 @@ UINT WINAPI MsiDetermineApplicablePatchesW(LPCWSTR szProductPackagePath,
732747

733748
TRACE("%s, %u, %p\n", debugstr_w(szProductPackagePath), cPatchInfo, pPatchInfo);
734749

735-
r = MSI_OpenPackageW( szProductPackagePath, &package );
750+
r = MSI_OpenPackageW( szProductPackagePath, 0, &package );
736751
if (r != ERROR_SUCCESS)
737752
{
738753
ERR("failed to open package %u\n", r);
@@ -810,7 +825,7 @@ static UINT open_package( const WCHAR *product, const WCHAR *usersid,
810825
if (GetFileAttributesW( sourcepath ) == INVALID_FILE_ATTRIBUTES)
811826
return ERROR_INSTALL_SOURCE_ABSENT;
812827

813-
return MSI_OpenPackageW( sourcepath, package );
828+
return MSI_OpenPackageW( sourcepath, 0, package );
814829
}
815830

816831
UINT WINAPI MsiDeterminePatchSequenceW( LPCWSTR product, LPCWSTR usersid,
@@ -4027,7 +4042,7 @@ UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature, DWORD dw
40274042
strcatW( sourcepath, filename );
40284043

40294044
if (dwReinstallMode & REINSTALLMODE_PACKAGE)
4030-
r = MSI_OpenPackageW( sourcepath, &package );
4045+
r = MSI_OpenPackageW( sourcepath, 0, &package );
40314046
else
40324047
r = MSI_OpenProductW( szProduct, &package );
40334048

dll/win32/msi/msipriv.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ extern UINT ACTION_ForceReboot(MSIPACKAGE *package) DECLSPEC_HIDDEN;
799799
extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable ) DECLSPEC_HIDDEN;
800800
extern UINT MSI_SetFeatureStates( MSIPACKAGE *package ) DECLSPEC_HIDDEN;
801801
extern UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine, BOOL preserve_case ) DECLSPEC_HIDDEN;
802+
extern const WCHAR *msi_get_command_line_option( const WCHAR *cmd, const WCHAR *option, UINT *len ) DECLSPEC_HIDDEN;
802803
extern UINT msi_schedule_action( MSIPACKAGE *package, UINT script, const WCHAR *action ) DECLSPEC_HIDDEN;
803804
extern INSTALLSTATE msi_get_component_action( MSIPACKAGE *package, MSICOMPONENT *comp ) DECLSPEC_HIDDEN;
804805
extern INSTALLSTATE msi_get_feature_action( MSIPACKAGE *package, MSIFEATURE *feature ) DECLSPEC_HIDDEN;
@@ -863,8 +864,9 @@ extern UINT msi_view_get_row(MSIDATABASE *, MSIVIEW *, UINT, MSIRECORD **) DECLS
863864
extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel ) DECLSPEC_HIDDEN;
864865

865866
/* package internals */
867+
#define WINE_OPENPACKAGEFLAGS_RECACHE 0x80000000
866868
extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE * ) DECLSPEC_HIDDEN;
867-
extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE **pPackage ) DECLSPEC_HIDDEN;
869+
extern UINT MSI_OpenPackageW( LPCWSTR szPackage, DWORD dwOptions, MSIPACKAGE **pPackage ) DECLSPEC_HIDDEN;
868870
extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR ) DECLSPEC_HIDDEN;
869871
extern INT MSI_ProcessMessageVerbatim( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * ) DECLSPEC_HIDDEN;
870872
extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * ) DECLSPEC_HIDDEN;

dll/win32/msi/package.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ UINT msi_set_original_database_property( MSIDATABASE *db, const WCHAR *package )
14331433
return r;
14341434
}
14351435

1436-
UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
1436+
UINT MSI_OpenPackageW(LPCWSTR szPackage, DWORD dwOptions, MSIPACKAGE **pPackage)
14371437
{
14381438
static const WCHAR dotmsi[] = {'.','m','s','i',0};
14391439
MSIDATABASE *db;
@@ -1516,6 +1516,16 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
15161516
if (localfile_attr & FILE_ATTRIBUTE_READONLY)
15171517
SetFileAttributesW( localfile, localfile_attr & ~FILE_ATTRIBUTE_READONLY);
15181518
}
1519+
else if (dwOptions & WINE_OPENPACKAGEFLAGS_RECACHE)
1520+
{
1521+
if (!CopyFileW( file, localfile, FALSE ))
1522+
{
1523+
r = GetLastError();
1524+
WARN("unable to update cached package (%u)\n", r);
1525+
msiobj_release( &db->hdr );
1526+
return r;
1527+
}
1528+
}
15191529
else
15201530
product_version = get_product_version( db );
15211531
msiobj_release( &db->hdr );
@@ -1669,7 +1679,7 @@ UINT WINAPI MsiOpenPackageExW(LPCWSTR szPackage, DWORD dwOptions, MSIHANDLE *phP
16691679
if( dwOptions )
16701680
FIXME("dwOptions %08x not supported\n", dwOptions);
16711681

1672-
ret = MSI_OpenPackageW( szPackage, &package );
1682+
ret = MSI_OpenPackageW( szPackage, 0, &package );
16731683
if( ret == ERROR_SUCCESS )
16741684
{
16751685
*phPackage = alloc_msihandle( &package->hdr );

modules/rostests/winetests/msi/package.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,15 +3840,15 @@ static void test_states(void)
38403840
r = MsiInstallProductA(msifile2, "");
38413841
ok(r == ERROR_PRODUCT_VERSION, "Expected ERROR_PRODUCT_VERSION, got %d\n", r);
38423842

3843-
r = MsiInstallProductA(msifile2, "REINSTALLMODE=v");
3844-
todo_wine ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3843+
r = MsiInstallProductA(msifile2, "REINSTALLMODe=V");
3844+
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
38453845

38463846
r = MsiOpenProductA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", &hprod);
38473847
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
38483848
size = MAX_PATH;
38493849
r = MsiGetProductPropertyA(hprod, "ProductVersion", value, &size);
38503850
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3851-
todo_wine ok(!strcmp(value, "1.1.2"), "ProductVersion = %s\n", value);
3851+
ok(!strcmp(value, "1.1.2"), "ProductVersion = %s\n", value);
38523852
MsiCloseHandle(hprod);
38533853

38543854
/* major upgrade test */

0 commit comments

Comments
 (0)