summaryrefslogtreecommitdiff
path: root/win/packaging
diff options
context:
space:
mode:
authorRasmus Johansson <razze@iki.fi>2019-11-17 10:39:47 +0200
committerRasmus Johansson <razze@iki.fi>2019-11-26 17:17:54 +0200
commitb6f7ec6a5b8da27866136d50f50337fcce64eff5 (patch)
tree22ef6f29eaf5cf9d140b9381e98d123a53327bc4 /win/packaging
parentf9ceb0a67ffb20631c936a7e8e8776c000d677ac (diff)
downloadmariadb-git-b6f7ec6a5b8da27866136d50f50337fcce64eff5.tar.gz
MDEV-19781 Create MariaDB named commands on Windowsbb-10.4-MDEV-19781
Added CreateSymlinks and DeleteSymlinks functions to CustomAction.cpp. Extra.wxs.in calls them.
Diffstat (limited to 'win/packaging')
-rw-r--r--win/packaging/CMakeLists.txt2
-rw-r--r--win/packaging/ca/CustomAction.cpp505
-rw-r--r--win/packaging/ca/CustomAction.def2
-rw-r--r--win/packaging/create_msi.cmake5
-rw-r--r--win/packaging/extra.wxs.in28
5 files changed, 437 insertions, 105 deletions
diff --git a/win/packaging/CMakeLists.txt b/win/packaging/CMakeLists.txt
index 9e06638a991..280be75c6d7 100644
--- a/win/packaging/CMakeLists.txt
+++ b/win/packaging/CMakeLists.txt
@@ -21,8 +21,6 @@ IF(MSVC_VERSION LESS 1600)
RETURN()
ENDIF()
-
-
SET(MANUFACTURER "MariaDB Corporation Ab")
SET(WIX_BIN_PATHS)
FOREACH(WIX_VER 3.9 3.10 3.11)
diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp
index bc3fcfea94f..4c2c1d056ed 100644
--- a/win/packaging/ca/CustomAction.cpp
+++ b/win/packaging/ca/CustomAction.cpp
@@ -32,6 +32,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#include <shellapi.h>
#include <stdlib.h>
#include <winservice.h>
+#include <string>
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <vector>
+#include <map>
+
+using namespace std;
#define ONE_MB 1048576
UINT ExecRemoveDataDirectory(wchar_t *dir)
@@ -56,7 +64,7 @@ UINT ExecRemoveDataDirectory(wchar_t *dir)
}
-extern "C" UINT __stdcall RemoveDataDirectory(MSIHANDLE hInstall)
+extern "C" UINT __stdcall RemoveDataDirectory(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
@@ -72,13 +80,13 @@ extern "C" UINT __stdcall RemoveDataDirectory(MSIHANDLE hInstall)
er= ExecRemoveDataDirectory(dir);
WcaLog(LOGMSG_STANDARD, "SHFileOperation returned %d", er);
LExit:
- return WcaFinalize(er);
+ return WcaFinalize(er);
}
/*
Escape command line parameter fpr pass to CreateProcess().
- We assume out has enough space to include encoded string
+ We assume out has enough space to include encoded string
2*wcslen(in) is enough.
It is assumed that called will add double quotation marks before and after
@@ -106,21 +114,21 @@ static void EscapeCommandLine(const wchar_t *in, wchar_t *out, size_t buflen)
}
pos= 0;
- for(int i = 0 ; ; i++)
+ for(int i = 0 ; ; i++)
{
size_t n_backslashes = 0;
wchar_t c;
- while (in[i] == L'\\')
+ while (in[i] == L'\\')
{
i++;
n_backslashes++;
}
c= in[i];
- if (c == 0)
+ if (c == 0)
{
/*
- Escape all backslashes, but let the terminating double quotation mark
+ Escape all backslashes, but let the terminating double quotation mark
that caller adds be interpreted as a metacharacter.
*/
for(size_t j= 0; j < 2*n_backslashes;j++)
@@ -129,7 +137,7 @@ static void EscapeCommandLine(const wchar_t *in, wchar_t *out, size_t buflen)
}
break;
}
- else if (c == L'"')
+ else if (c == L'"')
{
/*
Escape all backslashes and the following double quotation mark.
@@ -140,7 +148,7 @@ static void EscapeCommandLine(const wchar_t *in, wchar_t *out, size_t buflen)
}
out[pos++]= L'"';
}
- else
+ else
{
/* Backslashes aren't special here. */
for (size_t j=0; j < n_backslashes; j++)
@@ -151,11 +159,11 @@ static void EscapeCommandLine(const wchar_t *in, wchar_t *out, size_t buflen)
}
out[pos++]= 0;
}
-/*
- Check for if directory is empty during install,
+/*
+ Check for if directory is empty during install,
sets "<PROPERTY>_NOT_EMPTY" otherise
*/
-extern "C" UINT __stdcall CheckDirectoryEmpty(MSIHANDLE hInstall,
+extern "C" UINT __stdcall CheckDirectoryEmpty(MSIHANDLE hInstall,
const wchar_t *PropertyName)
{
HRESULT hr = S_OK;
@@ -165,14 +173,14 @@ extern "C" UINT __stdcall CheckDirectoryEmpty(MSIHANDLE hInstall,
WIN32_FIND_DATAW data;
HANDLE h;
bool empty;
-
+
hr = WcaInitialize(hInstall, __FUNCTION__);
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
MsiGetPropertyW(hInstall, PropertyName, buf, &len);
wcscat_s(buf, MAX_PATH, L"*.*");
-
+
WcaLog(LOGMSG_STANDARD, "Checking files in %S", buf);
h= FindFirstFile(buf, &data);
@@ -198,7 +206,7 @@ extern "C" UINT __stdcall CheckDirectoryEmpty(MSIHANDLE hInstall,
}
if(empty)
- WcaLog(LOGMSG_STANDARD, "Directory %S is empty or non-existent",
+ WcaLog(LOGMSG_STANDARD, "Directory %S is empty or non-existent",
PropertyName);
else
WcaLog(LOGMSG_STANDARD, "Directory %S is NOT empty", PropertyName);
@@ -208,7 +216,7 @@ extern "C" UINT __stdcall CheckDirectoryEmpty(MSIHANDLE hInstall,
WcaSetProperty(buf, empty? L"":L"1");
LExit:
- return WcaFinalize(er);
+ return WcaFinalize(er);
}
extern "C" UINT __stdcall CheckDataDirectoryEmpty(MSIHANDLE hInstall)
@@ -220,12 +228,12 @@ bool CheckServiceExists(const wchar_t *name)
{
SC_HANDLE manager =0, service=0;
manager = OpenSCManager( NULL, NULL, SC_MANAGER_CONNECT);
- if (!manager)
+ if (!manager)
{
return false;
}
- service = OpenService(manager, name, SC_MANAGER_CONNECT);
+ service = OpenService(manager, name, SC_MANAGER_CONNECT);
if(service)
CloseServiceHandle(service);
CloseServiceHandle(manager);
@@ -239,11 +247,11 @@ bool ExecRemoveService(const wchar_t *name)
SC_HANDLE manager =0, service=0;
manager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS);
bool ret;
- if (!manager)
+ if (!manager)
{
return false;
}
- service = OpenService(manager, name, DELETE);
+ service = OpenService(manager, name, DELETE);
if(service)
{
ret= DeleteService(service);
@@ -289,7 +297,7 @@ bool IsPortFree(short port)
}
-/*
+/*
Helper function used in filename normalization.
Removes leading quote and terminates string at the position of the next one
(if applicable, does not change string otherwise). Returns modified string
@@ -310,23 +318,23 @@ wchar_t *strip_quotes(wchar_t *s)
/*
Checks for consistency of service configuration.
- It can happen that SERVICENAME or DATADIR
- MSI properties are in inconsistent state after somebody upgraded database
- We catch this case during uninstall. In particular, either service is not
+ It can happen that SERVICENAME or DATADIR
+ MSI properties are in inconsistent state after somebody upgraded database
+ We catch this case during uninstall. In particular, either service is not
removed even if SERVICENAME was set (but this name is reused by someone else)
or data directory is not removed (if it is used by someone else). To find out
- whether service name and datadirectory are in use For every service,
+ whether service name and datadirectory are in use For every service,
configuration is read and checked as follows:
- look if a service has to do something with mysql
- - If so, check its name against SERVICENAME. if match, check binary path
+ - If so, check its name against SERVICENAME. if match, check binary path
against INSTALLDIR\bin. If binary path does not match, then service runs
under different installation and won't be removed.
- Check options file for datadir and look if this is inside this
installation's datadir don't remove datadir if this is the case.
- "Don't remove" in this context means that custom action is removing
- SERVICENAME property or CLEANUPDATA property, which later on in course of
+ "Don't remove" in this context means that custom action is removing
+ SERVICENAME property or CLEANUPDATA property, which later on in course of
installation mean, that either datadir or service is kept.
*/
@@ -367,15 +375,15 @@ void CheckServiceConfig(
if(!is_my_service)
{
WcaLog(LOGMSG_STANDARD, "service does not match current service");
- /*
+ /*
TODO probably the best thing possible would be to add temporary
row to MSI ServiceConfig table with remove on uninstall
*/
}
else if (!same_bindir)
{
- WcaLog(LOGMSG_STANDARD,
- "Service name matches, but not the executable path directory, mine is %S",
+ WcaLog(LOGMSG_STANDARD,
+ "Service name matches, but not the executable path directory, mine is %S",
bindir);
WcaSetProperty(L"SERVICENAME", L"");
}
@@ -392,10 +400,10 @@ void CheckServiceConfig(
WcaLog(LOGMSG_STANDARD, "parsed defaults file is %S", defaults_file);
- if (GetPrivateProfileStringW(L"mysqld", L"datadir", NULL, current_datadir,
+ if (GetPrivateProfileStringW(L"mysqld", L"datadir", NULL, current_datadir,
MAX_PATH, defaults_file) == 0)
{
- WcaLog(LOGMSG_STANDARD,
+ WcaLog(LOGMSG_STANDARD,
"Cannot find datadir in ini file '%S'", defaults_file);
goto end;
}
@@ -404,18 +412,18 @@ void CheckServiceConfig(
strip_quotes(current_datadir);
/* Convert to Windows path */
- if (GetFullPathNameW(current_datadir, MAX_PATH, normalized_current_datadir,
+ if (GetFullPathNameW(current_datadir, MAX_PATH, normalized_current_datadir,
NULL))
{
/* Add backslash to be compatible with directory formats in MSI */
wcsncat(normalized_current_datadir, L"\\", MAX_PATH+1);
- WcaLog(LOGMSG_STANDARD, "normalized current datadir is '%S'",
+ WcaLog(LOGMSG_STANDARD, "normalized current datadir is '%S'",
normalized_current_datadir);
}
if (_wcsicmp(datadir, normalized_current_datadir) == 0 && !same_bindir)
{
- WcaLog(LOGMSG_STANDARD,
+ WcaLog(LOGMSG_STANDARD,
"database directory from current installation, but different mysqld.exe");
WcaSetProperty(L"CLEANUPDATA", L"");
}
@@ -427,13 +435,13 @@ end:
/*
Checks if database directory or service are modified by user
For example, service may point to different mysqld.exe that it was originally
- installed, or some different service might use this database directory. This
- would normally mean user has done an upgrade of the database and in this case
+ installed, or some different service might use this database directory. This
+ would normally mean user has done an upgrade of the database and in this case
uninstall should neither delete service nor database directory.
- If this function find that service is modified by user (mysqld.exe used by
+ If this function find that service is modified by user (mysqld.exe used by
service does not point to the installation bin directory), MSI public variable
- SERVICENAME is removed, if DATADIR is used by some other service, variables
+ SERVICENAME is removed, if DATADIR is used by some other service, variables
DATADIR and CLEANUPDATA are removed.
The effect of variable removal is that service does not get uninstalled and
@@ -453,11 +461,11 @@ extern "C" UINT CheckDBInUse(MSIHANDLE hInstall)
wchar_t *datadir= NULL;
wchar_t *bindir=NULL;
- SC_HANDLE scm = NULL;
- ULONG bufsize = sizeof(buf);
- ULONG bufneed = 0x00;
- ULONG num_services = 0x00;
- LPENUM_SERVICE_STATUS_PROCESS info = NULL;
+ SC_HANDLE scm = NULL;
+ ULONG bufsize = sizeof(buf);
+ ULONG bufneed = 0x00;
+ ULONG num_services = 0x00;
+ LPENUM_SERVICE_STATUS_PROCESS info = NULL;
BOOL ok;
hr = WcaInitialize(hInstall, __FUNCTION__);
@@ -467,48 +475,49 @@ extern "C" UINT CheckDBInUse(MSIHANDLE hInstall)
WcaGetProperty(L"SERVICENAME", &servicename);
WcaGetProperty(L"DATADIR", &datadir);
WcaGetFormattedString(L"[INSTALLDIR]bin\\", &bindir);
+
WcaLog(LOGMSG_STANDARD,"SERVICENAME=%S, DATADIR=%S, bindir=%S",
servicename, datadir, bindir);
- scm = OpenSCManager(NULL, NULL,
- SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_CONNECT);
- if (scm == NULL)
- {
+ scm = OpenSCManager(NULL, NULL,
+ SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_CONNECT);
+ if (scm == NULL)
+ {
ExitOnFailure(E_FAIL, "OpenSCManager failed");
}
ok = EnumServicesStatusExW( scm,
- SC_ENUM_PROCESS_INFO,
+ SC_ENUM_PROCESS_INFO,
SERVICE_WIN32,
- SERVICE_STATE_ALL,
- buf,
- bufsize,
- &bufneed,
- &num_services,
- NULL,
+ SERVICE_STATE_ALL,
+ buf,
+ bufsize,
+ &bufneed,
+ &num_services,
+ NULL,
NULL);
- if(!ok)
+ if(!ok)
{
WcaLog(LOGMSG_STANDARD, "last error %d", GetLastError());
ExitOnFailure(E_FAIL, "EnumServicesStatusExW failed");
}
- info = (LPENUM_SERVICE_STATUS_PROCESS)buf;
+ info = (LPENUM_SERVICE_STATUS_PROCESS)buf;
for (ULONG i=0; i < num_services; i++)
{
- SC_HANDLE service= OpenServiceW(scm, info[i].lpServiceName,
+ SC_HANDLE service= OpenServiceW(scm, info[i].lpServiceName,
SERVICE_QUERY_CONFIG);
if (!service)
continue;
WcaLog(LOGMSG_VERBOSE, "Checking Service %S", info[i].lpServiceName);
- QUERY_SERVICE_CONFIGW *config=
+ QUERY_SERVICE_CONFIGW *config=
(QUERY_SERVICE_CONFIGW *)(void *)config_buffer;
DWORD needed;
- BOOL ok= QueryServiceConfigW(service, config,sizeof(config_buffer),
+ BOOL ok= QueryServiceConfigW(service, config,sizeof(config_buffer),
&needed);
CloseServiceHandle(service);
if (ok)
{
- CheckServiceConfig(servicename, datadir, bindir, info[i].lpServiceName,
+ CheckServiceConfig(servicename, datadir, bindir, info[i].lpServiceName,
config);
}
}
@@ -520,18 +529,18 @@ LExit:
ReleaseStr(servicename);
ReleaseStr(datadir);
ReleaseStr(bindir);
- return WcaFinalize(er);
+ return WcaFinalize(er);
}
-/*
+/*
Get maximum size of the buffer process can allocate.
this is calculated as min(RAM,virtualmemorylimit)
For 32bit processes, virtual address memory is 2GB (x86 OS)
or 4GB(x64 OS).
-
- Fragmentation due to loaded modules, heap and stack
+
+ Fragmentation due to loaded modules, heap and stack
limit maximum size of continuous memory block further,
- so that limit for 32 bit process is about 1200 on 32 bit OS
+ so that limit for 32 bit process is about 1200 on 32 bit OS
or 2000 MB on 64 bit OS(found experimentally).
*/
unsigned long long GetMaxBufferSize(unsigned long long totalPhys)
@@ -549,9 +558,9 @@ unsigned long long GetMaxBufferSize(unsigned long long totalPhys)
/*
- Checks SERVICENAME, PORT and BUFFERSIZE parameters
+ Checks SERVICENAME, PORT and BUFFERSIZE parameters
*/
-extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
+extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
{
wchar_t ServiceName[MAX_PATH]={0};
wchar_t SkipNetworking[MAX_PATH]={0};
@@ -574,7 +583,7 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
-
+
MsiGetPropertyW (hInstall, L"SERVICENAME", ServiceName, &ServiceNameLen);
if(ServiceName[0])
{
@@ -585,10 +594,10 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
}
for(DWORD i=0; i< ServiceNameLen;i++)
{
- if(ServiceName[i] == L'\\' || ServiceName[i] == L'/'
+ if(ServiceName[i] == L'\\' || ServiceName[i] == L'/'
|| ServiceName[i]=='\'' || ServiceName[i] ==L'"')
{
- ErrorMsg =
+ ErrorMsg =
L"Invalid service name. Forward slash and back slash are forbidden."
L"Single and double quotes are also not permitted.";
goto LExit;
@@ -608,10 +617,10 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
sizeof(EscapedPassword)/sizeof(EscapedPassword[0]));
MsiSetPropertyW(hInstall,L"ESCAPEDPASSWORD",EscapedPassword);
- MsiGetPropertyW(hInstall, L"SKIPNETWORKING", SkipNetworking,
+ MsiGetPropertyW(hInstall, L"SKIPNETWORKING", SkipNetworking,
&SkipNetworkingLen);
MsiGetPropertyW(hInstall, L"PORT", Port, &PortLen);
-
+
if(SkipNetworking[0]==0 && Port[0] != 0)
{
/* Strip spaces */
@@ -644,13 +653,13 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
short port = (short)_wtoi(Port);
if (!IsPortFree(port))
{
- ErrorMsg =
+ ErrorMsg =
L"The TCP Port you selected is already in use. "
L"Please choose a different port.";
goto LExit;
}
}
-
+
MsiGetPropertyW (hInstall, L"STDCONFIG", QuickConfig, &QuickConfigLen);
if(QuickConfig[0] !=0)
{
@@ -660,7 +669,7 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
if (!GlobalMemoryStatusEx(&memstatus))
{
- WcaLog(LOGMSG_STANDARD, "Error %u from GlobalMemoryStatusEx",
+ WcaLog(LOGMSG_STANDARD, "Error %u from GlobalMemoryStatusEx",
GetLastError());
er= ERROR_INSTALL_FAILURE;
goto LExit;
@@ -714,7 +723,7 @@ LExit:
return WcaFinalize(er);
}
-/*
+/*
Sets Innodb buffer pool size (1/8 of RAM by default), if not already specified
via command line.
Calculates innodb log file size as min(50, innodb buffer pool size/8)
@@ -745,7 +754,7 @@ extern "C" UINT __stdcall PresetDatabaseProperties(MSIHANDLE hInstall)
memstatus.dwLength = sizeof(memstatus);
if (!GlobalMemoryStatusEx(&memstatus))
{
- WcaLog(LOGMSG_STANDARD, "Error %u from GlobalMemoryStatusEx",
+ WcaLog(LOGMSG_STANDARD, "Error %u from GlobalMemoryStatusEx",
GetLastError());
er= ERROR_INSTALL_FAILURE;
goto LExit;
@@ -754,14 +763,14 @@ extern "C" UINT __stdcall PresetDatabaseProperties(MSIHANDLE hInstall)
/* Give innodb 12.5% of available physical memory. */
InnodbBufferPoolSize= totalPhys/ONE_MB/8;
#ifdef _M_IX86
- /*
+ /*
For 32 bit processes, take virtual address space limitation into account.
Do not try to use more than 3/4 of virtual address space, even if there
is plenty of physical memory.
*/
InnodbBufferPoolSize= min(GetMaxBufferSize(totalPhys)/ONE_MB*3/4,
InnodbBufferPoolSize);
- #endif
+ #endif
swprintf_s(buff, L"%llu",InnodbBufferPoolSize);
MsiSetPropertyW(hInstall, L"BUFFERPOOLSIZE", buff);
}
@@ -816,7 +825,7 @@ static void DumpErrorLog(const wchar_t *dir)
}
/* Remove service and data directory created by CreateDatabase operation */
-extern "C" UINT __stdcall CreateDatabaseRollback(MSIHANDLE hInstall)
+extern "C" UINT __stdcall CreateDatabaseRollback(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
@@ -857,17 +866,17 @@ extern "C" UINT __stdcall CreateDatabaseRollback(MSIHANDLE hInstall)
ExecRemoveDataDirectory(dir);
}
LExit:
- return WcaFinalize(er);
+ return WcaFinalize(er);
}
/*
- Enables/disables optional "Launch upgrade wizard" checkbox at the end of
+ Enables/disables optional "Launch upgrade wizard" checkbox at the end of
installation
*/
#define MAX_VERSION_PROPERTY_SIZE 64
-extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
+extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
@@ -884,7 +893,7 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
hr = WcaInitialize(hInstall, __FUNCTION__);
WcaLog(LOGMSG_STANDARD, "Initialized.");
- if (MsiGetPropertyW(hInstall, L"ProductVersion", installerVersion, &size)
+ if (MsiGetPropertyW(hInstall, L"ProductVersion", installerVersion, &size)
!= ERROR_SUCCESS)
{
hr = HRESULT_FROM_WIN32(GetLastError());
@@ -903,12 +912,12 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
hr = HRESULT_FROM_WIN32(GetLastError());
ExitOnFailure(hr, "MsiGetPropertyW failed");
}
-
- scm = OpenSCManager(NULL, NULL,
- SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_CONNECT);
- if (scm == NULL)
- {
+
+ scm = OpenSCManager(NULL, NULL,
+ SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_CONNECT);
+ if (scm == NULL)
+ {
hr = HRESULT_FROM_WIN32(GetLastError());
ExitOnFailure(hr,"OpenSCManager failed");
}
@@ -921,7 +930,7 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
DWORD num_services;
ok= EnumServicesStatusExW(scm, SC_ENUM_PROCESS_INFO, SERVICE_WIN32,
SERVICE_STATE_ALL, buf, bufsize, &bufneed, &num_services, NULL, NULL);
- if(!ok)
+ if(!ok)
{
hr = HRESULT_FROM_WIN32(GetLastError());
ExitOnFailure(hr,"EnumServicesStatusEx failed");
@@ -931,11 +940,11 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
index=-1;
for (ULONG i=0; i < num_services; i++)
{
- SC_HANDLE service= OpenServiceW(scm, info[i].lpServiceName,
+ SC_HANDLE service= OpenServiceW(scm, info[i].lpServiceName,
SERVICE_QUERY_CONFIG);
if (!service)
continue;
- QUERY_SERVICE_CONFIGW *config=
+ QUERY_SERVICE_CONFIGW *config=
(QUERY_SERVICE_CONFIGW*)(void *)config_buffer;
DWORD needed;
ok= QueryServiceConfigW(service, config,sizeof(config_buffer),
@@ -946,7 +955,7 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
mysqld_service_properties props;
if (get_mysql_service_properties(config->lpBinaryPathName, &props))
continue;
- /*
+ /*
Only look for services that have mysqld.exe outside of the current
installation directory.
*/
@@ -955,7 +964,7 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
WcaLog(LOGMSG_STANDARD, "found service %S, major=%d, minor=%d",
info[i].lpServiceName, props.version_major, props.version_minor);
if(props.version_major < installerMajorVersion
- || (props.version_major == installerMajorVersion &&
+ || (props.version_major == installerMajorVersion &&
props.version_minor <= installerMinorVersion))
{
upgradableServiceFound= true;
@@ -979,7 +988,7 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall)
LExit:
if(scm)
CloseServiceHandle(scm);
- return WcaFinalize(er);
+ return WcaFinalize(er);
}
@@ -1003,3 +1012,305 @@ extern "C" BOOL WINAPI DllMain(
return TRUE;
}
+
+// check if file exists
+inline bool checkIfFileExists (wstring& name) {
+ string sLog = "checkIfFileExists, ";
+
+ string sName(name.begin(), name.end() );
+
+ ifstream f(sName);
+
+ sLog.append(sName);
+ sLog.append(", result: ");
+ bool fileExists = f.good();
+
+ if (f.good())
+ sLog.append("true");
+ else
+ sLog.append("false");
+
+ WcaLog(LOGMSG_STANDARD, sLog.c_str());
+
+ return f.good();
+}
+
+// string to wstring
+std::wstring s2ws(const std::string& s)
+{
+ int len;
+ int slength = (int)s.length() + 1;
+ len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
+ wchar_t* buf = new wchar_t[len];
+ MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
+ std::wstring r(buf);
+ delete[] buf;
+ return r;
+}
+
+/* MDEV-19781 MariaDB symlinks on Windows */
+extern "C" UINT __stdcall CreateSymlinks(MSIHANDLE hInstall)
+{
+ HRESULT hr = S_OK;
+ UINT er = ERROR_SUCCESS;
+ wchar_t customActionData[10000];
+ wchar_t installDir[MAX_PATH];
+ DWORD len = 10000;
+ wchar_t installerVersion[MAX_VERSION_PROPERTY_SIZE];
+ DWORD size = MAX_VERSION_PROPERTY_SIZE;
+ wchar_t binDir[MAX_PATH];
+ size_t blen = NULL;
+
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
+
+ if (MsiGetPropertyW(hInstall, L"CustomActionData", customActionData, &len) != ERROR_SUCCESS)
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hr);
+ }
+
+ if (MsiGetPropertyW(hInstall, L"ProductVersion", installerVersion, &size) != ERROR_SUCCESS)
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hr);
+ }
+
+ MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hr);
+
+ wstring wsCustomActionData(customActionData);
+ string sCustomActionData(wsCustomActionData.begin(), wsCustomActionData.end());
+ WcaLog(LOGMSG_STANDARD, sCustomActionData.c_str());
+
+ stringstream ss;
+ ss << sCustomActionData;
+ vector<string> vCustomActionData;
+
+ while( ss.good() )
+ {
+ string substr;
+ getline( ss, substr, '|' );
+ WcaLog(LOGMSG_STANDARD, substr.c_str());
+ vCustomActionData.push_back( substr );
+ }
+
+ int i = 0;
+ string sBinPath = "";
+ string sPathFrom = "";
+ string sPathTo = "";
+
+ for(auto const& value: vCustomActionData) {
+ if (i == 0) {
+ sBinPath = value;
+ sBinPath.append("bin\\");
+ } else if (i == 1) {
+ sPathFrom = value;
+ } else if (i == 2) {
+ sPathTo = value;
+ }
+
+ WcaLog(LOGMSG_STANDARD, value.c_str());
+
+ i++;
+ }
+
+ WcaLog(LOGMSG_STANDARD, sBinPath.c_str());
+ WcaLog(LOGMSG_STANDARD, sPathFrom.c_str());
+ WcaLog(LOGMSG_STANDARD, sPathTo.c_str());
+
+ stringstream ssPathFrom, ssPathTo;
+ ssPathFrom << sPathFrom;
+ ssPathTo << sPathTo;
+ vector<string> vPathFrom;
+ vector<string> vPathTo;
+
+ while(ssPathFrom.good()) {
+ string substr = "";
+ getline(ssPathFrom, substr, ';');
+ substr = substr.insert(0, sBinPath);
+ WcaLog(LOGMSG_STANDARD, substr.c_str());
+ vPathFrom.push_back(substr);
+ }
+
+ while(ssPathTo.good()) {
+ string substr = "";
+ getline(ssPathTo, substr, ';');
+ substr = substr.insert(0, sBinPath);
+ WcaLog(LOGMSG_STANDARD, substr.c_str());
+ vPathTo.push_back(substr);
+ }
+
+ i = 0;
+
+ for(auto const& value: vPathTo) {
+ string &sTmpPathFrom = vPathFrom[i];
+ string &sTmpPathTo = vPathTo[i];
+
+ sTmpPathFrom.append(".exe");
+ sTmpPathTo.append(".exe");
+
+ wstring wsPathFrom = s2ws(sTmpPathFrom);
+ LPCWSTR lPathFrom = wsPathFrom.c_str();
+ wstring wsPathTo = s2ws(sTmpPathTo);
+ LPCWSTR lPathTo = wsPathTo.c_str();
+
+ int createdSymlink = -1;
+
+ if (checkIfFileExists(wsPathFrom))
+ createdSymlink = CreateSymbolicLinkW(wsPathTo.c_str(), wsPathFrom.c_str(), 0);
+
+ string created = "Created symlink: ";
+ created.append(sTmpPathTo);
+ created.append(" --> ");
+ created.append(sTmpPathFrom);
+ created.append(", result= ");
+ created.append(to_string(createdSymlink));
+
+ WcaLog(LOGMSG_STANDARD, created.c_str());
+
+ i++;
+ }
+
+ ReleaseStr(installDir);
+ ReleaseStr(installerVersion);
+ ReleaseStr(binDir);
+ return WcaFinalize(er);
+}
+
+/* MDEV-19781 MariaDB symlinks on Windows */
+extern "C" UINT __stdcall DeleteSymlinks(MSIHANDLE hInstall)
+{
+ HRESULT hr = S_OK;
+ UINT er = ERROR_SUCCESS;
+ wchar_t customActionData[10000];
+ wchar_t installDir[MAX_PATH];
+ DWORD len = 10000;
+ DWORD size = MAX_VERSION_PROPERTY_SIZE;
+ wchar_t binDir[MAX_PATH];
+ size_t blen = NULL;
+
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ WcaLog(LOGMSG_STANDARD, "DeleteSymlinks initialized.");
+
+ if (MsiGetPropertyW(hInstall, L"CustomActionData", customActionData, &len) != ERROR_SUCCESS)
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hr);
+ }
+
+ wstring wsCustomActionData(customActionData);
+ string sCustomActionData(wsCustomActionData.begin(), wsCustomActionData.end());
+ WcaLog(LOGMSG_STANDARD, sCustomActionData.c_str());
+
+ stringstream ss;
+ ss << sCustomActionData;
+ vector<string> vCustomActionData;
+
+ while( ss.good() )
+ {
+ string substr;
+ getline( ss, substr, '|' );
+ WcaLog(LOGMSG_STANDARD, substr.c_str());
+ vCustomActionData.push_back( substr );
+ }
+
+ int i = 0;
+ string sBinPath = "";
+ string sPathFrom = "";
+ string sPathTo = "";
+
+ for(auto const& value: vCustomActionData) {
+ if (i == 0) {
+ sBinPath = value;
+ sBinPath.append("bin\\");
+ } else if (i == 1) {
+ sPathFrom = value;
+ } else if (i == 2) {
+ sPathTo = value;
+ }
+
+ WcaLog(LOGMSG_STANDARD, value.c_str());
+
+ i++;
+ }
+
+ WcaLog(LOGMSG_STANDARD, sBinPath.c_str());
+ WcaLog(LOGMSG_STANDARD, sPathFrom.c_str());
+ WcaLog(LOGMSG_STANDARD, sPathTo.c_str());
+
+ stringstream ssPathFrom, ssPathTo;
+ ssPathFrom << sPathFrom;
+ ssPathTo << sPathTo;
+ vector<string> vPathFrom;
+ vector<string> vPathTo;
+
+ while(ssPathFrom.good()) {
+ string substr = "";
+ getline(ssPathFrom, substr, ';');
+ substr = substr.insert(0, sBinPath);
+ WcaLog(LOGMSG_STANDARD, substr.c_str());
+ vPathFrom.push_back(substr);
+ }
+
+ while(ssPathTo.good()) {
+ string substr = "";
+ getline(ssPathTo, substr, ';');
+ substr = substr.insert(0, sBinPath);
+ WcaLog(LOGMSG_STANDARD, substr.c_str());
+ vPathTo.push_back(substr);
+ }
+
+ i = 0;
+
+ for(auto const& value: vPathTo) {
+ string &sTmpPathFrom = vPathFrom[i];
+ string &sTmpPathTo = vPathTo[i];
+
+ sTmpPathFrom.append(".exe");
+ sTmpPathTo.append(".exe");
+
+ wstring wsPathFrom = s2ws(sTmpPathFrom);
+ LPCWSTR lPathFrom = wsPathFrom.c_str();
+ wstring wsPathTo = s2ws(sTmpPathTo);
+ LPCWSTR lPathTo = wsPathTo.c_str();
+
+ int deletedSymlink = -1;
+
+ if (checkIfFileExists(wsPathTo))
+ deletedSymlink = DeleteFileW(wsPathTo.c_str());
+
+ string deleted = "Deleted symlink: ";
+ deleted.append(sTmpPathTo);
+ deleted.append(" --> ");
+ deleted.append(sTmpPathFrom);
+ deleted.append(", result= ");
+ deleted.append(to_string(deletedSymlink));
+
+ WcaLog(LOGMSG_STANDARD, deleted.c_str());
+
+ i++;
+ }
+/*
+
+ for(size_t i = 0; i < std::size(symlink_to); i++) {
+ wchar_t pathTo[MAX_PATH];
+
+ wcscpy(pathTo, binDir);
+ wcscat(pathTo, symlink_to[i].data());
+
+ wstring wsPathTo(pathTo);
+
+ if ( checkIfFileExists(wsPathTo) ) {
+ DeleteFileW(pathTo);
+ } else {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ ExitOnFailure(hr, "Could not delete symlink");
+ }
+ }
+
+*/
+
+ ReleaseStr(installDir);
+ ReleaseStr(binDir);
+ return WcaFinalize(er);
+} \ No newline at end of file
diff --git a/win/packaging/ca/CustomAction.def b/win/packaging/ca/CustomAction.def
index 0be77a97a08..c99951b4cf9 100644
--- a/win/packaging/ca/CustomAction.def
+++ b/win/packaging/ca/CustomAction.def
@@ -8,3 +8,5 @@ CheckDatabaseProperties
CheckDataDirectoryEmpty
CheckDBInUse
CheckServiceUpgrades
+CreateSymlinks
+DeleteSymlinks
diff --git a/win/packaging/create_msi.cmake b/win/packaging/create_msi.cmake
index ad935803a1e..3135935acfb 100644
--- a/win/packaging/create_msi.cmake
+++ b/win/packaging/create_msi.cmake
@@ -1,3 +1,8 @@
+# get the symlink lists
+#INCLUDE(${CMAKE_SOURCE_DIR}/../../cmake/symlinks.cmake)
+#INCLUDE(symlinks)
+INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/symlinks.cmake)
+
MACRO(MAKE_WIX_IDENTIFIER str varname)
STRING(REPLACE "/" "." ${varname} "${str}")
STRING(REGEX REPLACE "[^a-zA-Z_0-9.]" "_" ${varname} "${${varname}}")
diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in
index 1955799f6f9..68e455d6486 100644
--- a/win/packaging/extra.wxs.in
+++ b/win/packaging/extra.wxs.in
@@ -63,6 +63,9 @@
<Property Id="BUFFERPOOLSIZE" Secure="yes"/>
<!-- Innodb page size -->
<Property Id="PAGESIZE" Secure="yes" Value="16K"/>
+ <!-- Symlinks -->
+ <Property Id="SYMLINK_TOS" Value="@MARIADB_SYMLINK_TOS@" />
+ <Property Id="SYMLINK_FROMS" Value="@MARIADB_SYMLINK_FROMS@" />
<CustomAction Id="LaunchUrl" BinaryKey="WixCA" DllEntry="WixShellExec" Execute="immediate" Return="check" Impersonate="yes" />
@@ -660,11 +663,24 @@
<MergeRef Id="VCRedist"/>
</Feature>
<?endif?>
+
+ <!-- Custom action, create symlinks -->
+ <CustomAction Id="CreateSymlinks.SetProperty" Return="check" Property="CreateSymlinks" Value="[INSTALLDIR]|[SYMLINK_FROMS]|[SYMLINK_TOS]" />
+ <CustomAction Id="CreateSymlinks" BinaryKey="wixca.dll" DllEntry="CreateSymlinks" Execute="deferred" Impersonate="no" Return="ignore" />
+ <CustomAction Id="DeleteSymlinks.SetProperty" Return="check" Property="DeleteSymlinks" Value="[INSTALLDIR]|[SYMLINK_FROMS]|[SYMLINK_TOS]" />
+ <CustomAction Id='DeleteSymlinks' BinaryKey="wixca.dll" DllEntry="DeleteSymlinks" Execute="deferred" Impersonate="no" Return="ignore" />
- <!-- Custom action, call mysql_install_db -->
- <SetProperty Sequence='execute' Before='CreateDatabaseCommand' Id="SKIPNETWORKING" Value="--skip-networking" >SKIPNETWORKING</SetProperty>
- <SetProperty Sequence='execute' Before='CreateDatabaseCommand' Id="ALLOWREMOTEROOTACCESS" Value="--allow-remote-root-access">ALLOWREMOTEROOTACCESS</SetProperty>
- <SetProperty Sequence='execute' Before='CreateDatabaseCommand' Id="DEFAULTUSER" Value="--default-user">DEFAULTUSER</SetProperty>
+ <InstallExecuteSequence>
+ <Custom Action="CreateSymlinks.SetProperty" Before="CreateSymlinks">NOT Installed</Custom>
+ <Custom Action="CreateSymlinks" Before="InstallFinalize">NOT Installed</Custom>
+ <Custom Action="DeleteSymlinks.SetProperty" Before="DeleteSymlinks">Installed AND NOT REINSTALL</Custom>
+ <Custom Action="DeleteSymlinks" Before="RemoveFiles">Installed AND NOT REINSTALL</Custom>
+ </InstallExecuteSequence>
+
+ <!-- Custom action, call mysql_install_db -->
+ <SetProperty Sequence='execute' Before='CreateDatabaseCommand' Id="SKIPNETWORKING" Value="--skip-networking" >SKIPNETWORKING</SetProperty>
+ <SetProperty Sequence='execute' Before='CreateDatabaseCommand' Id="ALLOWREMOTEROOTACCESS" Value="--allow-remote-root-access">ALLOWREMOTEROOTACCESS</SetProperty>
+ <SetProperty Sequence='execute' Before='CreateDatabaseCommand' Id="DEFAULTUSER" Value="--default-user">DEFAULTUSER</SetProperty>
<CustomAction Id='CheckDatabaseProperties' BinaryKey='wixca.dll' DllEntry='CheckDatabaseProperties' />
<CustomAction Id='PresetDatabaseProperties' BinaryKey='wixca.dll' DllEntry='PresetDatabaseProperties' />
<CustomAction Id="CreateDatabaseCommand" Property="CreateDatabase"
@@ -881,10 +897,10 @@
>
<![CDATA[ NOT(NSISINSTALLKEY << "MariaDB @MAJOR_VERSION@.@MINOR_VERSION@.") OR Installed]]>
</Condition>
- <Condition Message=
+ <!-- Condition Message=
'Setting the ALLUSERS property is not allowed because [ProductName] is a per-machine application. Setup will now exit.'>
<![CDATA[ALLUSERS = "1"]]>
- </Condition>
+ </Condition -->
<Condition Message='This application is only supported on Windows Vista, Windows Server 2008, or higher.'>
<![CDATA[Installed OR (VersionNT >= 600)]]>
</Condition>