summaryrefslogtreecommitdiff
path: root/win
diff options
context:
space:
mode:
authorRasmus Johansson <rasmus@mariadb.com>2020-03-20 16:41:54 +0200
committerSergei Golubchik <serg@mariadb.org>2020-03-21 20:20:29 +0100
commit9e1b3af4a490d6fb6704756aba90281ff5ac033a (patch)
tree513967006d4809562e38a04ae741916c2c32e119 /win
parent6fb59d525b7047c82e350d2b721bffc50431eb12 (diff)
downloadmariadb-git-9e1b3af4a490d6fb6704756aba90281ff5ac033a.tar.gz
MDEV-21303 Make executables MariaDB named
To change all executables to have a mariadb name I had to: - Do name changes in every CMakeLists.txt that produces executables - CREATE_MARIADB_SYMLINK was removed and GET_SYMLINK added by Wlad to reuse the function in other places also - The scripts/CMakeLists.txt could make use of GET_SYMLINK instead of introducing redundant code, but I thought I'll leave that for next release - A lot of changes to debian/.install and debian/.links files due to swapping of real executable and symlink. I did not however change the name of the manpages, so the real name is still mysql there and mariadb are symlinks. - The Windows part needed a change now when we made the executables mariadb -named. MSI (and ZIP) do not support symlinks and to not break backward compatibility we had to include mysql named binaries also. Done by Wlad
Diffstat (limited to 'win')
-rw-r--r--win/packaging/ca/CMakeLists.txt13
-rw-r--r--win/packaging/ca/CustomAction.cpp265
-rw-r--r--win/packaging/ca/CustomAction.def3
-rw-r--r--win/packaging/ca/symlinks.cc.in6
-rw-r--r--win/packaging/ca/symlinks.h8
-rw-r--r--win/packaging/create_msi.cmake2
-rw-r--r--win/packaging/extra.wxs.in17
-rw-r--r--win/upgrade_wizard/CMakeLists.txt10
8 files changed, 9 insertions, 315 deletions
diff --git a/win/packaging/ca/CMakeLists.txt b/win/packaging/ca/CMakeLists.txt
index 99dc7da01fb..326bab47de4 100644
--- a/win/packaging/ca/CMakeLists.txt
+++ b/win/packaging/ca/CMakeLists.txt
@@ -14,21 +14,10 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
INCLUDE_DIRECTORIES(${WIX_DIR}/../SDK/${WIX_MSVC_SUFFIX}/inc)
-SET(WIXCA_SOURCES CustomAction.cpp CustomAction.def ${CMAKE_CURRENT_BINARY_DIR}/symlinks.cc)
+SET(WIXCA_SOURCES CustomAction.cpp CustomAction.def)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql ${CMAKE_CURRENT_SOURCE_DIR})
-INCLUDE(symlinks)
-LIST(LENGTH MARIADB_SYMLINK_FROMS LEN)
-MATH(EXPR max_index "${LEN}-1")
-SET(ALL_SYMLINKS "")
-FOREACH(i RANGE 0 ${max_index})
- LIST(GET MARIADB_SYMLINK_FROMS ${i} src)
- LIST(GET MARIADB_SYMLINK_TOS ${i} dst)
- STRING(APPEND ALL_SYMLINKS "{L\"${src}\",L\"${dst}\"},\n")
-ENDFOREACH()
-CONFIGURE_FILE(symlinks.cc.in symlinks.cc)
-
# Custom action should not depend on C runtime, since we do not know if CRT is installed.
FORCE_STATIC_CRT()
ADD_VERSION_INFO(wixca SHARED WIXCA_SOURCES)
diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp
index 4f66e266583..1a4abc754e8 100644
--- a/win/packaging/ca/CustomAction.cpp
+++ b/win/packaging/ca/CustomAction.cpp
@@ -1013,268 +1013,3 @@ extern "C" BOOL WINAPI DllMain(
return TRUE;
}
-
-static wstring MakeExePath(const wchar_t *installDir, const wchar_t *basename)
-{
- wstring path(installDir);
- if (path.back() != L'\\')
- path.append(L"\\");
- path.append(L"bin\\");
- path.append(basename);
- path.append(L".exe");
- return path;
-}
-
-static wstring MakeExePath(const wchar_t *installDir, string basename)
-{
- wstring path(installDir);
- if (path.back() != L'\\')
- path.append(L"\\");
- path.append(L"bin\\");
- for (auto c : basename)
- path+= c;
- path.append(L".exe");
- return path;
-}
-static wstring MakeFixSymlinksLogPath()
-{
- wchar_t buf[MAX_PATH];
- if (GetTempPathW(MAX_PATH, buf))
- return wstring(buf) + L"\\mariadb_msi_fix_symlinks.log";
- return L"";
-}
-
-static string w2s(wstring w)
-{
- string s;
- for (auto wc : w)
- s += (char)wc;
- return s;
-}
-
-/*
- Remove symlinks if target file does not exist.
- Create symlink if target exists, but symlink is not.
-*/
-static void fix_symlink(const wchar_t *file, const wchar_t *link,
- const wchar_t *installdir,
- vector<string> &rollback_actions)
-{
- WcaLog(LOGMSG_STANDARD, "fix_symlink %S=>%S", link, file);
-
- auto tgt= MakeExePath(installdir, file);
- auto lnk= MakeExePath(installdir, link);
- auto target_path= tgt.c_str();
- auto link_path= lnk.c_str();
-
- auto target_attr= GetFileAttributesW(target_path);
- auto link_attr= GetFileAttributesW(link_path);
- WcaLog(LOGMSG_STANDARD, "%S %s", target_path,
- target_attr == INVALID_FILE_ATTRIBUTES ? "does not exist" : "exists");
- WcaLog(LOGMSG_STANDARD, "%S %s", link_path,
- link_attr == INVALID_FILE_ATTRIBUTES ? "does not exist" : "exists");
-
- if (link_attr != INVALID_FILE_ATTRIBUTES &&
- ((link_attr & FILE_ATTRIBUTE_REPARSE_POINT) == 0))
- {
- WcaLog(LOGMSG_STANDARD, "%S is not a symlink!", link_path);
- return;
- }
-
- if (target_attr == INVALID_FILE_ATTRIBUTES)
- {
- if (link_attr == INVALID_FILE_ATTRIBUTES)
- {
- return;
- }
- auto ok= DeleteFileW(link_path);
- WcaLog(LOGMSG_STANDARD, "DeleteFileW(L\"%S\") returned %s, last error %lu",
- link_path, ok ? "success" : "error", GetLastError());
- if (ok)
- {
- rollback_actions.push_back(string("create_symlink ") + w2s(link) + " " +
- w2s(file));
- }
- return;
- }
-
- if (link_attr != INVALID_FILE_ATTRIBUTES)
- return;
-
- auto ok= CreateSymbolicLinkW(link_path, target_path, 0);
- WcaLog(LOGMSG_STANDARD,
- "CreateSymbolicLinkW(\"%S\",\"%S\", 0) returned %s, last error %d",
- link_path, target_path, ok ? "success" : "error",
- (int) GetLastError());
- if (ok)
- rollback_actions.push_back(string("delete ") + w2s(link));
-}
-
-static string rollback_info_path()
-{
- char tmppath[MAX_PATH];
- if (!GetTempPathA(MAX_PATH, tmppath))
- return "";
- string filepath(tmppath);
- filepath.append("\\mariadb_symlink_rollback_info.tmp");
- return filepath;
-}
-
-
-static void save_symlink_rollback_info(vector<string> rollback_info)
-{
- std::ofstream ofs;
- string path = rollback_info_path();
- ofs.open(path, std::ofstream::out | std::ofstream::trunc);
- if (!ofs.good())
- return;
- WcaLog(LOGMSG_STANDARD,
- "Storing this rollback script for custom action in %s, in case installation rolls back",
- path.c_str());
- for (auto line : rollback_info)
- {
- WcaLog(LOGMSG_STANDARD, "%s", line.c_str());
- ofs << line << "\n";
- }
- WcaLog(LOGMSG_STANDARD, "End of rollback script");
-}
-
-
-#include <symlinks.h>
-/* MDEV-19781 MariaDB symlinks on Windows */
-extern "C" UINT __stdcall FixSymlinksRollback(MSIHANDLE hInstall)
-{
- HRESULT hr= S_OK;
- UINT er= ERROR_SUCCESS;
- wchar_t targetdir[MAX_PATH];
- DWORD len= MAX_PATH;
- hr= WcaInitialize(hInstall, __FUNCTION__);
- WcaLog(LOGMSG_STANDARD, "Initialized.");
- std::ifstream ifs;
- std::string command;
-
- if (MsiGetPropertyW(hInstall, L"CustomActionData", targetdir, &len) !=
- ERROR_SUCCESS)
- {
- hr= HRESULT_FROM_WIN32(GetLastError());
- ExitOnFailure(hr, "MsiGetPropertyW failed");
- }
-
- ifs.open(rollback_info_path(), std::ofstream::in);
- if (!ifs.good())
- goto LExit;
-
- while (ifs >> command)
- {
- if (command == "create_symlink")
- {
- string link;
- ifs >> link;
- auto link_path= MakeExePath(targetdir, link);
- string file;
- ifs >> file;
- auto target_path= MakeExePath(targetdir, file);
- bool ok= CreateSymbolicLinkW(link_path.c_str(), target_path.c_str(), 0);
- WcaLog(LOGMSG_STANDARD, "CreateSymbolicLinkW(%S,%S) %s, last error %lu",
- link_path.c_str(), target_path.c_str(), ok ? "success" : "error",
- GetLastError());
- }
- else if (command == "delete")
- {
- string link;
- ifs >> link;
- auto link_path= MakeExePath(targetdir, link);
- auto link_attr= GetFileAttributesW(link_path.c_str());
- if (link_attr != INVALID_FILE_ATTRIBUTES &&
- (link_attr & FILE_ATTRIBUTE_REPARSE_POINT))
- {
- auto ok= DeleteFileW(link_path.c_str());
- WcaLog(LOGMSG_STANDARD, "DeleteFile(%S) %s, last error %lu",
- link_path.c_str(), ok ? "success" : "error", GetLastError());
- }
- }
- else
- {
- WcaLog(LOGMSG_STANDARD, "Unknown command '%s' in rollback script ",
- command.c_str());
- goto LExit;
- }
- }
-
-LExit:
- return WcaFinalize(er);
-}
-
-
-extern "C" UINT __stdcall SymlinksUninstall(MSIHANDLE hInstall)
-{
- HRESULT hr = S_OK;
- UINT er = ERROR_SUCCESS;
- wchar_t targetdir[MAX_PATH];
- DWORD len = MAX_PATH;
- int i;
- hr = WcaInitialize(hInstall, __FUNCTION__);
- WcaLog(LOGMSG_STANDARD, "Initialized.");
-
- if (MsiGetPropertyW(hInstall, L"CustomActionData", targetdir, &len) !=
- ERROR_SUCCESS)
- {
- hr = HRESULT_FROM_WIN32(GetLastError());
- ExitOnFailure(hr, "MsiGetPropertyW failed");
- }
-
- for (i = 0; all_symlinks[i].file; i++)
- {
- auto link_path = MakeExePath(targetdir, all_symlinks[i].link);
- auto link_attr = GetFileAttributesW(link_path.c_str());
- auto filepath = link_path.c_str();
-
- if (link_attr == INVALID_FILE_ATTRIBUTES)
- {
- WcaLog(LOGMSG_STANDARD, " %S does not exist",filepath);
- continue;
- }
-
- if(!(link_attr & FILE_ATTRIBUTE_REPARSE_POINT))
- {
- WcaLog(LOGMSG_STANDARD, " %S is not a symbolic link!",filepath);
- continue;
- }
- BOOL ok = DeleteFileW(filepath);
- WcaLog(LOGMSG_STANDARD, "DeleteFile(%S) %s, last error %lu",
- filepath, ok? "succeeded":"failed", GetLastError());
- }
-
-LExit:
- return WcaFinalize(er);
-}
-
-/* MDEV-19781 MariaDB symlinks on Windows */
-extern "C" UINT __stdcall FixSymlinks(MSIHANDLE hInstall)
-{
- HRESULT hr= S_OK;
- UINT er= ERROR_SUCCESS;
- wchar_t targetdir[MAX_PATH];
- vector<string> rollback_actions;
- DWORD len= MAX_PATH;
- int i;
- hr= WcaInitialize(hInstall, __FUNCTION__);
- WcaLog(LOGMSG_STANDARD, "Initialized.");
-
- if (MsiGetPropertyW(hInstall, L"CustomActionData", targetdir, &len) !=
- ERROR_SUCCESS)
- {
- hr= HRESULT_FROM_WIN32(GetLastError());
- ExitOnFailure(hr, "MsiGetPropertyW failed");
- }
-
- for (i= 0; all_symlinks[i].file; i++)
- fix_symlink(all_symlinks[i].file, all_symlinks[i].link, targetdir,
- rollback_actions);
-
- save_symlink_rollback_info(rollback_actions);
-
-LExit:
- return WcaFinalize(er);
-}
-
diff --git a/win/packaging/ca/CustomAction.def b/win/packaging/ca/CustomAction.def
index 8169968e26b..0be77a97a08 100644
--- a/win/packaging/ca/CustomAction.def
+++ b/win/packaging/ca/CustomAction.def
@@ -8,6 +8,3 @@ CheckDatabaseProperties
CheckDataDirectoryEmpty
CheckDBInUse
CheckServiceUpgrades
-FixSymlinks
-FixSymlinksRollback
-SymlinksUninstall
diff --git a/win/packaging/ca/symlinks.cc.in b/win/packaging/ca/symlinks.cc.in
deleted file mode 100644
index 62ca9884af8..00000000000
--- a/win/packaging/ca/symlinks.cc.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "symlinks.h"
-symlink all_symlinks[]=
-{
-@ALL_SYMLINKS@
-{nullptr, nullptr}
-};
diff --git a/win/packaging/ca/symlinks.h b/win/packaging/ca/symlinks.h
deleted file mode 100644
index 4fc1f2cb685..00000000000
--- a/win/packaging/ca/symlinks.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-struct symlink
-{
- const wchar_t *file;
- const wchar_t *link;
-};
-
-extern symlink all_symlinks[];
diff --git a/win/packaging/create_msi.cmake b/win/packaging/create_msi.cmake
index 0527c6a7787..6b9b5c04449 100644
--- a/win/packaging/create_msi.cmake
+++ b/win/packaging/create_msi.cmake
@@ -311,9 +311,11 @@ ENDFUNCTION()
SET(CPACK_WIX_COMPONENTS)
SET(CPACK_WIX_COMPONENT_GROUPS)
GET_FILENAME_COMPONENT(abs . ABSOLUTE)
+
FOREACH(d ${DIRS})
GET_FILENAME_COMPONENT(d ${d} ABSOLUTE)
GET_FILENAME_COMPONENT(d_name ${d} NAME)
+
MAKE_WIX_IDENTIFIER("${d_name}" d_name)
FILE(WRITE ${abs}/${d_name}_component_group.wxs
"<ComponentGroup Id='componentgroup.${d_name}'>")
diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in
index 7de62907300..3aa6889ac2f 100644
--- a/win/packaging/extra.wxs.in
+++ b/win/packaging/extra.wxs.in
@@ -597,21 +597,6 @@
<?endif ?>
- <!-- Custom action, create symlinks -->
- <CustomAction Id="Symlinks.SetProperty" Return="check" Property="Symlinks" Value="[INSTALLDIR]" />
- <CustomAction Id="Symlinks" BinaryKey="wixca.dll" DllEntry="FixSymlinks" Execute="deferred" Impersonate="no" Return="ignore"/>
- <CustomAction Id="SymlinksRollback.SetProperty" Return="check" Property="SymlinksRollback" Value="[INSTALLDIR]" />
- <CustomAction Id="SymlinksRollback" BinaryKey="wixca.dll" DllEntry="FixSymlinksRollback" Execute="rollback" Impersonate="no" Return="ignore"/>
- <CustomAction Id="SymlinksUninstall.SetProperty" Return="check" Property="SymlinksUninstall" Value="[INSTALLDIR]" />
- <CustomAction Id="SymlinksUninstall" BinaryKey="wixca.dll" DllEntry="SymlinksUninstall" Execute="deferred" Impersonate="no" Return="ignore"/>
- <InstallExecuteSequence>
- <Custom Action="Symlinks.SetProperty" Before="Symlinks">NOT Installed OR UPGRADINGPRODUCTCODE</Custom>
- <Custom Action="Symlinks" After="SymlinksRollback">NOT Installed OR UPGRADINGPRODUCTCODE</Custom>
- <Custom Action="SymlinksRollback.SetProperty" Before="SymlinksRollback">NOT Installed OR UPGRADINGPRODUCTCODE</Custom>
- <Custom Action="SymlinksRollback" After="InstallFiles">NOT Installed OR UPGRADINGPRODUCTCODE</Custom>
- <Custom Action="SymlinksUninstall.SetProperty" Before="SymlinksUninstall">Installed AND NOT UPGRADINGPRODUCTCODE</Custom>
- <Custom Action="SymlinksUninstall" Before="RemoveFiles">Installed AND NOT UPGRADINGPRODUCTCODE</Custom>
- </InstallExecuteSequence>
<!-- Custom action, call mysql_install_db -->
<SetProperty Sequence='execute' Before='CreateDatabaseCommand' Id="SKIPNETWORKING" Value="--skip-networking" >SKIPNETWORKING</SetProperty>
@@ -633,7 +618,7 @@
<CustomAction Id="CreateDatabaseRollback" BinaryKey="wixca.dll" DllEntry="CreateDatabaseRollback"
Execute="rollback" Return="check" Impersonate="no"/>
<UI>
- <ProgressText Action="CreateDatabase">Running mysql_install_db.exe</ProgressText>
+ <ProgressText Action="CreateDatabase">Running mariadb-install-db.exe</ProgressText>
</UI>
<!-- Error injection script activated by TEST_FAIL=1 passed to msiexec (to see how good custom action rollback works) -->
diff --git a/win/upgrade_wizard/CMakeLists.txt b/win/upgrade_wizard/CMakeLists.txt
index 7d0e774b968..510f770b798 100644
--- a/win/upgrade_wizard/CMakeLists.txt
+++ b/win/upgrade_wizard/CMakeLists.txt
@@ -40,20 +40,20 @@ SET(CMAKE_MFC_FLAG 1)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc -DNO_WARN_MBCS_MFC_DEPRECATION")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql)
-MYSQL_ADD_EXECUTABLE(mysql_upgrade_wizard
+MYSQL_ADD_EXECUTABLE(mariadb-upgrade-wizard
upgrade.cpp upgradeDlg.cpp upgrade.rc ${UPGRADE_WIZARD_SOURCES}
COMPONENT Server)
-TARGET_LINK_LIBRARIES(mysql_upgrade_wizard ${UPGRADE_WIZARD_LINK_LIBRARIES})
+TARGET_LINK_LIBRARIES(mariadb-upgrade-wizard ${UPGRADE_WIZARD_LINK_LIBRARIES})
# upgrade_wizard is Windows executable, set WIN32_EXECUTABLE so it does not
# create a console.
-SET_TARGET_PROPERTIES(mysql_upgrade_wizard PROPERTIES WIN32_EXECUTABLE 1)
+SET_TARGET_PROPERTIES(mariadb-upgrade-wizard PROPERTIES WIN32_EXECUTABLE 1)
# Embed Vista "admin" manifest, since upgrade_wizard needs admin privileges
# to change service configuration. Due to a CMake bug http://www.vtk.org/Bug/view.php?id=11171
# it is not possible currenly to do it with linker flags. Work around is to use
# manifest tool mt.exe and embed the manifest post-build.
ADD_CUSTOM_COMMAND(
- TARGET mysql_upgrade_wizard POST_BUILD
+ TARGET mariadb-upgrade-wizard POST_BUILD
COMMAND mt.exe -manifest ${CMAKE_CURRENT_SOURCE_DIR}/upgrade_wizard.exe.manifest
- "-outputresource:$<TARGET_FILE:mysql_upgrade_wizard>;#1"
+ "-outputresource:$<TARGET_FILE:mariadb-upgrade-wizard>;#1"
)