cpython/Tools/msi/msisupport.c

94 lines
2.6 KiB
C
Raw Normal View History

2004-12-12 11:29:21 -04:00
#include "windows.h"
#include "msiquery.h"
/* Print a debug message to the installer log file.
* To see the debug messages, install with
* msiexec /i pythonxy.msi /l*v python.log
*/
static UINT debug(MSIHANDLE hInstall, LPCSTR msg)
2004-12-12 11:29:21 -04:00
{
MSIHANDLE hRec = MsiCreateRecord(1);
if (!hRec || MsiRecordSetStringA(hRec, 1, msg) != ERROR_SUCCESS) {
2004-12-12 11:29:21 -04:00
return ERROR_INSTALL_FAILURE;
}
MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hRec);
MsiCloseHandle(hRec);
return ERROR_SUCCESS;
}
/* Check whether the TARGETDIR exists and is a directory.
* Set TargetExists appropriately.
*/
UINT __declspec(dllexport) __stdcall CheckDir(MSIHANDLE hInstall)
{
#define PSIZE 1024
WCHAR wpath[PSIZE];
char path[PSIZE];
2004-12-12 11:29:21 -04:00
UINT result;
DWORD size = PSIZE;
2004-12-12 11:29:21 -04:00
DWORD attributes;
2004-12-12 11:29:21 -04:00
Merged revisions 62954-62959,62961,62963-62967,62969-62970,62972-62973,62975-62976,62978-62982,62984,62987-62996 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62954 | martin.v.loewis | 2008-05-09 16:11:37 -0400 (Fri, 09 May 2008) | 1 line Port to VS 2008. Drop W9x support. ........ r62957 | benjamin.peterson | 2008-05-09 17:30:26 -0400 (Fri, 09 May 2008) | 2 lines In stdtypes.rst, move methods under class directives where applicable ........ r62958 | brett.cannon | 2008-05-09 17:30:36 -0400 (Fri, 09 May 2008) | 2 lines Add a todo list to the module deletion command. ........ r62963 | brett.cannon | 2008-05-09 18:52:28 -0400 (Fri, 09 May 2008) | 2 lines Add support for extension modules in 3.0 deprection command. ........ r62967 | brett.cannon | 2008-05-09 22:25:00 -0400 (Fri, 09 May 2008) | 2 lines Fix some errors in the deprecation warnings for new and user. ........ r62975 | brett.cannon | 2008-05-09 22:54:52 -0400 (Fri, 09 May 2008) | 3 lines Suppress deprecations for packages as well when using test.test_support.import_module(). ........ r62976 | brett.cannon | 2008-05-09 22:57:03 -0400 (Fri, 09 May 2008) | 2 lines Also ignore package deprecations. ........ r62982 | benjamin.peterson | 2008-05-09 23:08:17 -0400 (Fri, 09 May 2008) | 2 lines Add the examples in the json module docstring as a doctest ........ r62992 | martin.v.loewis | 2008-05-10 09:24:09 -0400 (Sat, 10 May 2008) | 2 lines Explicitly refer to current hhp file (2.6a3) ........ r62993 | skip.montanaro | 2008-05-10 10:48:49 -0400 (Sat, 10 May 2008) | 2 lines Note the PyPI-edness of bsddb185 for people who might still need it. ........ r62994 | andrew.kuchling | 2008-05-10 13:36:24 -0400 (Sat, 10 May 2008) | 1 line Docstring typo ........ r62995 | andrew.kuchling | 2008-05-10 13:37:05 -0400 (Sat, 10 May 2008) | 1 line Document the 'line' argument ........ r62996 | andrew.kuchling | 2008-05-10 13:48:45 -0400 (Sat, 10 May 2008) | 1 line #1625509: describe behaviour of import lock ........
2008-05-15 19:51:26 -03:00
result = MsiGetPropertyW(hInstall, L"TARGETDIR", wpath, &size);
2004-12-12 11:29:21 -04:00
if (result != ERROR_SUCCESS)
return result;
wpath[size] = L'\0';
2004-12-12 11:29:21 -04:00
path[size] = L'\0';
Merged revisions 62954-62959,62961,62963-62967,62969-62970,62972-62973,62975-62976,62978-62982,62984,62987-62996 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r62954 | martin.v.loewis | 2008-05-09 16:11:37 -0400 (Fri, 09 May 2008) | 1 line Port to VS 2008. Drop W9x support. ........ r62957 | benjamin.peterson | 2008-05-09 17:30:26 -0400 (Fri, 09 May 2008) | 2 lines In stdtypes.rst, move methods under class directives where applicable ........ r62958 | brett.cannon | 2008-05-09 17:30:36 -0400 (Fri, 09 May 2008) | 2 lines Add a todo list to the module deletion command. ........ r62963 | brett.cannon | 2008-05-09 18:52:28 -0400 (Fri, 09 May 2008) | 2 lines Add support for extension modules in 3.0 deprection command. ........ r62967 | brett.cannon | 2008-05-09 22:25:00 -0400 (Fri, 09 May 2008) | 2 lines Fix some errors in the deprecation warnings for new and user. ........ r62975 | brett.cannon | 2008-05-09 22:54:52 -0400 (Fri, 09 May 2008) | 3 lines Suppress deprecations for packages as well when using test.test_support.import_module(). ........ r62976 | brett.cannon | 2008-05-09 22:57:03 -0400 (Fri, 09 May 2008) | 2 lines Also ignore package deprecations. ........ r62982 | benjamin.peterson | 2008-05-09 23:08:17 -0400 (Fri, 09 May 2008) | 2 lines Add the examples in the json module docstring as a doctest ........ r62992 | martin.v.loewis | 2008-05-10 09:24:09 -0400 (Sat, 10 May 2008) | 2 lines Explicitly refer to current hhp file (2.6a3) ........ r62993 | skip.montanaro | 2008-05-10 10:48:49 -0400 (Sat, 10 May 2008) | 2 lines Note the PyPI-edness of bsddb185 for people who might still need it. ........ r62994 | andrew.kuchling | 2008-05-10 13:36:24 -0400 (Sat, 10 May 2008) | 1 line Docstring typo ........ r62995 | andrew.kuchling | 2008-05-10 13:37:05 -0400 (Sat, 10 May 2008) | 1 line Document the 'line' argument ........ r62996 | andrew.kuchling | 2008-05-10 13:48:45 -0400 (Sat, 10 May 2008) | 1 line #1625509: describe behaviour of import lock ........
2008-05-15 19:51:26 -03:00
attributes = GetFileAttributesW(wpath);
2004-12-12 11:29:21 -04:00
if (attributes == INVALID_FILE_ATTRIBUTES ||
!(attributes & FILE_ATTRIBUTE_DIRECTORY))
{
return MsiSetPropertyA(hInstall, "TargetExists", "0");
2004-12-12 11:29:21 -04:00
} else {
return MsiSetPropertyA(hInstall, "TargetExists", "1");
2004-12-12 11:29:21 -04:00
}
}
/* Update the state of the REGISTRY.tcl component according to the
* Extension and TclTk features. REGISTRY.tcl must be installed
* if both features are installed, and must be absent otherwise.
*/
UINT __declspec(dllexport) __stdcall UpdateEditIDLE(MSIHANDLE hInstall)
{
INSTALLSTATE ext_old, ext_new, tcl_old, tcl_new, reg_new;
UINT result;
result = MsiGetFeatureStateA(hInstall, "Extensions", &ext_old, &ext_new);
2004-12-12 11:29:21 -04:00
if (result != ERROR_SUCCESS)
return result;
result = MsiGetFeatureStateA(hInstall, "TclTk", &tcl_old, &tcl_new);
2004-12-12 11:29:21 -04:00
if (result != ERROR_SUCCESS)
return result;
/* If the current state is Absent, and the user did not select
the feature in the UI, Installer apparently sets the "selected"
state to unknown. Update it to the current value, then. */
if (ext_new == INSTALLSTATE_UNKNOWN)
ext_new = ext_old;
if (tcl_new == INSTALLSTATE_UNKNOWN)
tcl_new = tcl_old;
// XXX consider current state of REGISTRY.tcl?
if (((tcl_new == INSTALLSTATE_LOCAL) ||
(tcl_new == INSTALLSTATE_SOURCE) ||
(tcl_new == INSTALLSTATE_DEFAULT)) &&
((ext_new == INSTALLSTATE_LOCAL) ||
(ext_new == INSTALLSTATE_SOURCE) ||
(ext_new == INSTALLSTATE_DEFAULT))) {
reg_new = INSTALLSTATE_SOURCE;
} else {
reg_new = INSTALLSTATE_ABSENT;
}
result = MsiSetComponentStateA(hInstall, "REGISTRY.tcl", reg_new);
2004-12-12 11:29:21 -04:00
return result;
}
BOOL APIENTRY DllMain(HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
return TRUE;
}