summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Johansson <razze@iki.fi>2019-08-01 13:52:34 +0300
committerRasmus Johansson <razze@iki.fi>2019-08-15 16:35:19 +0300
commit4df2e4ffdfbdd14a6f933c68fc016a71b28c9299 (patch)
tree813ce12222ad2374fb0beafecc0f2818429c4213
parent54d37a6765285138cd66cbdc6753d2606a95fb9c (diff)
downloadmariadb-git-MDEV-19781.tar.gz
new trials with custom actions in win installerMDEV-19781
-rw-r--r--win/packaging/ca/CustomAction.cpp217
-rw-r--r--win/packaging/extra.wxs.in11
-rw-r--r--win/packaging/mysql_server.wxs.in4
3 files changed, 192 insertions, 40 deletions
diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp
index 83cd40be35e..c136a1e065a 100644
--- a/win/packaging/ca/CustomAction.cpp
+++ b/win/packaging/ca/CustomAction.cpp
@@ -37,8 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#include <filesystem>
#include <fstream>
#include <map>
-#include <Shlwapi.h>
-#include "CustomAction.h"
+
using namespace std;
using namespace std::filesystem;
@@ -479,6 +478,7 @@ extern "C" UINT CheckDBInUse(MSIHANDLE hInstall)
WcaGetFormattedString(L"[INSTALLDIR]bin\\", &bindir);
myfile.open("c:\\users\\rasmu\\debug2.txt");
+ myfile << __FUNCTION__;
myfile << L"Read bindir\n";
myfile << bindir;
myfile << L"\nEnd reading bindir\n";
@@ -1021,47 +1021,109 @@ extern "C" BOOL WINAPI DllMain(
return TRUE;
}
+inline bool checkIfFileExists (wstring& name) {
+ ifstream f(name.c_str());
+ return f.good();
+}
+
/* Symlinks */
extern "C" UINT __stdcall CreateSymlinks(MSIHANDLE hInstall)
{
- wchar_t *bindir= NULL;
+ /*
HRESULT hr= S_OK;
UINT er= ERROR_SUCCESS;
- TCHAR *szValueBuf= NULL;
- DWORD cchValueBuf= 0;
- UINT uiStat= NULL;
- string debug;
- string symlinkName;
- string appendedPath1, appendedPath2;
- path target, symlink;
- ofstream myfile;
- char installDir[MAX_PATH];
- DWORD size= MAX_VERSION_PROPERTY_SIZE;
-
- hr = WcaInitialize(hInstall, __FUNCTION__);
+ // TCHAR *szValueBuf= NULL;
+ // DWORD cchValueBuf= 0;
+ // UINT uiStat= NULL;
+ // string debug;
+ // string symlinkName;
+ // string appendedPath1, appendedPath2;
+ // path target, symlink;
+ wofstream myfile;
+ wchar_t *bindir=NULL;
+ wchar_t ServiceName[MAX_PATH]={0};
+ DWORD ServiceNameLen = MAX_PATH;
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ */
+ /*
myfile.open("c:\\users\\rasmu\\debug.txt");
myfile << "Start\n";
myfile.close();
+ */
- ExitOnFailure(hr, "Failed to initialize");
+ // ExitOnFailure(hr, "Failed to initialize");
+ /*
myfile.open("c:\\users\\rasmu\\debug.txt", ios_base::app);
myfile << "Initialize successful\n";
myfile.close();
+ */
//ExitOnFailure(hr, "Failed to read INSTALLDIR property.");
// hr= WcaGetFormattedString(L"[INSTALLDIR]bin\\", &bindir);
//uiStat= MsiGetPropertyW(hInstall, L"INSTALLDIR", bindir, &cchValueBuf);
- MsiGetProperty(hInstall, TEXT("INSTALLDIR"), bindir, &size);
+ // MsiGetProperty(hInstall, TEXT("INSTALLDIR"), bindir, &size);
+ //WcaLog(LOGMSG_STANDARD, "Hei");
+ //hr= WcaGetFormattedString(L"[INSTALLDIR]", &bindir);
+
+ // WcaGetProperty(L"SERVICENAME", &servicename);
+ // WcaGetProperty(L"DATADIR", &datadir);
+ // MsiGetPropertyW (hInstall, L"INSTALLDIR", ServiceName, &ServiceNameLen);
+ // hr = WcaGetFormattedString2(L"[INSTALLDIR]bin\\", &bindir);
+
+ // uiStat = MsiGetProperty(hInstall, TEXT("CustomActionData"), szValueBuf, &cchValueBuf);
+ // uiStat = MsiGetProperty(hInstall, TEXT("CustomActionData"), szValueBuf, &cchValueBuf);
+ /*
+ TCHAR* buffer = NULL;
+ DWORD bufferLen = 0;
+
+ LPWSTR empty = NULL;
+ UINT uiStat = MsiGetProperty(hInstall, L"CustomActionData", empty, &bufferLen);
- myfile.open("c:\\users\\rasmu\\debug.txt", ios_base::app);
- myfile << "Read bindir\n";
- myfile << bindir;
- myfile << "\nEnd reading bindir\n";
- myfile.close();
+ if (ERROR_MORE_DATA == uiStat)
+ {
+ ++ bufferLen;
+ buffer = new TCHAR[bufferLen];
+
+ if(NULL != buffer)
+ {
+ uiStat = MsiGetProperty(hInstall, L"CustomActionData", buffer, &bufferLen);
+ }
+ }
+
+ TCHAR szActionData[MAX_PATH] = {0};
+ DWORD dActionDataLen = MAX_PATH;
+ MsiGetProperty (hInstall, L"CustomActionData", szActionData, &dActionDataLen);
+
+ // WcaLog(LOGMSG_STANDARD,"SERVICENAME=%S, DATADIR=%S, bindir=%S",
+ // servicename, datadir, bindir);
+ //WcaLog(LOGMSG_STANDARD, installDir);
+ //WcaLog(LOGMSG_STANDARD, ServiceName);
+ WcaLog(LOGMSG_STANDARD, "Ho");
+
+ myfile.open("c:\\users\\rasmu\\debug.txt");
+ myfile << __FUNCTION__;
+ myfile.close();
+ myfile.open("c:\\users\\rasmu\\debug.txt", std::ios_base::app);
+ myfile << L"Read bindir\n";
+ myfile.close();
+ myfile.open("c:\\users\\rasmu\\debug.txt", std::ios_base::app);
+ myfile << szActionData;
+ myfile.close();
+ myfile.open("c:\\users\\rasmu\\debug.txt", std::ios_base::app);
+ myfile << L"\nEnd szActionData\n";
+ myfile.close();
+ myfile.open("c:\\users\\rasmu\\debug.txt", std::ios_base::app);
+ myfile << buffer;
+ myfile.close();
+ myfile.open("c:\\users\\rasmu\\debug.txt", std::ios_base::app);
+ myfile << L"\nEnd reading bindir\n";
+ myfile.close();
+ */
+ /*
uiStat=
MsiGetProperty(hInstall, TEXT("INSTALLDIR"), LPWSTR(L""), &cchValueBuf);
// cchValueBuf now contains the size of the property's string, without null
@@ -1075,15 +1137,15 @@ extern "C" UINT __stdcall CreateSymlinks(MSIHANDLE hInstall)
uiStat= MsiGetProperty(hInstall, TEXT("MyProperty"), szValueBuf,
&cchValueBuf);
}
- }
+ } */
- // string symlink_from[]= {"mysql", "mysqlaccess", "mysqladmin"};
- // string symlink_to[]= {"mariadb", "mariadb-access", "mariadb-admin"};
+ // string symlink_from[]= {"mysql.exe", "mysqlaccess.exe", "mysqladmin.exe"};
+ // string symlink_to[]= {"mariadb.exe", "mariadb-access.exe", "mariadb-admin.exe"};
// cout << symlink_from[0];
// printf("%s\n", symlink_from[0].c_str());
- target = L"C:/Users/rasmu/target.txt";
+ /*target = L"C:/Users/rasmu/target.txt";
symlinkName= "symlink.txt";
appendedPath2= installDir + symlinkName;
@@ -1093,8 +1155,8 @@ extern "C" UINT __stdcall CreateSymlinks(MSIHANDLE hInstall)
myfile << "2:" + symlinkName;
myfile << "\nEnd\n";
myfile.close();
-
- try
+ */
+ /* try
{
create_symlink(target, appendedPath2);
}
@@ -1102,18 +1164,101 @@ extern "C" UINT __stdcall CreateSymlinks(MSIHANDLE hInstall)
{
myfile.open("c:\\users\\rasmu\\debug.txt", ios_base::app);
myfile << e.what();
- myfile.close();
- }
+ myfile.close();
+ } */
-LExit:
+// LExit:
+ /*
myfile.open("c:\\users\\rasmu\\debug.txt", ios_base::app);
- myfile << "LExit\n";
+ myfile << L"LExit\n";
myfile << hr;
myfile.close();
+ */
- ReleaseStr(bindir);
+ //ReleaseStr(bindir);
+ //return WcaFinalize(er);
+ HRESULT hr = S_OK;
+ UINT er = ERROR_SUCCESS;
+ wchar_t installDir[MAX_PATH];
+ DWORD len = MAX_PATH;
+ wofstream myfile;
+ wchar_t binDir[MAX_PATH];
+ size_t blen = NULL;
+ // string symlink_from[1];
+ // string symlink_to[1];
+ wstring symlink_from[]= {L"mysql.exe", L"mysqlaccess.exe", L"mysqladmin.exe", L"mariabackup.exe", L"mysqlbinlog.exe", L"mysqlcheck.exe",
+ L"mysql_client_test_embedded.exe", L"mysql_client_test.exe", L"mariadb_config.exe", L"mysql_convert_table_format.exe",
+ L"mysqldump.exe", L"mysqldumpslow.exe", L"mysql_embedded.exe", L"mysql_find_rows.exe", L"mysql_fix_extensions.exe",
+ L"mysqlhotcopy.exe", L"mysqlimport.exe", L"mysql_install_db.exe", L"mysql_ldb.exe", L"mysql_plugin.exe",
+ L"mysql_secure_installation.exe", L"mysql_setpermission.exe", L"mysqlshow.exe", L"mysqlslap.exe",
+ L"mysqltest.exe", L"mysqltest_embedded.exe", L"mysql_tzinfo_to_sql.exe", L"mysql_upgrade.exe",
+ L"mysql_upgrade_service.exe", L"mysql_upgrade_wizard.exe", L"mysql_waitpid.exe", L"mysqld.exe", L"mysqld_multi.exe",
+ L"mysqld_safe.exe", L"mysqld_safe_helper.exe"};
+
+ wstring symlink_to[]= {L"mariadb.exe", L"mariadb-access.exe", L"mariadb-admin.exe", L"mariadb-backup.exe", L"mariadb-binlog.exe", L"mariadb-check.exe",
+ L"mariadb-client-test-embedded.exe", L"mariadb-client-test.exe", L"mariadb-config.exe", L"mariadb-convert-table-format.exe",
+ L"mariadb-dump.exe", L"mariadb-dumpslow.exe", L"mariadb-embedded.exe", L"mariadb-find-rows.exe", L"mariadb-fix-extensions.exe",
+ L"mariadb-hotcopy.exe", L"mariadb-import.exe", L"mariadb-install-db.exe", L"mariadb-ldb.exe", L"mariadb-plugin.exe",
+ L"mariadb-secure-installation.exe", L"mariadb-setpermission.exe", L"mariadb-show.exe", L"mariadb-slap.exe",
+ L"mariadb-test.exe", L"mariadb-test-embedded.exe", L"mariadb-tzinfo-to-sql.exe", L"mariadb-upgrade.exe",
+ L"mariadb-upgrade-service.exe", L"mariadb-upgrade-wizard.exe", L"mariadb-waitpid.exe", L"mariadbd.exe", L"mariadbd-multi.exe",
+ L"mariadbd-safe.exe", L"mariadbd-safe-helper.exe"};
- er= SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+// ExitOnFailure(hr, "Failed to initialize");
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
- return WcaFinalize(er);
-} \ No newline at end of file
+ MsiGetPropertyW(hInstall, L"CustomActionData", installDir, &len);
+ blen = wcslen(installDir);
+ wcscpy(binDir, installDir);
+
+ if(blen > 0 && installDir[blen-1] != L'\\')
+ wcscat(binDir, L"\\");
+
+ wcscat(binDir, L"bin\\");
+
+ myfile.open("c:\\users\\rasmu\\debug.txt");
+ myfile << installDir << "\n";
+ myfile << binDir << "\n";
+ myfile << "symlink_from size: " << std::size(symlink_from) << "\n";
+ myfile << "symlink_to size: " << std::size(symlink_to) << "\n";
+ myfile.close();
+
+ for(size_t i = 0; i < std::size(symlink_from); i++)
+ {
+ wchar_t pathFrom[MAX_PATH], pathTo[MAX_PATH];
+
+ wcscpy(pathFrom, binDir);
+ wcscat(pathFrom, symlink_from[i].data());
+ wcscpy(pathTo, binDir);
+ wcscat(pathTo, symlink_to[i].data());
+
+ myfile.open("c:\\users\\rasmu\\debug.txt", ios_base::app);
+ myfile << "pathFrom: " << pathFrom << "\n";
+ myfile.close();
+
+ myfile.open("c:\\users\\rasmu\\debug.txt", ios_base::app);
+ myfile << "pathTo: " << pathTo << "\n";
+ myfile.close();
+
+ wstring wsPathFrom(pathFrom);
+
+ try {
+ if (checkIfFileExists(wsPathFrom))
+ create_symlink(pathFrom, pathTo);
+ } catch (const filesystem_error &e){
+ myfile.open("c:\\users\\rasmu\\debug.txt", ios_base::app);
+ myfile << e.what() << "\n";
+ myfile.close();
+ }
+
+ myfile.open("c:\\users\\rasmu\\debug.txt", ios_base::app);
+ myfile << symlink_from[i] << " --> " << symlink_to[i] << "\n";
+ myfile.close();
+ }
+
+ myfile.close();
+
+//LExit:
+ return WcaFinalize(er);
+}
diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in
index 1955799f6f9..4e17ef4b5fd 100644
--- a/win/packaging/extra.wxs.in
+++ b/win/packaging/extra.wxs.in
@@ -661,7 +661,16 @@
</Feature>
<?endif?>
- <!-- Custom action, call mysql_install_db -->
+ <!-- Custom action, create symlinks -->
+ <CustomAction Id="CreateSymlinks" BinaryKey="wixca.dll" DllEntry="CreateSymlinks" Execute="deferred" Impersonate="no" />
+ <CustomAction Id="CreateSymlinks.SetProperty" Return="check" Property="CreateSymlinks" Value="[INSTALLDIR]" />
+
+ <InstallExecuteSequence>
+ <Custom Action="CreateSymlinks.SetProperty" Before="CreateSymlinks" >NOT Installed</Custom>
+ <Custom Action="CreateSymlinks" Before="InstallFinalize">NOT Installed</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>
diff --git a/win/packaging/mysql_server.wxs.in b/win/packaging/mysql_server.wxs.in
index 38ec20b0c2e..f6ae706f74a 100644
--- a/win/packaging/mysql_server.wxs.in
+++ b/win/packaging/mysql_server.wxs.in
@@ -44,12 +44,10 @@
</Condition>
<CustomAction Id="symlinks" ExeCommand="cmd /c &quot;PostInstall.bat&quot;" Directory="INSTALLDIR" Execute="deferred" Impersonate="no" Return="check"/>
- <CustomAction Id="CreateSymlinks" BinaryKey="wixca.dll" DllEntry="CreateSymlinks" Execute="commit" />
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallFinalize"/>
- <Custom Action="symlinks" After="CreateSymlinks" >NOT Installed</Custom>
- <Custom Action="CreateSymlinks" After="InstallFiles">Not Installed</Custom>
+ <Custom Action="symlinks" After="InstallFiles" >NOT Installed</Custom>
</InstallExecuteSequence>