summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:24:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:24:36 +0000
commit06eaf7232e9a920468c0f8d74dcf2fe8b555501c (patch)
treee2c7b5777f728320e5b5542b6213fd3591ba51e2 /win
parentInitial commit. (diff)
downloadmariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.tar.xz
mariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.zip
Adding upstream version 1:10.11.6.upstream/1%10.11.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'win')
-rw-r--r--win/appveyor_skip_tests.txt14
-rw-r--r--win/create_def_file.js265
-rw-r--r--win/packaging/CMakeLists.txt245
-rw-r--r--win/packaging/COPYING.rtf61
-rw-r--r--win/packaging/CPackWixConfig.cmake121
-rw-r--r--win/packaging/CPackZIPConfig.cmake11
-rw-r--r--win/packaging/CPackZIPDebugInfoConfig.cmake6
-rw-r--r--win/packaging/CPackZIPTestConfig.cmake6
-rw-r--r--win/packaging/WixUIBannerBmp.jpgbin0 -> 3856 bytes
-rw-r--r--win/packaging/WixUIDialogBmp.jpgbin0 -> 9745 bytes
-rw-r--r--win/packaging/ca/CMakeLists.txt24
-rw-r--r--win/packaging/ca/CustomAction.cpp1134
-rw-r--r--win/packaging/ca/CustomAction.def11
-rw-r--r--win/packaging/ca/CustomAction.rc18
-rw-r--r--win/packaging/create_msi.cmake416
-rw-r--r--win/packaging/extra.wxs.in839
-rw-r--r--win/packaging/heidisql.cmake16
-rw-r--r--win/packaging/heidisql.wxi.in128
-rw-r--r--win/packaging/heidisql_feature.wxi.in10
-rw-r--r--win/packaging/mysql_server.wxs.in89
-rw-r--r--win/upgrade_wizard/CMakeLists.txt47
-rw-r--r--win/upgrade_wizard/res/upgrade.icobin0 -> 99678 bytes
-rw-r--r--win/upgrade_wizard/res/upgrade.rc213
-rw-r--r--win/upgrade_wizard/resource.h27
-rw-r--r--win/upgrade_wizard/stdafx.h47
-rw-r--r--win/upgrade_wizard/targetver.h8
-rw-r--r--win/upgrade_wizard/upgrade.cpp57
-rw-r--r--win/upgrade_wizard/upgrade.h32
-rw-r--r--win/upgrade_wizard/upgrade.rc148
-rw-r--r--win/upgrade_wizard/upgradeDlg.cpp641
-rw-r--r--win/upgrade_wizard/upgradeDlg.h73
-rw-r--r--win/upgrade_wizard/upgrade_wizard.exe.manifest15
32 files changed, 4522 insertions, 0 deletions
diff --git a/win/appveyor_skip_tests.txt b/win/appveyor_skip_tests.txt
new file mode 100644
index 00000000..3f0a0874
--- /dev/null
+++ b/win/appveyor_skip_tests.txt
@@ -0,0 +1,14 @@
+main.mysql_upgrade : Takes long time on Appveyor
+main.mysqlslap : Takes long time
+mysql.upgrade_view : Takes long time
+main.check : Takes long time on Appveyor
+main.mrr_icp_extra : Takes long time on Appveyor
+main.derived_opt : Takes long time on Appveyor
+main.trigger : Takes long time on Appveyor
+main.index_merge_myisam : Takes long time on Appveyor
+main.mysqldump : Takes long time on Appveyor
+main.derived : Takes long time on Appveyor
+main.multi_update : Takes long time on Appveyor
+main.index_merge_innodb : Takes long time on Appveyor
+main.count_distinct2 : Takes long time on Appveyor
+main.mysqltest : Takes long time on Appveyor
diff --git a/win/create_def_file.js b/win/create_def_file.js
new file mode 100644
index 00000000..c8915a39
--- /dev/null
+++ b/win/create_def_file.js
@@ -0,0 +1,265 @@
+// create_def_file.js
+//
+// Copyright (c) 2009 Sun Microsystems, Inc.
+// Use is subject to license terms.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
+
+/*
+ This script extracts names and types of globally defined symbols from
+ COFF object files, and writes this information to stdout using .DEF
+ file format (module definition file used by Microsoft linker)
+
+ In MySQL this script is used to export symbols from mysqld.exe for use by
+ storage engine DLLs.
+
+ Usage:
+ cscript create_def_file.js [x86|x64] [object|static_lib|directory ...]
+
+ If directory is passed as a parameter, script will process all object files
+ and static libraries in this directory and recursively in all subdrectories.
+
+ Note :The script does not work properly if /GL (global optimization)
+ compiler option was used to produce object files or libraries. This is a
+ limitation of the dumpbin tool that is used by the script.
+*/
+
+ForReading = 1;
+ForWriting = 2;
+ForAppending = 8;
+
+
+var args = WScript.Arguments;
+
+// check that we got proper arguments
+if (args.length < 2)
+{
+ echo("Usage: create_def_file <X86|X64> [static_library|objectfile|objectdirectory ...] ");
+ WScript.Quit(1);
+}
+
+
+var is64 = args.Item(0).toLowerCase() == "x64";
+var shell = new ActiveXObject("WScript.Shell");
+var fso = new ActiveXObject("Scripting.FileSystemObject");
+
+/*
+ If .def file is used with together with lib.exe
+ the name mangling for stdcall is slightly different.
+
+ Undescore prefix for stdcall function name must be removed for
+ lib.exe but not link.exe (see ScrubSymbol())
+
+ This difference is not documented anywhere and could
+ be a bug in compiler tools.
+
+ We use a parameter /forLib, if the resulting .def file is used
+ with lib.exe .
+*/
+var forLib = false;
+
+
+OutputSymbols(CollectSymbols());
+
+
+// takes the array that has been built up and writes out mysqld.def
+function OutputSymbols(symbols)
+{
+ var out = WScript.StdOut;
+ out.WriteLine("EXPORTS");
+ for (var i= 0; i < symbols.length; i++)
+ out.WriteLine(symbols[i]);
+}
+
+function echo(message)
+{
+ WScript.StdErr.WriteLine(message);
+}
+
+// Extract global symbol names and type from objects
+// Returns string array with symbol names
+function CollectSymbols()
+{
+ var uniqueSymbols = new Object();
+
+ try
+ {
+ /*
+ Compiler tools use VS_UNICODE_OUTPUT env. variable as indicator
+ that they run within IDE, so they can communicate with IDE via
+ pipes instead of usual stdout/stderr. Refer to
+ http://blogs.msdn.com/freik/archive/2006/04/05/569025.aspx
+ for more info.
+ Unset this environment variable.
+ */
+ shell.Environment("PROCESS").Remove("VS_UNICODE_OUTPUT");
+ }
+ catch(e){}
+
+ var rspfilename = "dumpsymbols.rsp";
+ CreateResponseFile(rspfilename);
+ var commandline="dumpbin @"+rspfilename;
+
+ echo("Executing "+commandline);
+ var oExec = shell.Exec(commandline);
+
+ while(!oExec.StdOut.AtEndOfStream)
+ {
+ var line = oExec.StdOut.ReadLine();
+ if (line.indexOf("External") == -1) continue;
+ var columns = line.split(" ");
+ var index = 0;
+ if (columns.length < 3)
+ continue;
+
+ /*
+ If the third column of dumpbin output contains SECTx,
+ the symbol is defined in that section of the object file.
+ If UNDEF appears, it is not defined in that object and must
+ be resolved elsewhere. BSS symbols (like uninitialized arrays)
+ appear to have non-zero second column.
+ */
+ if (columns[2].substring(0,4)!="SECT")
+ {
+ if (columns[2] == "UNDEF" && parseInt(columns[1])==0 )
+ continue;
+ }
+
+ /*
+ Extract undecorated symbol names
+ between "|" and next whitespace after it.
+ */
+ for (; index < columns.length; index++)
+ if (columns[index] == "|")
+ break;
+
+ var symbol = columns[index + 1];
+ var firstSpace = symbol.indexOf(" ");
+ if (firstSpace != -1)
+ symbol = symbol.substring(0, firstSpace-1);
+
+ // Don't export compiler defined stuff
+ if (IsCompilerDefinedSymbol(symbol))
+ continue;
+
+ // Correct symbol name for cdecl calling convention on x86
+ symbol = ScrubSymbol(symbol);
+
+ // Check if we have function or data
+ if (line.indexOf("notype () ") == -1)
+ symbol = symbol + " DATA";
+
+ uniqueSymbols[symbol] = 1;
+ }
+ fso.DeleteFile(rspfilename);
+ // Sort symbols names
+ var keys=[];
+ var sorted = {};
+ for (key in uniqueSymbols)
+ {
+ if (uniqueSymbols.hasOwnProperty(key))
+ {
+ keys.push(key);
+ }
+ }
+ keys.sort();
+
+ return keys;
+}
+
+// performs necessary cleanup on the symbol name
+function ScrubSymbol(symbol)
+{
+ if (is64) return symbol;
+ if (symbol.charAt(0) != "_")
+ return symbol;
+
+ if (forLib)
+ return symbol.substring(1, symbol.length);
+
+ var atSign = symbol.indexOf("@");
+ if (atSign != -1)
+ {
+ var paramSize = symbol.substring(atSign+1, symbol.Length);
+ if (paramSize.match("[0-9]+$")) return symbol;
+ }
+ return symbol.substring(1, symbol.length);
+}
+
+// returns true if the symbol is compiler defined
+function IsCompilerDefinedSymbol(symbol)
+{
+ return ((symbol.indexOf("__real@") != -1) ||
+ (symbol.indexOf("_xmm@") != -1) ||
+ (symbol.indexOf("_RTC_") != -1) ||
+ (symbol.indexOf("??_C@_") != -1) ||
+ (symbol.indexOf("??_R") != -1) ||
+ (symbol.indexOf("??_7") != -1) ||
+ (symbol.indexOf("_xmm@7F") != -1) || // VS2012 Win64 special symbol
+ (symbol.indexOf("?_G") != -1) || // scalar deleting destructor
+ (symbol.indexOf("_VInfreq_?") != -1) || // special label (exception handler?) for Intel compiler
+ (symbol.indexOf("?_E") != -1)); // vector deleting destructor
+}
+
+// Creates response file for dumpbin
+function CreateResponseFile(filename)
+{
+ var responseFile = fso.CreateTextFile(filename,true);
+ responseFile.WriteLine("/SYMBOLS");
+
+ var index = 1;
+ for (; index < args.length; index++)
+ {
+ var param = args.Item(index);
+ if (param == "/forLib")
+ forLib = true;
+ else
+ addToResponseFile(args.Item(index),responseFile);
+ }
+ responseFile.Close();
+}
+
+// Add object file/library to the dumpbin response file.
+// If filename parameter is directory, all objects and libs under
+// this directory or subdirectories are added.
+function addToResponseFile(filename, responseFile)
+{
+ if (fso.FolderExists(filename))
+ {
+ var folder = fso.getFolder(filename);
+ var enumerator = new Enumerator(folder.files);
+ for (; !enumerator.atEnd(); enumerator.moveNext())
+ {
+ addToResponseFile(enumerator.item().Path, responseFile);
+ }
+ enumerator = new Enumerator(folder.subFolders);
+ for (; !enumerator.atEnd(); enumerator.moveNext())
+ {
+ addToResponseFile(enumerator.item().Path, responseFile);
+ }
+ }
+ else if (fso.FileExists(filename))
+ {
+ var extension = filename.substr(filename.length -3).toLowerCase();
+ if(extension == "lib" || extension == "obj")
+ {
+ responseFile.WriteLine("\""+fso.GetFile(filename).Path+"\"");
+ }
+ }
+ else
+ {
+ echo("file " + filename + " not found. Can't generate symbols file");
+ WScript.Quit (1);
+ }
+}
diff --git a/win/packaging/CMakeLists.txt b/win/packaging/CMakeLists.txt
new file mode 100644
index 00000000..a4d951bf
--- /dev/null
+++ b/win/packaging/CMakeLists.txt
@@ -0,0 +1,245 @@
+# Copyright 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
+
+SET(CAN_BUILD_MSI 1)
+MACRO(CANT_BUILD_MSI reason)
+ IF(BUILD_RELEASE)
+ MESSAGE(FATAL_ERROR "Can't build MSI package - ${reason}")
+ ENDIF()
+ SET(CAN_BUILD_MSI 0)
+ENDMACRO()
+
+IF (NOT CMAKE_C_COMPILER_ARCHITECTURE_ID)
+ CANT_BUILD_MSI("Can't determine compiler architecture")
+ENDIF()
+
+
+STRING(TOLOWER "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" WIX_ARCH)
+
+SET(WIX_BIN_PATHS)
+FOREACH(WIX_VER 3.14 3.13 3.12 3.11)
+ LIST(APPEND WIX_BIN_PATHS "$ENV{ProgramFiles}/WiX Toolset v${WIX_VER}/bin")
+ LIST(APPEND WIX_BIN_PATHS "$ENV{ProgramFiles} (x86)/WiX Toolset v${WIX_VER}/bin")
+ENDFOREACH()
+FIND_PATH(WIX_DIR heat.exe ${WIX_BIN_PATHS})
+IF(NOT WIX_DIR)
+ CANT_BUILD_MSI("WiX version 3.11 or later not found")
+ENDIF()
+
+
+GET_FILENAME_COMPONENT(WIX_SDK_DIR ../SDK/ ABSOLUTE BASE_DIR ${WIX_DIR} CACHE)
+FIND_LIBRARY(WIX_WCAUTIL_LIBRARY
+ wcautil
+ PATHS
+ ${WIX_SDK_DIR}/VS2017/lib/${WIX_ARCH}
+ ${WIX_SDK_DIR}/VS2015/lib/${WIX_ARCH}
+ )
+
+IF(NOT WIX_WCAUTIL_LIBRARY)
+ CANT_BUILD_MSI("wcautil.lib not found for ${WIX_ARCH}")
+ENDIF()
+
+FIND_LIBRARY(WIX_DUTIL_LIBRARY
+ dutil
+ PATHS
+ ${WIX_SDK_DIR}/VS2017/lib/${WIX_ARCH}
+ ${WIX_SDK_DIR}/VS2015/lib/${WIX_ARCH}
+ )
+
+IF(NOT WIX_DUTIL_LIBRARY)
+ CANT_BUILD_MSI("dutil.lib not found for ${WIX_ARCH}")
+ENDIF()
+
+FIND_PATH(WIX_INCLUDE_DIR
+ wcautil.h PATHS
+ ${WIX_SDK_DIR}/VS2017/inc
+ ${WIX_SDK_DIR}/VS2015/inc
+ ${WIX_SDK_DIR}/inc)
+
+IF(NOT WIX_INCLUDE_DIR)
+ CANT_BUILD_MSI("wcautil.h not found for ${WIX_ARCH}")
+ENDIF()
+
+FIND_PROGRAM(CANDLE_EXECUTABLE candle ${WIX_DIR})
+IF(NOT CANDLE_EXECUTABLE)
+ CANT_BUILD_MSI("candle.exe not found")
+ENDIF()
+
+FIND_PROGRAM(LIGHT_EXECUTABLE light ${WIX_DIR})
+IF(NOT LIGHT_EXECUTABLE)
+ CANT_BUILD_MSI("light.exe not found")
+ENDIF()
+
+SET(CPACK_WIX_PACKAGE_BASE_NAME "MariaDB")
+
+SET(CPACK_WIX_UPGRADE_CODE_arm64 "5AA9B79C-643C-4151-811D-B6845AA5DB28")
+SET(CPACK_WIX_UPGRADE_CODE_x86 "49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3")
+SET(CPACK_WIX_UPGRADE_CODE_x64 "2331E7BD-EE58-431B-9E18-B2B918BCEB1B")
+
+SET(CPACK_WIX_UPGRADE_CODE ${CPACK_WIX_UPGRADE_CODE_${WIX_ARCH}})
+IF(NOT CPACK_WIX_UPGRADE_CODE)
+ MESSAGE_ONCE("unknown upgrade code for arch ${WIX_ARCH}")
+ CANT_BUILD_MSI("unknown upgrade code for arch ${WIX_ARCH}")
+ENDIF()
+
+IF(WIX_ARCH STREQUAL "x86")
+ SET(CPACK_WIX_PACKAGE_NAME "MariaDB ${MAJOR_VERSION}.${MINOR_VERSION}")
+ELSE()
+ SET(CPACK_WIX_PACKAGE_NAME "MariaDB ${MAJOR_VERSION}.${MINOR_VERSION} (${WIX_ARCH})")
+ENDIF()
+
+IF(CAN_BUILD_MSI)
+
+ADD_SUBDIRECTORY(ca)
+SET(MANUFACTURER "MariaDB Corporation Ab")
+
+
+
+# WiX wants the license text as rtf; if there is no rtf license,
+# we create a fake one from the plain text COPYING file.
+IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf")
+ SET(COPYING_RTF "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf")
+ELSE()
+ IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../LICENSE.mysql")
+ SET(LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../LICENSE.mysql")
+ ELSE()
+ SET(LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../COPYING")
+ ENDIF()
+ FILE(READ ${LICENSE_FILE} CONTENTS)
+ STRING(REGEX REPLACE "\n" "\\\\par\n" CONTENTS "${CONTENTS}")
+ STRING(REGEX REPLACE "\t" "\\\\tab" CONTENTS "${CONTENTS}")
+ FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Courier New;}}\\viewkind4\\uc1\\pard\\lang1031\\f0\\fs15")
+ FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "${CONTENTS}")
+ FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "\n}\n")
+ SET(COPYING_RTF "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf")
+ENDIF()
+SET(CPACK_WIX_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/CPackWixConfig.cmake)
+
+IF(NOT TARGET mariadb-upgrade-wizard)
+ SET(EXTRA_WIX_PREPROCESSOR_FLAGS "-dHaveUpgradeWizard=0")
+ENDIF()
+IF(WITH_INNOBASE_STORAGE_ENGINE)
+ SET(EXTRA_WIX_PREPROCESSOR_FLAGS ${EXTRA_WIX_PREPROCESSOR_FLAGS} "-dHaveInnodb=1")
+ENDIF()
+
+SET(THIRD_PARTY_FEATURE_CONDITION "")
+
+IF(WITH_THIRD_PARTY)
+ SET(THIRD_PARTY_DOWNLOAD_LOCATION "$ENV{TEMP}")
+ IF(THIRD_PARTY_DOWNLOAD_LOCATION)
+ FILE(TO_CMAKE_PATH "${THIRD_PARTY_DOWNLOAD_LOCATION}" THIRD_PARTY_DOWNLOAD_LOCATION)
+ ELSE()
+ SET(THIRD_PARTY_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}")
+ ENDIF()
+ENDIF()
+
+FOREACH(third_party ${WITH_THIRD_PARTY})
+ SET(third_party_install_plugin ${CMAKE_CURRENT_SOURCE_DIR}/${third_party}.cmake)
+ IF(NOT EXISTS ${third_party_install_plugin})
+ MESSAGE(FATAL_ERROR
+"Third party MSI installation plugin ${third_party_install_plugin} does not exist.
+It was expected due to WITH_THIRD_PARTY=${WITH_THIRD_PARTY}"
+)
+ ENDIF()
+ STRING(TOUPPER "${third_party}" upper_third_party)
+ IF(NOT THIRD_PARTY_FEATURE_CONDITION )
+ SET(THIRD_PARTY_FEATURE_CONDITION "<Condition Level='0'>${upper_third_party}INSTALLED")
+ ELSE()
+ SET(THIRD_PARTY_FEATURE_CONDITION "AND ${upper_third_party}INSTALLED")
+ ENDIF()
+ENDFOREACH()
+
+IF(THIRD_PARTY_FEATURE_CONDITION)
+ SET(THIRD_PARTY_FEATURE_CONDITION "${THIRD_PARTY_FEATURE_CONDITION}</Condition>")
+ENDIF()
+
+IF(CMAKE_GENERATOR MATCHES "Visual Studio")
+ SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}")
+ENDIF()
+
+
+ADD_CUSTOM_TARGET(
+ MSI
+ COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM}
+ -DCANDLE_EXECUTABLE="${CANDLE_EXECUTABLE}"
+ -DCMAKE_CFG_INTDIR="${CMAKE_CFG_INTDIR}"
+ -DCMAKE_FULL_VER="${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}"
+ -DCMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}
+ -DCOPYING_RTF="${COPYING_RTF}"
+ -DCPACK_WIX_CONFIG="${CPACK_WIX_CONFIG}"
+ -DCPACK_WIX_INCLUDE="${CPACK_WIX_INCLUDE}"
+ -DCPACK_WIX_PACKAGE_BASE_NAME="${CPACK_WIX_PACKAGE_BASE_NAME}"
+ -DCPACK_WIX_PACKAGE_NAME="${CPACK_WIX_PACKAGE_NAME}"
+ -DCPACK_WIX_UPGRADE_CODE="${CPACK_WIX_UPGRADE_CODE}"
+ -DEXTRA_WIX_PREPROCESSOR_FLAGS="${EXTRA_WIX_PREPROCESSOR_FLAGS}"
+ -DLIGHT_EXECUTABLE="${LIGHT_EXECUTABLE}"
+ -DMAJOR_VERSION="${MAJOR_VERSION}"
+ -DMANUFACTURER="${MANUFACTURER}"
+ -DMINOR_VERSION="${MINOR_VERSION}"
+ -DPATCH_VERSION="${PATCH_VERSION}"
+ -DSIGNCODE="${SIGNCODE}"
+ -DSIGNTOOL_EXECUTABLE="${SIGNTOOL_EXECUTABLE}"
+ -DSIGNTOOL_PARAMETERS="${SIGNTOOL_PARAMETERS}"
+ -DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}"
+ -DTHIRD_PARTY_DOWNLOAD_LOCATION="${THIRD_PARTY_DOWNLOAD_LOCATION}"
+ -DTHIRD_PARTY_FEATURE_CONDITION="${THIRD_PARTY_FEATURE_CONDITION}"
+ -DTINY_VERSION="${TINY_VERSION}"
+ -DTOP_BINDIR="${CMAKE_BINARY_DIR}"
+ -DVERSION="${VERSION}"
+ -DWITH_THIRD_PARTY="${WITH_THIRD_PARTY}"
+ -DWIXCA_LOCATION="$<TARGET_FILE:wixca>"
+ -DMSVC_CRT_TYPE="${MSVC_CRT_TYPE}"
+ -DDYNAMIC_UCRT_LINK="${DYNAMIC_UCRT_LINK}"
+ -DPlatform="${WIX_ARCH}"
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/create_msi.cmake
+)
+ADD_DEPENDENCIES(MSI wixca)
+
+ENDIF(CAN_BUILD_MSI)
+
+IF(CMAKE_GENERATOR MATCHES "Visual Studio")
+ SET(CPACK_CONFIG_PARAM -C $(Configuration))
+ENDIF()
+
+IF(SIGNCODE)
+ SET(SIGN_COMMAND COMMAND ${CMAKE_COMMAND} -P ${PROJECT_BINARY_DIR}/sign.cmake)
+ENDIF()
+
+ADD_CUSTOM_TARGET(
+ win_package_zip
+ ${SIGN_COMMAND}
+ COMMAND ${CMAKE_CPACK_COMMAND} ${CPACK_CONFIG_PARAM} --config ${CMAKE_CURRENT_SOURCE_DIR}/CPackZipConfig.cmake
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+)
+
+ADD_CUSTOM_TARGET(
+ win_package_debuginfo
+ COMMAND ${CMAKE_CPACK_COMMAND} ${CPACK_CONFIG_PARAM} --config ${CMAKE_CURRENT_SOURCE_DIR}/CPackZipDebugInfoConfig.cmake
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+)
+
+ADD_CUSTOM_TARGET(
+ win_package_test
+ COMMAND ${CMAKE_CPACK_COMMAND} ${CPACK_CONFIG_PARAM} --config ${CMAKE_CURRENT_SOURCE_DIR}/CPackZipTestConfig.cmake
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+)
+
+ADD_CUSTOM_TARGET(win_package DEPENDS win_package_zip win_package_debuginfo)
+SET_TARGET_PROPERTIES(
+ win_package win_package_zip win_package_debuginfo
+ PROPERTIES
+ EXCLUDE_FROM_ALL TRUE
+ EXCLUDE_FROM_DEFAULT_BUILD TRUE
+)
diff --git a/win/packaging/COPYING.rtf b/win/packaging/COPYING.rtf
new file mode 100644
index 00000000..c4dec495
--- /dev/null
+++ b/win/packaging/COPYING.rtf
@@ -0,0 +1,61 @@
+{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fcharset0 Arial;}}
+{\stylesheet{ Normal;}{\s1 heading 1;}{\s2 heading 2;}}
+\viewkind4\uc1\pard\s2\sb100\sa100\b\f0\fs24 GNU GENERAL PUBLIC LICENSE\par
+\pard\sb100\sa100\b0\fs20 Version 2, June 1991 \par
+\pard Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.\fs24 \par
+\pard\s2\sb100\sa100\b Preamble\par
+\pard\sb100\sa100\b0\fs20 The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. \par
+When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. \par
+To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. \par
+For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. \par
+We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. \par
+Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. \par
+Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. \par
+The precise terms and conditions for copying, distribution and modification follow.\fs24 \par
+\pard\s2\sb100\sa100\b TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\par
+\pard\sb100\sa100\b0\fs20 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". \par
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. \par
+1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. \par
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. \par
+2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: \par
+\pard\fi-360\li720\sb100\sa100\tx720\f1\'b7\tab\f0 a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. \par
+\pard\fi-360\li720\sb100\sa100\f1\'b7\tab\f0 b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. \par
+\f1\'b7\tab\f0 c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) \par
+\pard These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. \par
+\pard\sb100\sa100 Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. \par
+In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. \par
+3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: \par
+\pard\fi-360\li720\sb100\sa100\tx720\f1\'b7\tab\f0 a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, \par
+\pard\fi-360\li720\sb100\sa100\f1\'b7\tab\f0 b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, \par
+\f1\'b7\tab\f0 c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) \par
+\pard The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. \par
+\pard\sb100\sa100 If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. \par
+4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. \par
+5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. \par
+6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. \par
+7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. \par
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. \par
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. \par
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. \par
+8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. \par
+9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. \par
+Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. \par
+10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. \par
+NO WARRANTY \par
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. \par
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. \par
+\pard\s2\sb100\sa100\b\fs24 END OF TERMS AND CONDITIONS \par
+How to Apply These Terms to Your New Programs\fs20\par
+\pard\sb100\sa100\b0 If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. \par
+To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. \par
+\pard one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. \par
+\pard\sb100\sa100 Also add information on how to contact you by electronic and paper mail. \par
+If the program is interactive, make it output a short notice like this when it starts in an interactive mode: \par
+\pard Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. \par
+\pard\sb100\sa100 The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c' ; they could even be mouse-clicks or menu items--whatever suits your program. \par
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: \par
+\pard Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon , 1 April 1989 Ty Coon, President of Vice \par
+\pard\sb100\sa100 This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.\par
+\pard\f2\par
+}
+
diff --git a/win/packaging/CPackWixConfig.cmake b/win/packaging/CPackWixConfig.cmake
new file mode 100644
index 00000000..4ac4d384
--- /dev/null
+++ b/win/packaging/CPackWixConfig.cmake
@@ -0,0 +1,121 @@
+
+IF(ESSENTIALS)
+ SET(CPACK_COMPONENTS_USED "Server;Client")
+ SET(CPACK_WIX_UI "MyWixUI_Mondo")
+ IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
+ SET(CPACK_PACKAGE_FILE_NAME "mariadb-essential-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-winx64")
+ ELSE()
+ SET(CPACK_PACKAGE_FILE_NAME "mariadb-essential-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-win32")
+ ENDIF()
+ELSE()
+ SET(CPACK_COMPONENTS_USED
+ "Server;Client;Development;SharedLibraries;Documentation;Readme;Common;connect-engine;ClientPlugins;gssapi-server;gssapi-client;aws-key-management;rocksdb-engine;backup;VCCRT")
+ENDIF()
+
+SET( WIX_FEATURE_MySQLServer_EXTRA_FEATURES "DBInstance;SharedClientServerComponents")
+# Some components like Embedded are optional
+# We will build MSI without embedded if it was not selected for build
+#(need to modify CPACK_COMPONENTS_ALL for that)
+SET(CPACK_ALL)
+FOREACH(comp1 ${CPACK_COMPONENTS_USED})
+ SET(found)
+ FOREACH(comp2 ${CPACK_COMPONENTS_ALL})
+ IF(comp1 STREQUAL comp2)
+ SET(found 1)
+ BREAK()
+ ENDIF()
+ ENDFOREACH()
+ IF(found)
+ SET(CPACK_ALL ${CPACK_ALL} ${comp1})
+ ENDIF()
+ENDFOREACH()
+SET(CPACK_COMPONENTS_ALL ${CPACK_ALL})
+
+# Always install (hidden), includes Readme files
+SET(CPACK_COMPONENT_GROUP_ALWAYSINSTALL_HIDDEN 1)
+SET(CPACK_COMPONENT_README_GROUP "AlwaysInstall")
+SET(CPACK_COMPONENT_COMMON_GROUP "AlwaysInstall")
+SET(CPACK_COMPONENT_VCCRT_GROUP "AlwaysInstall")
+
+# Feature MySQL Server
+SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DISPLAY_NAME "MariaDB Server")
+SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_EXPANDED "1")
+SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DESCRIPTION "Install server")
+ # Subfeature "Server" (hidden)
+ SET(CPACK_COMPONENT_SERVER_GROUP "MySQLServer")
+ SET(CPACK_COMPONENT_SERVER_HIDDEN 1)
+ # Subfeature "Client"
+ SET(CPACK_COMPONENT_CLIENT_GROUP "MySQLServer")
+ SET(CPACK_COMPONENT_CLIENT_DISPLAY_NAME "Client Programs")
+ SET(CPACK_COMPONENT_CLIENT_DESCRIPTION
+ "Various helpful (commandline) tools including the mysql command line client" )
+ # Subfeature "Debug binaries"
+ SET(CPACK_COMPONENT_DEBUGBINARIES_GROUP "MySQLServer")
+ SET(CPACK_COMPONENT_DEBUGBINARIES_DISPLAY_NAME "Debug binaries")
+ SET(CPACK_COMPONENT_DEBUGBINARIES_DESCRIPTION
+ "Debug/trace versions of executables and libraries" )
+ #SET(CPACK_COMPONENT_DEBUGBINARIES_WIX_LEVEL 2)
+
+ # Subfeature "Backup"
+ SET(CPACK_COMPONENT_BACKUP_GROUP "MySQLServer")
+ SET(CPACK_COMPONENT_BACKUP_DISPLAY_NAME "Backup utilities")
+ SET(CPACK_COMPONENT_BACKUP_DESCRIPTION "Installs backup utilities(mariabackup and mbstream)")
+
+
+ #Miscellaneous (hidden) components, part of server / or client programs
+ FOREACH(comp connect-engine ClientPlugins gssapi-server gssapi-client aws-key-management rocksdb-engine)
+ STRING(TOUPPER "${comp}" comp)
+ SET(CPACK_COMPONENT_${comp}_GROUP "MySQLServer")
+ SET(CPACK_COMPONENT_${comp}_HIDDEN 1)
+ ENDFOREACH()
+
+#Feature "Devel"
+SET(CPACK_COMPONENT_GROUP_DEVEL_DISPLAY_NAME "Development Components")
+SET(CPACK_COMPONENT_GROUP_DEVEL_DESCRIPTION "Installs C/C++ header files and libraries")
+ #Subfeature "Development"
+ SET(CPACK_COMPONENT_DEVELOPMENT_GROUP "Devel")
+ SET(CPACK_COMPONENT_DEVELOPMENT_HIDDEN 1)
+
+ #Subfeature "Shared libraries"
+ SET(CPACK_COMPONENT_SHAREDLIBRARIES_GROUP "Devel")
+ SET(CPACK_COMPONENT_SHAREDLIBRARIES_DISPLAY_NAME "Client C API library (shared)")
+ SET(CPACK_COMPONENT_SHAREDLIBRARIES_DESCRIPTION "Installs shared client library")
+
+ #Subfeature "Embedded"
+ SET(CPACK_COMPONENT_EMBEDDED_GROUP "Devel")
+ SET(CPACK_COMPONENT_EMBEDDED_DISPLAY_NAME "Embedded server library")
+ SET(CPACK_COMPONENT_EMBEDDED_DESCRIPTION "Installs embedded server library")
+ SET(CPACK_COMPONENT_EMBEDDED_WIX_LEVEL 2)
+
+#Feature Debug Symbols
+SET(CPACK_COMPONENT_GROUP_DEBUGSYMBOLS_DISPLAY_NAME "Debug Symbols")
+SET(CPACK_COMPONENT_GROUP_DEBUGSYMBOLS_DESCRIPTION "Installs Debug Symbols")
+SET(CPACK_COMPONENT_DEBUGSYMBOLS_WIX_LEVEL 2)
+ SET(CPACK_COMPONENT_DEBUGINFO_GROUP "DebugSymbols")
+ SET(CPACK_COMPONENT_DEBUGINFO_HIDDEN 1)
+
+#Feature Documentation
+SET(CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "Documentation")
+SET(CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION "Installs documentation")
+SET(CPACK_COMPONENT_DOCUMENTATION_WIX_LEVEL 2)
+
+#Feature tests
+SET(CPACK_COMPONENT_TEST_DISPLAY_NAME "Tests")
+SET(CPACK_COMPONENT_TEST_DESCRIPTION "Installs unittests (requires Perl to run)")
+SET(CPACK_COMPONENT_TEST_WIX_LEVEL 2)
+
+
+#Feature Misc (hidden, installs only if everything is installed)
+SET(CPACK_COMPONENT_GROUP_MISC_HIDDEN 1)
+SET(CPACK_COMPONENT_GROUP_MISC_WIX_LEVEL 100)
+ SET(CPACK_COMPONENT_INIFILES_GROUP "Misc")
+ SET(CPACK_COMPONENT_SERVER_SCRIPTS_GROUP "Misc")
+
+#Add Firewall exception for mysqld.exe
+SET(bin.mysqld.exe.FILE_EXTRA "
+ <FirewallException Id='firewallexception.mysqld.exe' Name='[ProductName]' Scope='any'
+ IgnoreFailure='yes' xmlns='http://schemas.microsoft.com/wix/FirewallExtension'
+ />
+ "
+)
+
diff --git a/win/packaging/CPackZIPConfig.cmake b/win/packaging/CPackZIPConfig.cmake
new file mode 100644
index 00000000..5afbffbf
--- /dev/null
+++ b/win/packaging/CPackZIPConfig.cmake
@@ -0,0 +1,11 @@
+INCLUDE(CPackConfig.cmake)
+SET(CPACK_GENERATOR ZIP)
+set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
+set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
+SET(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY ON)
+FOREACH(it DebugBinaries Debuginfo IniFiles Junk Test SqlBench)
+ list(FIND CPACK_COMPONENTS_ALL "${it}" index)
+ IF(index GREATER 0)
+ LIST(REMOVE_AT CPACK_COMPONENTS_ALL ${index})
+ ENDIF()
+ENDFOREACH()
diff --git a/win/packaging/CPackZIPDebugInfoConfig.cmake b/win/packaging/CPackZIPDebugInfoConfig.cmake
new file mode 100644
index 00000000..674c1675
--- /dev/null
+++ b/win/packaging/CPackZIPDebugInfoConfig.cmake
@@ -0,0 +1,6 @@
+INCLUDE(CPackConfig.cmake)
+set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-debugsymbols")
+set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
+set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
+SET(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY ON)
+SET(CPACK_COMPONENTS_ALL Debuginfo)
diff --git a/win/packaging/CPackZIPTestConfig.cmake b/win/packaging/CPackZIPTestConfig.cmake
new file mode 100644
index 00000000..1dfba7ec
--- /dev/null
+++ b/win/packaging/CPackZIPTestConfig.cmake
@@ -0,0 +1,6 @@
+INCLUDE(CPackConfig.cmake)
+set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-test")
+set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
+set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
+SET(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY ON)
+SET(CPACK_COMPONENTS_ALL Test)
diff --git a/win/packaging/WixUIBannerBmp.jpg b/win/packaging/WixUIBannerBmp.jpg
new file mode 100644
index 00000000..66256b79
--- /dev/null
+++ b/win/packaging/WixUIBannerBmp.jpg
Binary files differ
diff --git a/win/packaging/WixUIDialogBmp.jpg b/win/packaging/WixUIDialogBmp.jpg
new file mode 100644
index 00000000..c6ddf12b
--- /dev/null
+++ b/win/packaging/WixUIDialogBmp.jpg
Binary files differ
diff --git a/win/packaging/ca/CMakeLists.txt b/win/packaging/ca/CMakeLists.txt
new file mode 100644
index 00000000..368a844f
--- /dev/null
+++ b/win/packaging/ca/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Copyright 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
+
+SET(WIXCA_SOURCES CustomAction.cpp CustomAction.def)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql ${CMAKE_CURRENT_SOURCE_DIR} ${WIX_INCLUDE_DIR})
+
+# 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)
+ADD_LIBRARY(wixca SHARED EXCLUDE_FROM_ALL ${WIXCA_SOURCES} ${CMAKE_SOURCE_DIR}/sql/winservice.c)
+TARGET_LINK_LIBRARIES(wixca ${WIX_WCAUTIL_LIBRARY} ${WIX_DUTIL_LIBRARY} msi version)
diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp
new file mode 100644
index 00000000..c397ce23
--- /dev/null
+++ b/win/packaging/ca/CustomAction.cpp
@@ -0,0 +1,1134 @@
+/* Copyright 2010, Oracle and/or its affiliates. All rights reserved.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
+
+#ifndef UNICODE
+#define UNICODE
+#endif
+
+#undef NOMINMAX
+
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <windows.h>
+#include <winreg.h>
+#include <msi.h>
+#include <msiquery.h>
+#include <wcautil.h>
+#include <strutil.h>
+#include <string.h>
+#include <strsafe.h>
+#include <assert.h>
+#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)
+{
+ /* Strip stray backslash */
+ DWORD len = (DWORD)wcslen(dir);
+ if(len > 0 && dir[len-1]==L'\\')
+ dir[len-1] = 0;
+
+ SHFILEOPSTRUCTW fileop;
+ fileop.hwnd= NULL; /* no status display */
+ fileop.wFunc= FO_DELETE; /* delete operation */
+ fileop.pFrom= dir; /* source file name as double null terminated string */
+ fileop.pTo= NULL; /* no destination needed */
+ fileop.fFlags= FOF_NOCONFIRMATION|FOF_SILENT; /* do not prompt the user */
+
+ fileop.fAnyOperationsAborted= FALSE;
+ fileop.lpszProgressTitle= NULL;
+ fileop.hNameMappings= NULL;
+
+ return SHFileOperationW(&fileop);
+}
+
+
+extern "C" UINT __stdcall RemoveDataDirectory(MSIHANDLE hInstall)
+{
+ HRESULT hr = S_OK;
+ UINT er = ERROR_SUCCESS;
+ wchar_t dir[MAX_PATH];
+ DWORD len = MAX_PATH;
+
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ ExitOnFailure(hr, "Failed to initialize");
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
+
+ MsiGetPropertyW(hInstall, L"CustomActionData", dir, &len);
+
+ er= ExecRemoveDataDirectory(dir);
+ WcaLog(LOGMSG_STANDARD, "SHFileOperation returned %d", er);
+LExit:
+ return WcaFinalize(er);
+}
+
+/*
+ Escape command line parameter fpr pass to CreateProcess().
+
+ 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
+ the string.
+*/
+static void EscapeCommandLine(const wchar_t *in, wchar_t *out, size_t buflen)
+{
+ const wchar_t special_chars[]=L" \t\n\v\"";
+ bool needs_escaping= false;
+ size_t pos;
+
+ for(size_t i=0; i< sizeof(special_chars) -1; i++)
+ {
+ if (wcschr(in, special_chars[i]))
+ {
+ needs_escaping = true;
+ break;
+ }
+ }
+
+ if(!needs_escaping)
+ {
+ wcscpy_s(out, buflen, in);
+ return;
+ }
+
+ pos= 0;
+ for(int i = 0 ; ; i++)
+ {
+ size_t n_backslashes = 0;
+ wchar_t c;
+ while (in[i] == L'\\')
+ {
+ i++;
+ n_backslashes++;
+ }
+
+ c= in[i];
+ if (c == 0)
+ {
+ /*
+ 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++)
+ {
+ out[pos++]=L'\\';
+ }
+ break;
+ }
+ else if (c == L'"')
+ {
+ /*
+ Escape all backslashes and the following double quotation mark.
+ */
+ for(size_t j= 0; j < 2*n_backslashes + 1; j++)
+ {
+ out[pos++]=L'\\';
+ }
+ out[pos++]= L'"';
+ }
+ else
+ {
+ /* Backslashes aren't special here. */
+ for (size_t j=0; j < n_backslashes; j++)
+ out[pos++] = L'\\';
+
+ out[pos++]= c;
+ }
+ }
+ out[pos++]= 0;
+}
+
+bool IsDirectoryEmptyOrNonExisting(const wchar_t *dir) {
+ wchar_t wildcard[MAX_PATH+3];
+ WIN32_FIND_DATAW data;
+ HANDLE h;
+ wcscpy_s(wildcard, MAX_PATH, dir);
+ wcscat_s(wildcard, MAX_PATH, L"*.*");
+ bool empty= true;
+ h= FindFirstFile(wildcard, &data);
+ if (h != INVALID_HANDLE_VALUE)
+ {
+ for (;;)
+ {
+ if (wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L".."))
+ {
+ empty= false;
+ break;
+ }
+ if (!FindNextFile(h, &data))
+ break;
+ }
+ FindClose(h);
+ }
+ return empty;
+}
+
+extern "C" UINT __stdcall CheckInstallDirectory(MSIHANDLE hInstall)
+{
+ HRESULT hr= S_OK;
+ UINT er= ERROR_SUCCESS;
+ wchar_t *path= 0;
+
+ hr= WcaInitialize(hInstall, __FUNCTION__);
+ ExitOnFailure(hr, "Failed to initialize");
+ WcaGetFormattedString(L"[INSTALLDIR]", &path);
+ if (!IsDirectoryEmptyOrNonExisting(path))
+ {
+ wchar_t msg[2*MAX_PATH];
+ swprintf(msg,countof(msg), L"Installation directory '%s' exists and is not empty. Choose a "
+ "different install directory",path);
+ WcaSetProperty(L"INSTALLDIRERROR", msg);
+ goto LExit;
+ }
+
+ WcaSetProperty(L"INSTALLDIRERROR", L"");
+
+LExit:
+ ReleaseStr(path);
+ return WcaFinalize(er);
+}
+
+/*
+ Check for valid data directory is empty during install
+ A valid data directory is non-existing, or empty.
+
+ In addition, it must be different from any directories that
+ are going to be installed. This is required. because the full
+ directory is removed on a feature uninstall, and we do not want
+ it to be lib or bin.
+*/
+extern "C" UINT __stdcall CheckDataDirectory(MSIHANDLE hInstall)
+{
+ HRESULT hr= S_OK;
+ UINT er= ERROR_SUCCESS;
+ wchar_t datadir[MAX_PATH];
+ DWORD len= MAX_PATH;
+ bool empty;
+ wchar_t *path= 0;
+
+ MsiGetPropertyW(hInstall, L"DATADIR", datadir, &len);
+ hr= WcaInitialize(hInstall, __FUNCTION__);
+ ExitOnFailure(hr, "Failed to initialize");
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
+
+ WcaLog(LOGMSG_STANDARD, "Checking files in %S", datadir);
+ empty= IsDirectoryEmptyOrNonExisting(datadir);
+ if (empty)
+ WcaLog(LOGMSG_STANDARD, "DATADIR is empty or non-existent");
+ else
+ WcaLog(LOGMSG_STANDARD, "DATADIR is NOT empty");
+
+ if (!empty)
+ {
+ WcaSetProperty(L"DATADIRERROR", L"data directory exist and not empty");
+ goto LExit;
+ }
+ WcaSetProperty(L"DATADIRERROR", L"");
+
+
+ WcaGetFormattedString(L"[INSTALLDIR]",&path);
+ if (path && !wcsicmp(datadir, path))
+ {
+ WcaSetProperty(L"DATADIRERROR", L"data directory can not be "
+ L"installation root directory");
+ ReleaseStr(path);
+ goto LExit;
+ }
+ for (auto dir :
+ {L"[INSTALLDIR]bin\\", L"[INSTALLDIR]include\\",
+ L"[INSTALLDIR]lib\\", L"[INSTALLDIR]share\\"})
+ {
+ WcaGetFormattedString(dir, &path);
+ if (path && !wcsnicmp(datadir, path, wcslen(path)))
+ {
+ const wchar_t *subdir= dir + sizeof("[INSTALLDIR]") - 1;
+ wchar_t msg[MAX_PATH]= L"data directory conflicts with '";
+ wcsncat_s(msg, subdir, wcslen(subdir) - 1);
+ wcscat_s(msg, L"' directory, which is part of this installation");
+ WcaSetProperty(L"DATADIRERROR", msg);
+ ReleaseStr(path);
+ goto LExit;
+ }
+ ReleaseStr(path);
+ path= 0;
+ }
+LExit:
+ return WcaFinalize(er);
+}
+
+
+bool CheckServiceExists(const wchar_t *name)
+{
+ SC_HANDLE manager =0, service=0;
+ manager = OpenSCManager( NULL, NULL, SC_MANAGER_CONNECT);
+ if (!manager)
+ {
+ return false;
+ }
+
+ service = OpenService(manager, name, SC_MANAGER_CONNECT);
+ if(service)
+ CloseServiceHandle(service);
+ CloseServiceHandle(manager);
+
+ return service?true:false;
+}
+
+/* User in rollback of create database custom action */
+bool ExecRemoveService(const wchar_t *name)
+{
+ SC_HANDLE manager =0, service=0;
+ manager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ bool ret;
+ if (!manager)
+ {
+ return false;
+ }
+ service = OpenService(manager, name, DELETE);
+ if(service)
+ {
+ ret= DeleteService(service);
+ }
+ else
+ {
+ ret= false;
+ }
+ CloseServiceHandle(manager);
+ return ret;
+}
+
+/* Find whether TCP port is in use by trying to bind to the port. */
+static bool IsPortInUse(unsigned short port)
+{
+ struct addrinfo* ai, * a;
+ struct addrinfo hints {};
+
+ char port_buf[NI_MAXSERV];
+ SOCKET ip_sock = INVALID_SOCKET;
+ hints.ai_flags = AI_PASSIVE;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_family = AF_UNSPEC;
+ snprintf(port_buf, NI_MAXSERV, "%u", (unsigned)port);
+
+ if (getaddrinfo(NULL, port_buf, &hints, &ai))
+ {
+ return false;
+ }
+
+ /*
+ Prefer IPv6 socket to IPv4, since we'll use IPv6 dual socket,
+ which coveres both IP versions.
+ */
+ for (a = ai; a; a = a->ai_next)
+ {
+ if (a->ai_family == AF_INET6 &&
+ (ip_sock = socket(a->ai_family, a->ai_socktype, a->ai_protocol)) != INVALID_SOCKET)
+ {
+ break;
+ }
+ }
+
+ if (ip_sock == INVALID_SOCKET)
+ {
+ for (a = ai; a; a = a->ai_next)
+ {
+ if (ai->ai_family == AF_INET &&
+ (ip_sock = socket(a->ai_family, a->ai_socktype, a->ai_protocol)) != INVALID_SOCKET)
+ {
+ break;
+ }
+ }
+ }
+
+ if (ip_sock == INVALID_SOCKET)
+ {
+ return false;
+ }
+
+ /* Use SO_EXCLUSIVEADDRUSE to prevent multiple binding. */
+ int arg = 1;
+ setsockopt(ip_sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char*)&arg, sizeof(arg));
+
+ /* Allow dual socket, so that IPv4 and IPv6 are both covered.*/
+ if (a->ai_family == AF_INET6)
+ {
+ arg = 0;
+ setsockopt(ip_sock, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&arg, sizeof(arg));
+ }
+
+ bool in_use = false;
+ if (bind(ip_sock, a->ai_addr, (int)a->ai_addrlen) == SOCKET_ERROR)
+ {
+ DWORD last_error = WSAGetLastError();
+ in_use = (last_error == WSAEADDRINUSE || last_error == WSAEACCES);
+ }
+
+ freeaddrinfo(ai);
+ closesocket(ip_sock);
+ return in_use;
+}
+
+
+/*
+ Check if TCP port is free
+*/
+bool IsPortFree(unsigned short port)
+{
+ WORD wVersionRequested = MAKEWORD(2, 2);
+ WSADATA wsaData;
+ WSAStartup(wVersionRequested, &wsaData);
+ bool in_use = IsPortInUse(port);
+ WSACleanup();
+ return !in_use;
+}
+
+
+/*
+ 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
+*/
+wchar_t *strip_quotes(wchar_t *s)
+{
+ if (s && (*s == L'"'))
+ {
+ s++;
+ wchar_t *p = wcschr(s, L'"');
+ if(p)
+ *p = 0;
+ }
+ return 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
+ 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,
+ 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
+ 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
+ installation mean, that either datadir or service is kept.
+*/
+
+void CheckServiceConfig(
+ wchar_t *my_servicename, /* SERVICENAME property in this installation*/
+ wchar_t *datadir, /* DATADIR property in this installation*/
+ wchar_t *bindir, /* INSTALLDIR\bin */
+ wchar_t *other_servicename, /* Service to check against */
+ QUERY_SERVICE_CONFIGW * config /* Other service's config */
+ )
+{
+
+ bool same_bindir = false;
+ wchar_t * commandline= config->lpBinaryPathName;
+ int numargs;
+ wchar_t **argv= CommandLineToArgvW(commandline, &numargs);
+ wchar_t current_datadir_buf[MAX_PATH]={0};
+ wchar_t normalized_current_datadir[MAX_PATH+1];
+ wchar_t *current_datadir;
+ wchar_t *defaults_file;
+ bool is_my_service;
+
+ WcaLog(LOGMSG_VERBOSE, "CommandLine= %S", commandline);
+ if(!argv || !argv[0] || ! wcsstr(argv[0], L"mysqld"))
+ {
+ goto end;
+ }
+
+ WcaLog(LOGMSG_STANDARD, "MySQL/MariaDB service %S found: CommandLine= %S",
+ other_servicename, commandline);
+ if (wcsstr(argv[0], bindir))
+ {
+ WcaLog(LOGMSG_STANDARD, "executable under bin directory");
+ same_bindir = true;
+ }
+
+ is_my_service = (_wcsicmp(my_servicename, other_servicename) == 0);
+ 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",
+ bindir);
+ WcaSetProperty(L"SERVICENAME", L"");
+ }
+
+ /* Check if data directory is used */
+ if(!datadir || numargs <= 1 || wcsncmp(argv[1],L"--defaults-file=",16) != 0)
+ {
+ goto end;
+ }
+
+ current_datadir= current_datadir_buf;
+ defaults_file= argv[1]+16;
+ defaults_file= strip_quotes(defaults_file);
+
+ WcaLog(LOGMSG_STANDARD, "parsed defaults file is %S", defaults_file);
+
+ if (GetPrivateProfileStringW(L"mysqld", L"datadir", NULL, current_datadir,
+ MAX_PATH, defaults_file) == 0)
+ {
+ WcaLog(LOGMSG_STANDARD,
+ "Cannot find datadir in ini file '%S'", defaults_file);
+ goto end;
+ }
+
+ WcaLog(LOGMSG_STANDARD, "datadir from defaults-file is %S", current_datadir);
+ strip_quotes(current_datadir);
+
+ /* Convert to Windows path */
+ 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'",
+ normalized_current_datadir);
+ }
+
+ if (_wcsicmp(datadir, normalized_current_datadir) == 0 && !same_bindir)
+ {
+ WcaLog(LOGMSG_STANDARD,
+ "database directory from current installation, but different mysqld.exe");
+ WcaSetProperty(L"CLEANUPDATA", L"");
+ }
+
+end:
+ LocalFree((HLOCAL)argv);
+}
+
+/*
+ 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
+ uninstall should neither delete service nor database directory.
+
+ 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
+ DATADIR and CLEANUPDATA are removed.
+
+ The effect of variable removal is that service does not get uninstalled and
+ datadir is not touched by uninstallation.
+
+ Note that this function is running without elevation and does not use anything
+ that would require special privileges.
+
+*/
+extern "C" UINT CheckDBInUse(MSIHANDLE hInstall)
+{
+ static BYTE buf[256*1024]; /* largest possible buffer for EnumServices */
+ static char config_buffer[8*1024]; /*largest buffer for QueryServiceConfig */
+ HRESULT hr = S_OK;
+ UINT er = ERROR_SUCCESS;
+ wchar_t *servicename= NULL;
+ 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;
+ BOOL ok;
+
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ ExitOnFailure(hr, "Failed to initialize");
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
+
+ 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)
+ {
+ ExitOnFailure(E_FAIL, "OpenSCManager failed");
+ }
+
+ ok = EnumServicesStatusExW( scm,
+ SC_ENUM_PROCESS_INFO,
+ SERVICE_WIN32,
+ SERVICE_STATE_ALL,
+ buf,
+ bufsize,
+ &bufneed,
+ &num_services,
+ NULL,
+ NULL);
+ if(!ok)
+ {
+ WcaLog(LOGMSG_STANDARD, "last error %d", GetLastError());
+ ExitOnFailure(E_FAIL, "EnumServicesStatusExW failed");
+ }
+ info = (LPENUM_SERVICE_STATUS_PROCESS)buf;
+ for (ULONG i=0; i < num_services; i++)
+ {
+ 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 *)(void *)config_buffer;
+ DWORD needed;
+ BOOL ok= QueryServiceConfigW(service, config,sizeof(config_buffer),
+ &needed);
+ CloseServiceHandle(service);
+ if (ok)
+ {
+ CheckServiceConfig(servicename, datadir, bindir, info[i].lpServiceName,
+ config);
+ }
+ }
+
+LExit:
+ if(scm)
+ CloseServiceHandle(scm);
+
+ ReleaseStr(servicename);
+ ReleaseStr(datadir);
+ ReleaseStr(bindir);
+ 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
+ limit maximum size of continuous memory block further,
+ 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)
+{
+#ifdef _M_IX86
+ BOOL wow64;
+ if (IsWow64Process(GetCurrentProcess(), &wow64))
+ return min(totalPhys, 2000ULL*ONE_MB);
+ else
+ return min(totalPhys, 1200ULL*ONE_MB);
+#else
+ return totalPhys;
+#endif
+}
+
+
+/*
+ Magic undocumented number for bufferpool minimum,
+ allows innodb to start also for all page sizes.
+*/
+static constexpr unsigned long long minBufferpoolMB= 20;
+
+/*
+ Checks SERVICENAME, PORT and BUFFERSIZE parameters
+*/
+extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
+{
+ wchar_t ServiceName[MAX_PATH]={0};
+ wchar_t SkipNetworking[MAX_PATH]={0};
+ wchar_t QuickConfig[MAX_PATH]={0};
+ wchar_t Password[MAX_PATH]={0};
+ wchar_t EscapedPassword[2*MAX_PATH+2];
+ wchar_t Port[6];
+ wchar_t BufferPoolSize[16];
+ DWORD PortLen=6;
+ bool haveInvalidPort=false;
+ const wchar_t *ErrorMsg=0;
+ HRESULT hr= S_OK;
+ UINT er= ERROR_SUCCESS;
+ DWORD ServiceNameLen = MAX_PATH;
+ DWORD QuickConfigLen = MAX_PATH;
+ DWORD PasswordLen= MAX_PATH;
+ DWORD SkipNetworkingLen= MAX_PATH;
+
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ ExitOnFailure(hr, "Failed to initialize");
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
+
+
+ MsiGetPropertyW (hInstall, L"SERVICENAME", ServiceName, &ServiceNameLen);
+ if(ServiceName[0])
+ {
+ if(ServiceNameLen > 256)
+ {
+ ErrorMsg= L"Invalid service name. The maximum length is 256 characters.";
+ goto LExit;
+ }
+ for(DWORD i=0; i< ServiceNameLen;i++)
+ {
+ if(ServiceName[i] == L'\\' || ServiceName[i] == L'/'
+ || ServiceName[i]=='\'' || ServiceName[i] ==L'"')
+ {
+ ErrorMsg =
+ L"Invalid service name. Forward slash and back slash are forbidden."
+ L"Single and double quotes are also not permitted.";
+ goto LExit;
+ }
+ }
+ if(CheckServiceExists(ServiceName))
+ {
+ ErrorMsg=
+ L"A service with the same name already exists. "
+ L"Please use a different name.";
+ goto LExit;
+ }
+ }
+
+ MsiGetPropertyW (hInstall, L"PASSWORD", Password, &PasswordLen);
+ EscapeCommandLine(Password, EscapedPassword,
+ sizeof(EscapedPassword)/sizeof(EscapedPassword[0]));
+ MsiSetPropertyW(hInstall,L"ESCAPEDPASSWORD",EscapedPassword);
+
+ MsiGetPropertyW(hInstall, L"SKIPNETWORKING", SkipNetworking,
+ &SkipNetworkingLen);
+ MsiGetPropertyW(hInstall, L"PORT", Port, &PortLen);
+
+ if(SkipNetworking[0]==0 && Port[0] != 0)
+ {
+ /* Strip spaces */
+ for(DWORD i=PortLen-1; i > 0; i--)
+ {
+ if(Port[i]== ' ')
+ Port[i] = 0;
+ }
+
+ if(PortLen > 5 || PortLen <= 3)
+ haveInvalidPort = true;
+ else
+ {
+ for (DWORD i=0; i< PortLen && Port[i] != 0;i++)
+ {
+ if(Port[i] < '0' || Port[i] >'9')
+ {
+ haveInvalidPort=true;
+ break;
+ }
+ }
+ }
+ if (haveInvalidPort)
+ {
+ ErrorMsg =
+ L"Invalid port number. Please use a number between 1025 and 65535.";
+ goto LExit;
+ }
+
+ unsigned short port = (unsigned short)_wtoi(Port);
+ if (!IsPortFree(port))
+ {
+ 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)
+ {
+ MEMORYSTATUSEX memstatus;
+ memstatus.dwLength =sizeof(memstatus);
+ wchar_t invalidValueMsg[256];
+
+ if (!GlobalMemoryStatusEx(&memstatus))
+ {
+ WcaLog(LOGMSG_STANDARD, "Error %u from GlobalMemoryStatusEx",
+ GetLastError());
+ er= ERROR_INSTALL_FAILURE;
+ goto LExit;
+ }
+ DWORD BufferPoolSizeLen= 16;
+ MsiGetPropertyW(hInstall, L"BUFFERPOOLSIZE", BufferPoolSize, &BufferPoolSizeLen);
+ /* Strip spaces */
+ for(DWORD i=BufferPoolSizeLen-1; i > 0; i--)
+ {
+ if(BufferPoolSize[i]== ' ')
+ BufferPoolSize[i] = 0;
+ }
+ unsigned long long availableMemory=
+ GetMaxBufferSize(memstatus.ullTotalPhys)/ONE_MB;
+ swprintf_s(invalidValueMsg,
+ L"Invalid buffer pool size. Please use a number between %llu and %llu",
+ minBufferpoolMB, availableMemory);
+ if (BufferPoolSizeLen == 0 || BufferPoolSizeLen > 15 || !BufferPoolSize[0])
+ {
+ ErrorMsg= invalidValueMsg;
+ goto LExit;
+ }
+
+ BufferPoolSize[BufferPoolSizeLen]=0;
+ MsiSetPropertyW(hInstall, L"BUFFERPOOLSIZE", BufferPoolSize);
+ wchar_t *end;
+ unsigned long long sz = wcstoull(BufferPoolSize, &end, 10);
+ if (sz > availableMemory || sz < minBufferpoolMB || *end)
+ {
+ if (*end == 0)
+ {
+ if(sz > availableMemory)
+ {
+ swprintf_s(invalidValueMsg,
+ L"Value for buffer pool size is too large."
+ L"Only approximately %llu MB is available for allocation."
+ L"Please use a number between %llu and %llu.",
+ availableMemory, minBufferpoolMB, availableMemory);
+ }
+ else if(sz < minBufferpoolMB)
+ {
+ swprintf_s(invalidValueMsg,
+ L"Value for buffer pool size is too small."
+ L"Please use a number between %llu and %llu.",
+ minBufferpoolMB, availableMemory);
+ }
+ }
+ ErrorMsg= invalidValueMsg;
+ goto LExit;
+ }
+ }
+LExit:
+ MsiSetPropertyW (hInstall, L"WarningText", ErrorMsg);
+ 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(100, innodb buffer pool size/4)
+*/
+extern "C" UINT __stdcall PresetDatabaseProperties(MSIHANDLE hInstall)
+{
+ unsigned long long InnodbBufferPoolSize= 256;
+ unsigned long long InnodbLogFileSize= 100;
+ wchar_t buff[MAX_PATH];
+ UINT er = ERROR_SUCCESS;
+ HRESULT hr= S_OK;
+ MEMORYSTATUSEX memstatus;
+ DWORD BufferPoolsizeParamLen = MAX_PATH;
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ ExitOnFailure(hr, "Failed to initialize");
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
+
+ /* Check if bufferpoolsize parameter was given on the command line*/
+ MsiGetPropertyW(hInstall, L"BUFFERPOOLSIZE", buff, &BufferPoolsizeParamLen);
+
+ if (BufferPoolsizeParamLen && buff[0])
+ {
+ WcaLog(LOGMSG_STANDARD, "BUFFERPOOLSIZE=%S, len=%u",buff, BufferPoolsizeParamLen);
+ InnodbBufferPoolSize= _wtoi64(buff);
+ }
+ else
+ {
+ memstatus.dwLength = sizeof(memstatus);
+ if (!GlobalMemoryStatusEx(&memstatus))
+ {
+ WcaLog(LOGMSG_STANDARD, "Error %u from GlobalMemoryStatusEx",
+ GetLastError());
+ er= ERROR_INSTALL_FAILURE;
+ goto LExit;
+ }
+ unsigned long long totalPhys= memstatus.ullTotalPhys;
+ /* 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
+ swprintf_s(buff, L"%llu",InnodbBufferPoolSize);
+ MsiSetPropertyW(hInstall, L"BUFFERPOOLSIZE", buff);
+ }
+ InnodbLogFileSize = min(100, 2 * InnodbBufferPoolSize);
+ swprintf_s(buff, L"%llu",InnodbLogFileSize);
+ MsiSetPropertyW(hInstall, L"LOGFILESIZE", buff);
+
+LExit:
+ return WcaFinalize(er);
+}
+
+static BOOL FindErrorLog(const wchar_t *dir, wchar_t * ErrorLogFile, size_t ErrorLogLen)
+{
+ WIN32_FIND_DATA FindFileData;
+ HANDLE hFind;
+ wchar_t name[MAX_PATH];
+ wcsncpy_s(name,dir, MAX_PATH);
+ wcsncat_s(name,L"\\*.err", MAX_PATH);
+ hFind = FindFirstFileW(name,&FindFileData);
+ if (hFind != INVALID_HANDLE_VALUE)
+ {
+ _snwprintf(ErrorLogFile, ErrorLogLen,
+ L"%s\\%s",dir, FindFileData.cFileName);
+ FindClose(hFind);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void DumpErrorLog(const wchar_t *dir)
+{
+ wchar_t filepath[MAX_PATH];
+ if (!FindErrorLog(dir, filepath, MAX_PATH))
+ return;
+ FILE *f= _wfopen(filepath, L"r");
+ if (!f)
+ return;
+ char buf[2048];
+ WcaLog(LOGMSG_STANDARD,"=== dumping error log %S === ",filepath);
+ while (fgets(buf, sizeof(buf), f))
+ {
+ /* Strip off EOL chars. */
+ size_t len = strlen(buf);
+ if (len > 0 && buf[len-1] == '\n')
+ buf[--len]= 0;
+ if (len > 0 && buf[len-1] == '\r')
+ buf[--len]= 0;
+ WcaLog(LOGMSG_STANDARD,"%s",buf);
+ }
+ fclose(f);
+ WcaLog(LOGMSG_STANDARD,"=== end of error log ===");
+}
+
+/* Remove service and data directory created by CreateDatabase operation */
+extern "C" UINT __stdcall CreateDatabaseRollback(MSIHANDLE hInstall)
+{
+ HRESULT hr = S_OK;
+ UINT er = ERROR_SUCCESS;
+ wchar_t* service= 0;
+ wchar_t* dir= 0;
+ wchar_t data[2*MAX_PATH];
+ DWORD len= MAX_PATH;
+
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ ExitOnFailure(hr, "Failed to initialize");
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
+
+ MsiGetPropertyW(hInstall, L"CustomActionData", data, &len);
+
+ /* Property is encoded as [SERVICENAME]\[DBLOCATION] */
+ if(data[0] == L'\\')
+ {
+ dir= data+1;
+ }
+ else
+ {
+ service= data;
+ dir= wcschr(data, '\\');
+ if (dir)
+ {
+ *dir=0;
+ dir++;
+ }
+ }
+
+ if(service)
+ {
+ ExecRemoveService(service);
+ }
+ if(dir)
+ {
+ DumpErrorLog(dir);
+ ExecRemoveDataDirectory(dir);
+ }
+LExit:
+ return WcaFinalize(er);
+}
+
+
+/*
+ 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)
+{
+ HRESULT hr = S_OK;
+ UINT er = ERROR_SUCCESS;
+ wchar_t installerVersion[MAX_VERSION_PROPERTY_SIZE];
+ char installDir[MAX_PATH];
+ DWORD size =MAX_VERSION_PROPERTY_SIZE;
+ int installerMajorVersion, installerMinorVersion, installerPatchVersion;
+ bool upgradableServiceFound=false;
+ LPENUM_SERVICE_STATUS_PROCESSW info;
+ DWORD bufsize;
+ int index;
+ BOOL ok;
+ SC_HANDLE scm = NULL;
+
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
+ if (MsiGetPropertyW(hInstall, L"ProductVersion", installerVersion, &size)
+ != ERROR_SUCCESS)
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ ExitOnFailure(hr, "MsiGetPropertyW failed");
+ }
+ if (swscanf(installerVersion,L"%d.%d.%d",
+ &installerMajorVersion, &installerMinorVersion, &installerPatchVersion) !=3)
+ {
+ assert(FALSE);
+ }
+
+ size= MAX_PATH;
+ if (MsiGetPropertyA(hInstall,"INSTALLDIR", installDir, &size)
+ != ERROR_SUCCESS)
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ ExitOnFailure(hr, "MsiGetPropertyW failed");
+ }
+
+
+ scm = OpenSCManager(NULL, NULL,
+ SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_CONNECT);
+ if (scm == NULL)
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ ExitOnFailure(hr,"OpenSCManager failed");
+ }
+
+ static BYTE buf[64*1024];
+ static BYTE config_buffer[8*1024];
+
+ bufsize= sizeof(buf);
+ DWORD bufneed;
+ DWORD num_services;
+ ok= EnumServicesStatusExW(scm, SC_ENUM_PROCESS_INFO, SERVICE_WIN32,
+ SERVICE_STATE_ALL, buf, bufsize, &bufneed, &num_services, NULL, NULL);
+ if(!ok)
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ ExitOnFailure(hr,"EnumServicesStatusEx failed");
+ }
+ info =
+ (LPENUM_SERVICE_STATUS_PROCESSW)buf;
+ index=-1;
+ for (ULONG i=0; i < num_services; i++)
+ {
+ SC_HANDLE service= OpenServiceW(scm, info[i].lpServiceName,
+ SERVICE_QUERY_CONFIG);
+ if (!service)
+ continue;
+ QUERY_SERVICE_CONFIGW *config=
+ (QUERY_SERVICE_CONFIGW*)(void *)config_buffer;
+ DWORD needed;
+ ok= QueryServiceConfigW(service, config,sizeof(config_buffer),
+ &needed) && (config->dwStartType != SERVICE_DISABLED);
+ CloseServiceHandle(service);
+ if (ok)
+ {
+ 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.
+ */
+ if(installDir[0] == 0 || strstr(props.mysqld_exe,installDir) == 0)
+ {
+ 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_minor <= installerMinorVersion))
+ {
+ upgradableServiceFound= true;
+ break;
+ }
+ }
+ }
+ }
+
+ if(!upgradableServiceFound)
+ {
+ /* Disable optional checkbox at the end of installation */
+ MsiSetPropertyW(hInstall, L"WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT", L"");
+ MsiSetPropertyW(hInstall, L"WIXUI_EXITDIALOGOPTIONALCHECKBOX",L"");
+ }
+ else
+ {
+ MsiSetPropertyW(hInstall, L"UpgradableServiceFound", L"1");
+ MsiSetPropertyW(hInstall, L"WIXUI_EXITDIALOGOPTIONALCHECKBOX",L"1");
+ }
+LExit:
+ if(scm)
+ CloseServiceHandle(scm);
+ return WcaFinalize(er);
+}
+
+
+/* DllMain - Initialize and cleanup WiX custom action utils */
+extern "C" BOOL WINAPI DllMain(
+ __in HINSTANCE hInst,
+ __in ULONG ulReason,
+ __in LPVOID
+ )
+{
+ switch(ulReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ WcaGlobalInitialize(hInst);
+ break;
+
+ case DLL_PROCESS_DETACH:
+ WcaGlobalFinalize();
+ break;
+ }
+
+ return TRUE;
+}
+
diff --git a/win/packaging/ca/CustomAction.def b/win/packaging/ca/CustomAction.def
new file mode 100644
index 00000000..c18a0d92
--- /dev/null
+++ b/win/packaging/ca/CustomAction.def
@@ -0,0 +1,11 @@
+LIBRARY "wixca"
+VERSION 1.0
+EXPORTS
+PresetDatabaseProperties
+RemoveDataDirectory
+CreateDatabaseRollback
+CheckDatabaseProperties
+CheckDataDirectory
+CheckDBInUse
+CheckServiceUpgrades
+CheckInstallDirectory
diff --git a/win/packaging/ca/CustomAction.rc b/win/packaging/ca/CustomAction.rc
new file mode 100644
index 00000000..3f37126e
--- /dev/null
+++ b/win/packaging/ca/CustomAction.rc
@@ -0,0 +1,18 @@
+#include "afxres.h"
+#undef APSTUDIO_READONLY_SYMBOLS
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x0L
+ FILESUBTYPE 0x0L
+BEGIN
+END
+
diff --git a/win/packaging/create_msi.cmake b/win/packaging/create_msi.cmake
new file mode 100644
index 00000000..57262e10
--- /dev/null
+++ b/win/packaging/create_msi.cmake
@@ -0,0 +1,416 @@
+
+MACRO(MAKE_WIX_IDENTIFIER str varname)
+ STRING(REPLACE "/" "." ${varname} "${str}")
+ STRING(REGEX REPLACE "[^a-zA-Z_0-9.]" "_" ${varname} "${${varname}}")
+ STRING(LENGTH "${${varname}}" len)
+ # Identifier should be smaller than 72 character
+ # We have to cut down the length to 70 chars, since we add 2 char prefix
+ # pretty often
+ IF(len GREATER 70)
+ MATH(EXPR diff "${len}-67")
+ STRING(SUBSTRING "${${varname}}" ${diff} 67 shortstr)
+ SET(${varname} "___${shortstr}")
+ ENDIF()
+ENDMACRO()
+
+SET($ENV{VS_UNICODE_OUTPUT} "")
+
+FOREACH(third_party ${WITH_THIRD_PARTY})
+ INCLUDE(${SRCDIR}/${third_party}.cmake)
+
+ # Check than above script produced ${third_party}.wxi and ${third_party}_feature.wxi
+ FOREACH(outfile ${third_party}.wxi ${third_party}_feature.wxi)
+ IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${outfile})
+ MESSAGE(FATAL_ERROR
+ "${SRCDIR}/${third_party}.cmake did not produce "
+ "${CMAKE_CURRENT_BINARY_DIR}/${outfile}"
+ )
+ ENDIF()
+ ENDFOREACH()
+ENDFOREACH()
+
+
+SET(CANDLE_ARCH -arch ${Platform})
+IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ SET(Win64 " Win64='yes'")
+ SET(PlatformProgramFilesFolder ProgramFiles64Folder)
+ SET(CA_QUIET_EXEC CAQuietExec64)
+ELSE()
+ SET(PlatformProgramFilesFolder ProgramFilesFolder)
+ SET(CA_QUIET_EXEC CAQuietExec)
+ SET(Win64)
+ENDIF()
+
+SET(ENV{VS_UNICODE_OUTPUT})
+
+INCLUDE(${TOP_BINDIR}/CPackConfig.cmake)
+
+IF(CPACK_WIX_CONFIG)
+ INCLUDE(${CPACK_WIX_CONFIG})
+ENDIF()
+
+IF(NOT CPACK_WIX_UI)
+ SET(CPACK_WIX_UI "MyWixUI_Mondo")
+ENDIF()
+
+IF(CMAKE_INSTALL_CONFIG_NAME)
+ STRING(REPLACE "${CMAKE_CFG_INTDIR}" "${CMAKE_INSTALL_CONFIG_NAME}"
+ WIXCA_LOCATION "${WIXCA_LOCATION}")
+ SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_INSTALL_CONFIG_NAME}")
+ENDIF()
+
+SET(COMPONENTS_ALL "${CPACK_COMPONENTS_ALL}")
+FOREACH(comp ${COMPONENTS_ALL})
+ SET(ENV{DESTDIR} testinstall/${comp})
+ EXECUTE_PROCESS(
+ COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM} -DCMAKE_INSTALL_COMPONENT=${comp}
+ -DCMAKE_INSTALL_PREFIX= -P ${TOP_BINDIR}/cmake_install.cmake
+ OUTPUT_QUIET
+
+ )
+ # Exclude empty install components
+ SET(INCLUDE_THIS_COMPONENT 1)
+ SET(MANIFEST_FILENAME "${TOP_BINDIR}/install_manifest_${comp}.txt")
+ IF(EXISTS ${MANIFEST_FILENAME})
+ FILE(READ ${MANIFEST_FILENAME} content)
+ STRING(LENGTH "${content}" content_length)
+ IF (content_length EQUAL 0)
+ MESSAGE(STATUS "Excluding empty component ${comp}")
+ SET(INCLUDE_THIS_COMPONENT 0)
+ ENDIF()
+ ENDIF()
+ IF(NOT INCLUDE_THIS_COMPONENT)
+ LIST(REMOVE_ITEM CPACK_COMPONENTS_ALL "${comp}")
+ ELSE()
+ SET(DIRS ${DIRS} testinstall/${comp})
+ ENDIF()
+ENDFOREACH()
+
+SET(WIX_FEATURES)
+FOREACH(comp ${CPACK_COMPONENTS_ALL})
+ STRING(TOUPPER "${comp}" comp_upper)
+ IF(NOT CPACK_COMPONENT_${comp_upper}_GROUP)
+ SET(WIX_FEATURE_${comp_upper}_COMPONENTS "${comp}")
+ SET(CPACK_COMPONENT_${comp_upper}_HIDDEN 1)
+ SET(CPACK_COMPONENT_GROUP_${comp_upper}_DISPLAY_NAME
+ ${CPACK_COMPONENT_${comp_upper}_DISPLAY_NAME})
+ SET(CPACK_COMPONENT_GROUP_${comp_upper}_DESCRIPTION
+ ${CPACK_COMPONENT_${comp_upper}_DESCRIPTION})
+ SET(CPACK_COMPONENT_GROUP_${comp_upper}_WIX_LEVEL
+ ${CPACK_COMPONENT_${comp_upper}_WIX_LEVEL})
+ SET(WIX_FEATURES ${WIX_FEATURES} WIX_FEATURE_${comp_upper})
+ ELSE()
+ SET(FEATURE_NAME WIX_FEATURE_${CPACK_COMPONENT_${comp_upper}_GROUP})
+ SET(WIX_FEATURES ${WIX_FEATURES} ${FEATURE_NAME})
+ LIST(APPEND ${FEATURE_NAME}_COMPONENTS ${comp})
+ ENDIF()
+ENDFOREACH()
+
+IF(WIX_FEATURES)
+ LIST(REMOVE_DUPLICATES WIX_FEATURES)
+ENDIF()
+
+SET(CPACK_WIX_FEATURES)
+
+FOREACH(f ${WIX_FEATURES})
+ STRING(TOUPPER "${f}" f_upper)
+ STRING(REPLACE "WIX_FEATURE_" "" f_upper ${f_upper})
+ IF (CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)
+ SET(TITLE ${CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME})
+ ELSE()
+ SET(TITLE CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)
+ ENDIF()
+
+ IF (CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)
+ SET(DESCRIPTION ${CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION})
+ ELSE()
+ SET(DESCRIPTION CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)
+ ENDIF()
+ IF(CPACK_COMPONENT_${f_upper}_WIX_LEVEL)
+ SET(Level ${CPACK_COMPONENT_${f_upper}_WIX_LEVEL})
+ ELSE()
+ SET(Level 1)
+ ENDIF()
+ IF(CPACK_COMPONENT_GROUP_${f_upper}_HIDDEN)
+ SET(DISPLAY "Display='hidden'")
+ SET(TITLE ${f_upper})
+ SET(DESCRIPTION ${f_upper})
+ ELSE()
+ SET(DISPLAY)
+ IF(CPACK_COMPONENT_GROUP_${f_upper}_EXPANDED)
+ SET(DISPLAY "Display='expand'")
+ ENDIF()
+ IF (CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)
+ SET(TITLE ${CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME})
+ ELSE()
+ SET(TITLE CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)
+ ENDIF()
+ IF (CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)
+ SET(DESCRIPTION ${CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION})
+ ELSE()
+ SET(DESCRIPTION CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)
+ ENDIF()
+ ENDIF()
+
+ SET(CPACK_WIX_FEATURES
+ "${CPACK_WIX_FEATURES}
+ <Feature Id='${f_upper}'
+ Title='${TITLE}'
+ Description='${DESCRIPTION}'
+ ConfigurableDirectory='INSTALLDIR'
+ AllowAdvertise='no'
+ Level='${Level}' ${DISPLAY} >"
+ )
+ FOREACH(c ${${f}_COMPONENTS})
+
+ STRING(TOUPPER "${c}" c_upper)
+ IF (CPACK_COMPONENT_${c_upper}_DISPLAY_NAME)
+ SET(TITLE ${CPACK_COMPONENT_${c_upper}_DISPLAY_NAME})
+ ELSE()
+ SET(TITLE CPACK_COMPONENT_${c_upper}_DISPLAY_NAME)
+ ENDIF()
+
+ IF (CPACK_COMPONENT_${c_upper}_DESCRIPTION)
+ SET(DESCRIPTION ${CPACK_COMPONENT_${c_upper}_DESCRIPTION})
+ ELSE()
+ SET(DESCRIPTION CPACK_COMPONENT_${c_upper}_DESCRIPTION)
+ ENDIF()
+ IF(CPACK_COMPONENT_${c_upper}_WIX_LEVEL)
+ SET(Level ${CPACK_COMPONENT_${c_upper}_WIX_LEVEL})
+ ELSE()
+ SET(Level 1)
+ ENDIF()
+ MAKE_WIX_IDENTIFIER("${c}" cg)
+
+ IF(CPACK_COMPONENT_${c_upper}_HIDDEN)
+ SET(CPACK_WIX_FEATURES
+ "${CPACK_WIX_FEATURES}
+ <ComponentGroupRef Id='componentgroup.${cg}'/>")
+ ELSE()
+ SET(CPACK_WIX_FEATURES
+ "${CPACK_WIX_FEATURES}
+ <Feature Id='${c}'
+ Title='${TITLE}'
+ Description='${DESCRIPTION}'
+ ConfigurableDirectory='INSTALLDIR'
+ AllowAdvertise='no'
+ Level='${Level}'>
+ <ComponentGroupRef Id='componentgroup.${cg}'/>
+ </Feature>")
+ ENDIF()
+
+ ENDFOREACH()
+ IF(${f}_EXTRA_FEATURES)
+ FOREACH(extra_feature ${${f}_EXTRA_FEATURES})
+ SET(CPACK_WIX_FEATURES
+ "${CPACK_WIX_FEATURES}
+ <FeatureRef Id='${extra_feature}' />
+ ")
+ ENDFOREACH()
+ ENDIF()
+ SET(CPACK_WIX_FEATURES
+ "${CPACK_WIX_FEATURES}
+ </Feature>
+ ")
+ENDFOREACH()
+
+
+
+MACRO(GENERATE_GUID VarName)
+ EXECUTE_PROCESS(COMMAND uuidgen -c
+ OUTPUT_VARIABLE ${VarName}
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ENDMACRO()
+
+
+FUNCTION(TRAVERSE_FILES dir topdir file file_comp dir_root)
+ FILE(GLOB all_files ${dir}/*)
+ IF(NOT all_files)
+ RETURN()
+ ENDIF()
+ FILE(RELATIVE_PATH dir_rel ${topdir} ${dir})
+ IF(dir_rel)
+ MAKE_DIRECTORY(${dir_root}/${dir_rel})
+ MAKE_WIX_IDENTIFIER("${dir_rel}" id)
+ SET(DirectoryRefId "D.${id}")
+ ELSE()
+ SET(DirectoryRefId "INSTALLDIR")
+ ENDIF()
+ FILE(APPEND ${file} "<DirectoryRef Id='${DirectoryRefId}'>\n")
+
+ SET(NONEXEFILES)
+ FOREACH(v MAJOR_VERSION MINOR_VERSION PATCH_VERSION TINY_VERSION)
+ IF(NOT DEFINED ${v})
+ MESSAGE(FATAL_ERROR "${v} is not defined")
+ ENDIF()
+ ENDFOREACH()
+ SET(default_version "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}.${TINY_VERSION}")
+
+ FOREACH(f ${all_files})
+ IF(NOT IS_DIRECTORY ${f})
+ FILE(RELATIVE_PATH rel ${topdir} ${f})
+ MAKE_WIX_IDENTIFIER("${rel}" id)
+ FILE(TO_NATIVE_PATH ${f} f_native)
+ GET_FILENAME_COMPONENT(f_ext "${f}" EXT)
+ GET_FILENAME_COMPONENT(name "${f}" NAME)
+
+ IF(name STREQUAL ".empty")
+ # Create an empty directory
+ GENERATE_GUID(guid)
+ FILE(APPEND ${file} " <Component Id='C.${id}' Guid='${guid}' ${Win64}> <CreateFolder/> </Component>\n")
+ FILE(APPEND ${file_comp} "<ComponentRef Id='C.${id}'/>\n")
+ ELSEIF(NOT ${file}.COMPONENT_EXCLUDE)
+ FILE(APPEND ${file} " <Component Id='C.${id}' Guid='*' ${Win64} >\n")
+ IF(${id}.COMPONENT_CONDITION)
+ FILE(APPEND ${file} " <Condition>${${id}.COMPONENT_CONDITION}</Condition>\n")
+ ENDIF()
+ FILE(APPEND ${file} " <File Id='F.${id}' KeyPath='yes' Source='${f_native}'")
+ FILE(APPEND ${file} " DefaultVersion='${default_version}' DefaultLanguage='1033'")
+ IF(${id}.FILE_EXTRA)
+ FILE(APPEND ${file} ">\n${${id}.FILE_EXTRA}</File>")
+ ELSE()
+ FILE(APPEND ${file} "/>\n")
+ ENDIF()
+ FILE(APPEND ${file} " </Component>\n")
+ FILE(APPEND ${file_comp} " <ComponentRef Id='C.${id}'/>\n")
+ ENDIF()
+ ENDIF()
+ ENDFOREACH()
+ FILE(APPEND ${file} "</DirectoryRef>\n")
+ IF(NONEXEFILES)
+ GENERATE_GUID(guid)
+ SET(ComponentId "C._files_${COMP_NAME}.${DirectoryRefId}")
+ MAKE_WIX_IDENTIFIER("${ComponentId}" ComponentId)
+ FILE(APPEND ${file}
+ "<DirectoryRef Id='${DirectoryRefId}'>\n<Component Guid='${guid}'
+ Id='${ComponentId}' ${Win64}>${NONEXEFILES}\n</Component></DirectoryRef>\n")
+ FILE(APPEND ${file_comp} " <ComponentRef Id='${ComponentId}'/>\n")
+ ENDIF()
+ FOREACH(f ${all_files})
+ IF(IS_DIRECTORY ${f})
+ TRAVERSE_FILES(${f} ${topdir} ${file} ${file_comp} ${dir_root})
+ ENDIF()
+ ENDFOREACH()
+ENDFUNCTION()
+
+FUNCTION(TRAVERSE_DIRECTORIES dir topdir file prefix)
+ FILE(RELATIVE_PATH rel ${topdir} ${dir})
+ IF(rel)
+ IF (IS_DIRECTORY "${f}")
+ MAKE_WIX_IDENTIFIER("${rel}" id)
+ GET_FILENAME_COMPONENT(name ${dir} NAME)
+ FILE(APPEND ${file} "${prefix}<Directory Id='D.${id}' Name='${name}'>\n")
+ ENDIF()
+ ENDIF()
+ FILE(GLOB all_files ${dir}/*)
+ FOREACH(f ${all_files})
+ IF(IS_DIRECTORY ${f})
+ TRAVERSE_DIRECTORIES(${f} ${topdir} ${file} "${prefix} ")
+ ENDIF()
+ ENDFOREACH()
+ IF(rel)
+ IF(IS_DIRECTORY "${f}")
+ FILE(APPEND ${file} "${prefix}</Directory>\n")
+ ENDIF()
+ ENDIF()
+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}'>")
+ SET(COMP_NAME ${d_name})
+ TRAVERSE_FILES(${d} ${d} ${abs}/${d_name}.wxs
+ ${abs}/${d_name}_component_group.wxs "${abs}/dirs")
+ FILE(APPEND ${abs}/${d_name}_component_group.wxs "</ComponentGroup>")
+ IF(EXISTS ${d_name}.wxs)
+ FILE(READ ${d_name}.wxs WIX_TMP)
+ SET(CPACK_WIX_COMPONENTS "${CPACK_WIX_COMPONENTS}\n${WIX_TMP}")
+ FILE(REMOVE ${d_name}.wxs)
+ ENDIF()
+
+ FILE(READ ${d_name}_component_group.wxs WIX_TMP)
+
+ SET(CPACK_WIX_COMPONENT_GROUPS "${CPACK_WIX_COMPONENT_GROUPS}\n${WIX_TMP}")
+ FILE(REMOVE ${d_name}_component_group.wxs)
+ENDFOREACH()
+
+FILE(WRITE directories.wxs "<DirectoryRef Id='INSTALLDIR'>\n")
+TRAVERSE_DIRECTORIES(${abs}/dirs ${abs}/dirs directories.wxs "")
+FILE(APPEND directories.wxs "</DirectoryRef>\n")
+
+FILE(READ directories.wxs CPACK_WIX_DIRECTORIES)
+FILE(REMOVE directories.wxs)
+
+
+FOREACH(src ${CPACK_WIX_INCLUDE})
+SET(CPACK_WIX_INCLUDES
+"${CPACK_WIX_INCLUDES}
+ <?include ${src}?>"
+)
+ENDFOREACH()
+
+
+CONFIGURE_FILE(${SRCDIR}/mysql_server.wxs.in
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql_server.wxs)
+CONFIGURE_FILE(${SRCDIR}/extra.wxs.in
+ ${CMAKE_CURRENT_BINARY_DIR}/extra.wxs)
+
+SET(EXTRA_CANDLE_ARGS "$ENV{EXTRA_CANDLE_ARGS}")
+
+SET(EXTRA_LIGHT_ARGS -cc . -reusecab)
+IF("$ENV{EXTRA_LIGHT_ARGS}")
+ SET(EXTRA_LIGHT_ARGS "$ENV{EXTRA_LIGHT_ARGS}")
+ENDIF()
+
+FILE(REMOVE mysql_server.wixobj extra.wixobj)
+STRING(REPLACE " " ";" EXTRA_WIX_PREPROCESSOR_FLAGS_LIST ${EXTRA_WIX_PREPROCESSOR_FLAGS})
+EXECUTE_PROCESS(
+ COMMAND ${CANDLE_EXECUTABLE}
+ ${EXTRA_WIX_PREPROCESSOR_FLAGS_LIST}
+ ${CANDLE_ARCH}
+ -ext WixUtilExtension
+ -ext WixFirewallExtension
+ mysql_server.wxs
+ ${EXTRA_CANDLE_ARGS}
+)
+
+EXECUTE_PROCESS(
+ COMMAND ${CANDLE_EXECUTABLE} ${CANDLE_ARCH}
+ ${EXTRA_WIX_PREPROCESSOR_FLAGS_LIST}
+ -ext WixUtilExtension
+ -ext WixFirewallExtension
+ ${CMAKE_CURRENT_BINARY_DIR}/extra.wxs
+ ${EXTRA_CANDLE_ARGS}
+)
+
+IF(VCRedist_MSM)
+ SET(SILENCE_VCREDIST_MSM_WARNINGS -sice:ICE82 -sice:ICE03)
+ENDIF()
+
+EXECUTE_PROCESS(
+ COMMAND ${LIGHT_EXECUTABLE} -v -ext WixUIExtension -ext WixUtilExtension
+ -ext WixFirewallExtension -sice:ICE61 -sw1103 ${SILENCE_VCREDIST_MSM_WARNINGS}
+ mysql_server.wixobj extra.wixobj -out ${CPACK_PACKAGE_FILE_NAME}.msi
+ ${EXTRA_LIGHT_ARGS}
+)
+
+IF(SIGNCODE)
+ SEPARATE_ARGUMENTS(SIGNTOOL_PARAMETERS WINDOWS_COMMAND "${SIGNTOOL_PARAMETERS}")
+ EXECUTE_PROCESS(
+ COMMAND ${SIGNTOOL_EXECUTABLE} sign ${SIGNTOOL_PARAMETERS}
+ /d ${CPACK_PACKAGE_FILE_NAME}.msi
+ ${CPACK_PACKAGE_FILE_NAME}.msi
+)
+ENDIF()
+CONFIGURE_FILE(${CPACK_PACKAGE_FILE_NAME}.msi
+ ${TOP_BINDIR}/${CPACK_PACKAGE_FILE_NAME}.msi
+ COPYONLY)
+
diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in
new file mode 100644
index 00000000..056a7ec4
--- /dev/null
+++ b/win/packaging/extra.wxs.in
@@ -0,0 +1,839 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
+ <Fragment>
+ <!--
+ Check, if upgrade wizard was built
+ It currently requires MFC, which is not in SDK
+ neither in express edítions of VS.
+ -->
+ <?ifndef HaveUpgradeWizard ?>
+ <?define HaveUpgradeWizard="1"?>
+ <?endif?>
+
+ <!-- If Innodb is compiled in, enable "optimize for transactions" checkbox -->
+ <?ifndef HaveInnodb ?>
+ <?define HaveInnodb="1"?>
+ <?endif?>
+
+ <Property Id="PortTemplate" Value="#####" />
+ <?if $(var.HaveInnodb) = "1" ?>
+ <Property Id="BufferPoolSizeTemplate" Value="#######" />
+ <?endif?>
+ <!--
+ Installation parameters that can be passed via msiexec command line
+ For "booleans" (like skip networking), just providing any value means property set to "yes".
+ -->
+ <!-- instalation directory (default under program files)-->
+ <!--- (defined elsewhere) <Property Id="INSTALLDIR" Secure="yes" /> -->
+
+ <!-- Database data directory (default under INSTALLDIR\data) -->
+ <!--- (defined elsewhere) <Property Id="DATADIR" Secure="yes"/> -->
+
+ <!-- Service name of database instanced (default MySQL in GUI, nothing with command line) -->
+ <!-- (defined elsewhere) <Property Id="SERVICENAME" Secure="yes" /> -->
+
+ <!-- Root password -->
+ <Property Id="PASSWORD" Hidden="yes" Secure="yes" />
+ <Property Id="ESCAPEDPASSWORD" Hidden="yes" Secure="yes" />
+ <!-- Database port -->
+ <Property Id="PORT" Value="3306" Secure="yes"/>
+ <!-- Whether to allow remote access for root user -->
+ <Property Id="ALLOWREMOTEROOTACCESS" Secure="yes" />
+ <!-- Skip networking. This will switch configuration to use named pipe-->
+ <Property Id="SKIPNETWORKING" Secure="yes"/>
+ <!-- Whether to keep default (unauthenticated) user. Default is no-->
+ <Property Id="DEFAULTUSER" Secure="yes"/>
+ <!-- Set server character set to UTF8 -->
+ <Property Id="UTF8" Secure="yes"/>
+ <!-- Whether to data on uninstall (default yes, after asking user consent) -->
+ <Property Id="CLEANUPDATA" Secure="yes" Value="1"/>
+ <!-- Force per machine installation -->
+ <Property Id="ALLUSERS" Secure="yes" Value="1"/>
+ <!-- Disable advertised shortcuts weirdness -->
+ <Property Id="DISABLEADVTSHORTCUTS" Secure="yes" Value="1"/>
+
+ <!-- Quick configuration : set default storage engine to innodb, use strict sql_mode -->
+ <Property Id="STDCONFIG" Secure="yes" Value="1"/>
+
+ <!-- Innodb Buffer pool size in MB-->
+ <Property Id="BUFFERPOOLSIZE" Secure="yes"/>
+ <!-- Innodb page size -->
+ <Property Id="PAGESIZE" Secure="yes" Value="16K"/>
+
+ <CustomAction Id="LaunchUrl" BinaryKey="WixCA" DllEntry="WixShellExec" Execute="immediate" Return="check" Impersonate="yes" />
+
+
+
+ <!--
+ User interface dialogs
+ -->
+ <WixVariable Id='WixUIBannerBmp' Value='@SRCDIR@\WixUIBannerBmp.jpg' />
+ <WixVariable Id='WixUIDialogBmp' Value='@SRCDIR@\WixUIDialogBmp.jpg' />
+ <UI>
+
+ <!-- Dialog on uninstall of the database -->
+ <Dialog Id="ConfirmDataCleanupDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
+
+ <!--<Control Id="CleanupDataCheckBox" Type="CheckBox" X="20" Y="100" Height="30" Property="CLEANUPDATA" Width="300" CheckBoxValue="1"
+ Text="{\Font1}Remove default database directory &#xD;&#xA;'[DATADIR]'"/>
+ -->
+ <Control Id="RemoveDatadirButton" Type="PushButton" X="40" Y="65" Width="80" Height="18"
+ Text="Remove data">
+ <Publish Property="CLEANUPDATA" Value="1">1</Publish>
+ <Publish Event="NewDialog" Value="VerifyReadyDlg">WixUI_InstallMode</Publish>
+ <Publish Event="EndDialog" Value="Return">NOT WixUI_InstallMode</Publish>
+
+ </Control>
+ <Control Id="RemoveDatadirText" Type="Text" X="60" Y="85" Width="280" Height="30">
+ <Text>Remove [DATADIR]. Ensures proper cleanup on uninstall.</Text>
+ </Control>
+
+ <Control Id="KeepDatadirButton" Type="PushButton" X="40" Y="128" Width="80" Height="18"
+ Text="Keep data">
+ <Publish Property="CLEANUPDATA">1</Publish>
+ <Publish Event="NewDialog" Value="VerifyReadyDlg">WixUI_InstallMode</Publish>
+ <Publish Event="EndDialog" Value="Return">NOT WixUI_InstallMode</Publish>
+ </Control>
+ <Control Id="KeepDataDirText" Type="Text" X="60" Y="148" Width="280" Height="70" >
+ <Text>Do not remove [DATADIR]. Choose this option if you intend to use data in the future</Text>
+ </Control>
+
+
+ <!-- Navigation buttons-->
+ <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
+ <Publish Event="NewDialog" Value="CustomizeDlg">WixUI_InstallMode="Change"</Publish>
+ <Condition Action="disable">NOT WixUI_InstallMode</Condition>
+ </Control>
+ <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Disabled="yes" Text="&amp;Next">
+ <Publish Event="NewDialog" Value="VerifyReadyDlg">WixUI_InstallMode</Publish>
+ <Publish Event="EndDialog" Value="Return">NOT WixUI_InstallMode</Publish>
+ </Control>
+ <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
+ <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
+ </Control>
+ <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
+ <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
+ <Text>Remove default [ProductName] database</Text>
+ </Control>
+ <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
+ <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
+ <Text>{\WixUI_Font_Title}Default instance properties</Text>
+ </Control>
+ <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
+ </Dialog>
+
+ <!-- Dialog new or upgrade instance -->
+
+ <Property Id="CreateOrUpgradeChoice" Value="Create"/>
+
+ <Dialog Id="NewOrUpgradeInstanceDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
+ <Control Id="Text" Type="Text" X="40" Y="65" Width="270" Height="30">
+ <Text>Setup found existing database instances that can be upgraded to [ProductName].You can create a new instance and/or upgrade existing one.
+ </Text>
+ </Control>
+
+ <Control Id="CreateOrUpgradeButton"
+ Type="RadioButtonGroup" X="40" Y="100" Width="300" Height="70"
+ Property="CreateOrUpgradeChoice" Text="Specify what to do">
+ <RadioButtonGroup Property="CreateOrUpgradeChoice">
+ <RadioButton Value="Create" X="0" Y="0" Width="300" Height="25"
+ Text="{\Font1}Create new database instance."/>
+ <RadioButton Value="Upgrade" X="0" Y="30" Width="300" Height="25"
+ Text="{\Font1}Do not create a new database. Optionally upgrade existing instances." />
+ </RadioButtonGroup>
+ </Control>
+
+ <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
+ <Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
+ </Control>
+ <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Text="&amp;Next">
+ <Publish Event="Remove" Value="DBInstance">CreateOrUpgradeChoice = "Upgrade" </Publish>
+ <Publish Event="AddLocal" Value="DBInstance">CreateOrUpgradeChoice = "Create"</Publish>
+ <Publish Property="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="[NonExistentProperty]">CreateOrUpgradeChoice = "Create"</Publish>
+ <Publish Property="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="[NonExistentProperty]">CreateOrUpgradeChoice = "Create"</Publish>
+ <Publish Property="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1">CreateOrUpgradeChoice = "Upgrade"</Publish>
+ <Publish Event="NewDialog" Value="CustomizeDlg">1</Publish>
+ </Control>
+ <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
+ <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
+ </Control>
+ <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
+ <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
+ <Text>Create or upgrade database instance</Text>
+ </Control>
+ <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
+ <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
+ <Text>{\WixUI_Font_Title}[ProductName] setup</Text>
+ </Control>
+ <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
+ </Dialog>
+
+ <!-- Error popup dialog -->
+ <Dialog Id="WarningDlg" Width="320" Height="85" Title="[ProductName] Setup" NoMinimize="yes">
+ <Control Id="Icon" Type="Icon" X="15" Y="15" Width="24" Height="24"
+ ToolTip="Information icon" FixedSize="yes" IconSize="32" Text="WixUI_Ico_Info" />
+ <Control Id="Ok" Type="PushButton" X="132" Y="57" Width="56" Height="17"
+ Default="yes" Cancel="yes" Text="OK">
+ <Publish Property="WarningText">1</Publish>
+ <Publish Event="EndDialog" Value="Return">1</Publish>
+ </Control>
+ <Control Id="Text" Type="Text" X="48" Y="15" Width="260" Height="30">
+ <Text>[WarningText]</Text>
+ </Control>
+ </Dialog>
+
+
+ <Property Id="ModifyRootPassword" Value="1"/>
+ <TextStyle Id="Font1" FaceName="Tahoma" Size="8" Red="0" Green="0" Blue="0" Bold="yes" />
+
+ <!-- Root password plus default user dialog -->
+ <Dialog Id="UserSettingsDlg" X="50" Y="50" Width="370" Height="270" Title="User settings">
+ <Control Id="EditRootPassword" Type="Edit" X="104" Y="82" Width="91" Height="15" Property="PASSWORD" Password="yes" TabSkip="no">
+ <Text>{100}</Text>
+ <Condition Action="enable">ModifyRootPassword</Condition>
+ <Condition Action="disable">NOT ModifyRootPassword</Condition>
+ </Control>
+ <Control Id="EditRootPasswordConfirm" Type="Edit" X="104" Y="103" Width="91" Height="15" Property="RootPasswordConfirm" Password="yes" TabSkip="no">
+ <Text>{100}</Text>
+ <Condition Action="enable">ModifyRootPassword</Condition>
+ <Condition Action="disable">NOT ModifyRootPassword</Condition>
+ </Control>
+
+ <Control Id="CheckBoxModifyRootPassword" Type="CheckBox" X="8" Y="62" Width="222" Height="18" Property="ModifyRootPassword" CheckBoxValue="1" TabSkip="no">
+ <Text>{\Font1}Modify password for database user 'root'</Text>
+ <Publish Property="PASSWORD" >NOT ModifyRootPassword</Publish>
+ <Publish Property="RootPasswordConfirm">NOT ModifyRootPassword</Publish>
+ <Publish Property="ALLOWREMOTEROOTACCESS">NOT ModifyRootPassword</Publish>
+ <Publish Property="ALLOWREMOTEROOTACCESS" Value="1">ModifyRootPassword</Publish>
+ </Control>
+
+ <Control Id="Text5" Type="Text" X="23" Y="82" Width="77" Height="14" TabSkip="yes">
+ <Text>New root password:</Text>
+ </Control>
+ <Control Id="Text6" Type="Text" X="201" Y="85" Width="100" Height="17" TabSkip="yes">
+ <Text>Enter new root password</Text>
+ </Control>
+ <Control Id="Text8" Type="Text" X="23" Y="105" Width="75" Height="17" TabSkip="yes">
+ <Text>Confirm:</Text>
+ </Control>
+
+ <Control Id="Text10" Type="Text" X="201" Y="104" Width="100" Height="17" TabSkip="yes">
+ <Text>Retype the password</Text>
+ </Control>
+ <Control Id="CheckBoxALLOWREMOTEROOTACCESS" Type="CheckBox" X="23" Y="122" Width="196" Height="18" Property="ALLOWREMOTEROOTACCESS"
+ CheckBoxValue="--allow-remote-root-access" TabSkip="no">
+ <Text>{\Font1}Enable access from remote machines for 'root' user</Text>
+ <Condition Action="enable">ModifyRootPassword</Condition>
+ <Condition Action="disable">NOT ModifyRootPassword</Condition>
+ </Control>
+
+ <Control Id="CheckBoxUTF8" Type="CheckBox" X="8" Y="154" Width="250" Height="18" Property="UTF8" CheckBoxValue="1" TabSkip="no">
+ <Text>{\Font1}Use UTF8 as default server's character set</Text>
+ </Control>
+ <Control Type="Text" Id="Text11" Width="67" Height="17" X="8" Y="190" Text="{\Font1}Data directory" />
+ <Control Type="PathEdit" Id="TxtDir" Width="175" Height="18" X="80" Y="190" Property="DATADIR">
+ </Control>
+ <Control Id="btnDirBrowse" Type="PushButton" Width="56" Height="17" X="278" Y="190" Text="Browse...">
+ <Publish Property="_BrowseProperty" Value="DATADIR" Order="1">1</Publish>
+ <Publish Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
+ </Control>
+ <!-- Navigation buttons-->
+ <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
+ <Publish Event="NewDialog" Value="CustomizeDlg">1</Publish>
+ </Control>
+ <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
+ <Publish Event="DoAction" Value="CheckDataDirectory">1</Publish>
+ <Publish Property="WarningText" Value="Invalid data directory, choose a different one. Error: [DATADIRERROR]">
+ DATADIRERROR
+ </Publish>
+ <Publish Property="WarningText" Value="Passwords do not match."><![CDATA[PASSWORD <> RootPasswordConfirm]]></Publish>
+ <Publish Event="SpawnDialog" Value="WarningDlg"><![CDATA[WarningText <>""]]></Publish>
+ <Publish Property="SERVICENAME" Value="MariaDB">NOT SERVICENAME AND NOT WarningText</Publish>
+ <Publish Event="NewDialog" Value="ServicePortDlg"><![CDATA[WarningText=""]]></Publish>
+ <Condition Action="enable"><![CDATA[NOT ModifyRootPassword OR PASSWORD]]> </Condition>
+ <Condition Action="disable"><![CDATA[ModifyRootPassword AND (NOT PASSWORD)]]> </Condition>
+ </Control>
+ <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
+ <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
+ </Control>
+ <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
+ <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
+ <Text> [ProductName] database configuration</Text>
+ </Control>
+ <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
+ <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
+ <Text>{\WixUI_Font_Title}Default instance properties</Text>
+ </Control>
+ <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
+ </Dialog>
+
+ <Property Id="InstallService" Value="1"/>
+ <Property Id="EnableNetworking" Value="1"/>
+
+ <!-- Service and port configuration -->
+ <Dialog Id="ServicePortDlg" Width="370" Height="270" Title="Database settings">
+ <Control Id="InstallAsService" Type="CheckBox" X="9" Y="61" Width="222" Height="19" Property="InstallService" CheckBoxValue="1" TabSkip="no">
+ <Text>{\Font1}Install as service</Text>
+ </Control>
+ <Control Id="EditServiceName" Type="Edit" X="104" Y="82" Width="91" Height="15" Property="SERVICENAME" TabSkip="no">
+ <Text>{20}</Text>
+ <Condition Action="enable">InstallService</Condition>
+ <Condition Action="disable">Not InstallService</Condition>
+ </Control>
+ <Control Id="Text5" Type="Text" X="25" Y="82" Width="77" Height="14" TabSkip="yes">
+ <Text>Service Name:</Text>
+ </Control>
+ <Control Id="CheckBoxEnableNetworking" Type="CheckBox" Height="18" Width="102" X="9" Y="117" Property="EnableNetworking" CheckBoxValue="1">
+ <Text>{\Font1}Enable networking</Text>
+ <!--<Publish Property="PORT">NOT EnableNetworking</Publish>-->
+ <Publish Property="SKIPNETWORKING" Value="--skip-networking">NOT EnableNetworking</Publish>
+ <Publish Property="SKIPNETWORKING">EnableNetworking</Publish>
+ </Control>
+ <Control Id="LabelTCPPort" Type="Text" Height="17" Width="75" X="25" Y="142" Text="TCP port:" />
+ <Control Id="Port" Type="MaskedEdit" X="104" Y="140" Width="28" Height="15" Property="PORT" Sunken="yes" Text="[PortTemplate]">
+ <Condition Action="enable" >EnableNetworking</Condition>
+ <Condition Action="disable">Not EnableNetworking</Condition>
+ </Control>
+
+ <Control Id="LabelInnodbSettings" Type="Text" Height="18" Width="220" X="25" Y="171" >
+ <Text>{\Font1}Innodb engine settings</Text>
+ </Control>
+ <Control Id="LabelInnodbBufferpool" Type="Text" Height="17" Width="77" X="25" Y="190" Text="Buffer pool size:" />
+ <Control Id="BPSize" Type="MaskedEdit" X="104" Y="188" Width="40" Height="15" Property="BUFFERPOOLSIZE" Sunken="yes" Text="[BufferPoolSizeTemplate]"/>
+ <Control Id="LabelMB" Type="Text" Height="17" Width="15" X="150" Y="190" Text="MB" />
+ <Control Id="LabelInnodbPageSize" Type="Text" Height="17" Width="77" X="25" Y="208" Text="Page size:" />
+ <Control Id="LabelKB" Type="Text" Height="17" Width="15" X="150" Y="210" Text="KB" />
+ <Control Id="ComboBoxInnodbPageSize" Type="ComboBox" X="104" Y="208" Width="30" Height="17" ComboList="yes" Sorted="yes" Property="PAGESIZE" >
+ <ComboBox Property="PAGESIZE">
+ <ListItem Text=" 4" Value="4K"/>
+ <ListItem Text=" 8" Value="8K"/>
+ <ListItem Text="16" Value="16K"/>
+ <ListItem Text="32" Value="32K"/>
+ <ListItem Text="64" Value="64K"/>
+ </ComboBox>
+ </Control>
+
+ <!-- Navigation buttons-->
+ <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
+ <Publish Event="NewDialog" Value="UserSettingsDlg">1</Publish>
+ </Control>
+ <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="no" Text="&amp;Next">
+ <Publish Property="SERVICENAME">NOT InstallService</Publish>
+ <Publish Property="WarningText" Value="Please enter valid port or uncheck 'Enable Networking' checkbox">
+ <![CDATA[EnableNetworking AND NOT PORT AND NOT WarningText]]>
+ </Publish>
+ <Publish Property="WarningText" Value="Please enter valid service name port or uncheck 'Install Service' checkbox">
+ <![CDATA[InstallService AND NOT SERVICENAME AND NOT WarningText]]>
+ </Publish>
+ <Publish Event="DoAction" Value="CheckDatabaseProperties">NOT WarningText</Publish>
+ <Publish Event="SpawnDialog" Value="WarningDlg">WarningText</Publish>
+ <Publish Event="NewDialog" Value="VerifyReadyDlg">Not WarningText</Publish>
+ </Control>
+ <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="no" Text="Cancel">
+ <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
+ </Control>
+ <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
+ <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
+ <Text>[ProductName] database configuration</Text>
+ </Control>
+ <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="2" />
+ <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
+ <Text>{\WixUI_Font_Title}Default instance properties</Text>
+ </Control>
+ <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="2" />
+ </Dialog>
+ </UI>
+
+ <Property Id="CRLF" Value="&#xD;&#xA;" />
+ <CustomAction Id="CheckDataDirectory" BinaryKey="wixca.dll" DllEntry="CheckDataDirectory" Execute="immediate" Impersonate="yes"/>
+ <CustomAction Id="CheckInstallDirectory" BinaryKey="wixca.dll" DllEntry="CheckInstallDirectory" Execute="immediate" Impersonate="yes"/>
+ <!-- What to do when navigation buttons are clicked -->
+ <UI Id="MyWixUI_Mondo">
+ <UIRef Id="WixUI_FeatureTree" />
+ <UIRef Id="WixUI_ErrorProgressText" />
+ <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="999">
+ OLDERVERSIONBEINGUPGRADED
+ </Publish>
+ <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="NewOrUpgradeInstanceDlg" Order="999">
+ NOT Installed AND UpgradableServiceFound
+ </Publish>
+
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ServicePortDlg" Order="3" ><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3"> <![CDATA[OLDERVERSIONBEINGUPGRADED <>""]]></Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="1" ><![CDATA[(&DBInstance=2) AND (!DBInstance=3)]]></Publish>
+
+
+ <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="NewOrUpgradeInstanceDlg" Order="999">
+ NOT Installed AND UpgradableServiceFound
+ </Publish>
+ <Publish Dialog="CustomizeDlg" Control="Next" Event="DoAction" Value="CheckInstallDirectory" Order="1">NOT Installed</Publish>
+ <Publish Dialog="CustomizeDlg" Control="Next" Property="WarningText" Order="2"
+ Value="[INSTALLDIRERROR]">
+ INSTALLDIRERROR
+ </Publish>
+ <Publish Dialog="CustomizeDlg" Control="Next" Event="SpawnDialog" Value="WarningDlg" Order="3">WarningText</Publish>
+ <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="4">
+ <![CDATA[(&DBInstance=2) AND (!DBInstance=3)]]>
+ </Publish>
+ <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="UserSettingsDlg" Order="5">
+ <![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND NOT WarningText]]>
+ </Publish>
+
+ <Publish Dialog="ConfirmDataCleanupDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg">WixUI_InstallMode = "Change"</Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="999">
+ !DBInstance=3 AND (CLEANUPDATA Or USECONFIRMDATACLEANUPDLG)
+ </Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Property="USECONFIRMDATACLEANUPDLG" Value="1" Order="999">
+ !DBInstance=3 AND CLEANUPDATA
+ </Publish>
+ <Publish Dialog="ConfirmDataCleanupDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg">WixUI_InstallMode = "Remove"</Publish>
+ </UI>
+
+ <!-- End of UI section -->
+
+ <!-- Extra folders we need (DATADIR and shortcut folder) -->
+ <DirectoryRef Id='INSTALLDIR'>
+ <Directory Id="DATADIR" Name="data">
+ </Directory>
+ <Directory Id="ProgramMenuFolder">
+ <Directory Id="ShortcutFolder" Name="@CPACK_WIX_PACKAGE_NAME@">
+ </Directory>
+ </Directory>
+ </DirectoryRef>
+
+
+ <!-- Extra feature (database instance). This could be split to several subfeatures if desired (e.g firewall exception)-->
+ <Feature Id='DBInstance'
+ Title='Database instance'
+ Description=
+ 'Install database instance. Only new database can be installed with this feature.'
+ ConfigurableDirectory='DATADIR'
+ AllowAdvertise='no'
+ Level='1'>
+
+ <!-- Data directory with some reasonable security settings -->
+ <Component Id="C.datadir" Guid="*" Directory="DATADIR">
+ <RegistryValue Root='HKLM'
+ Key='SOFTWARE\@CPACK_WIX_PACKAGE_NAME@'
+ Name='DATADIR' Value='[DATADIR]' Type='string' KeyPath='yes'/>
+ </Component>
+
+ <Component Id="C.datadir.permissions" Directory="DATADIR">
+ <Condition>
+ <!--
+ Skip setting permissions for LogonUser, if package is installed by
+ service user (e.g LocalSystem)
+ -->
+ <![CDATA[ (UserSID <> "S-1-5-18") AND (UserSID <> "S-1-5-19") AND (UserSID <> "S-1-5-20") ]]>
+ </Condition>
+ <RegistryValue Root='HKLM'
+ Key='SOFTWARE\@CPACK_WIX_PACKAGE_NAME@'
+ Name='InstalledBy' Value='[USER_DOMAIN]\[LogonUser]' Type='string' KeyPath='yes'/>
+ <CreateFolder>
+ <util:PermissionEx User="[LogonUser]" Domain="[USER_DOMAIN]" GenericAll="yes" />
+ </CreateFolder>
+ </Component>
+
+ <!-- Database service conditioned on SERVICENAME property-->
+ <Component Id="C.service" Guid="*" Directory="DATADIR">
+ <Condition>SERVICENAME</Condition>
+ <RegistryValue Root='HKLM'
+ Key='SOFTWARE\@CPACK_WIX_PACKAGE_NAME@'
+ Name='SERVICENAME' Value='[SERVICENAME]' Type='string' KeyPath='yes'/>
+ <ServiceControl Id='DBInstanceServiceStop' Name='[SERVICENAME]' Stop='both' Remove='uninstall' Wait='yes'/>
+ <ServiceControl Id='DBInstanceServiceStart' Name='[SERVICENAME]' Start='install' Wait='yes'/>
+ </Component>
+
+ <Component Id="C.myiniconfig" Guid="*" Directory="DATADIR">
+ <RegistryValue Root='HKLM'
+ Key='SOFTWARE\@CPACK_WIX_PACKAGE_NAME@'
+ Name='STDCONFIG' Value='1' Type='string' KeyPath='yes'/>
+ <IniFile Id="Ini3"
+ Action="createLine"
+ Directory="DATADIR"
+ Section="mysqld"
+ Name="my.ini"
+ Key="innodb_buffer_pool_size"
+ Value="[BUFFERPOOLSIZE]M" />
+ </Component>
+
+ <Component Id="C.utf8" Guid="*" Directory="DATADIR">
+ <Condition>UTF8</Condition>
+ <RegistryValue Root='HKLM'
+ Key='SOFTWARE\@CPACK_WIX_PACKAGE_NAME@'
+ Name='UTF8' Value='1' Type='string' KeyPath='yes'/>
+ <IniFile Id="Ini6"
+ Action="createLine"
+ Directory="DATADIR"
+ Section="mysqld"
+ Name="my.ini"
+ Key="character-set-server"
+ Value="utf8mb4" />
+ </Component>
+
+ <!-- Shortcuts in program menu (mysql client etc) -->
+ <Component Id="c.shortcuts" Guid="*" Directory="ShortcutFolder">
+ <!-- shortcut to my.ini-->
+ <RegistryValue Root="HKCU" Key="Software\@CPACK_WIX_PACKAGE_NAME@\Uninstall" Name="shortcuts" Value="1" Type="string" KeyPath="yes" />
+ <RemoveFolder Id="RemoveShorcutFolder" On="uninstall" />
+ <Shortcut Id="shortcut.my.ini"
+ Name="my.ini (@CPACK_WIX_PACKAGE_NAME@)"
+ Target="[System64Folder]notepad.exe"
+ Arguments="&quot;[DATADIR]my.ini&quot;"
+ Directory="ShortcutFolder"
+ Description="Edit database configuration" />
+ <Shortcut Id="shortcut.errorlog"
+ Name="Error log (@CPACK_WIX_PACKAGE_NAME@)"
+ Target="[System64Folder]notepad.exe"
+ Arguments="&quot;[DATADIR][ComputerName].err&quot;"
+ Directory="ShortcutFolder"
+ Description="View Database Error log" />
+ <Shortcut Id="shortcut.dbfolder" Name="Database directory (@CPACK_WIX_PACKAGE_NAME@)"
+ Target="[DATADIR]" />
+ </Component>
+
+ <!-- add reference so mysql client won't get uninstalled and we have a shortcut pointing to nowhere-->
+ <ComponentRef Id="C.bin.mysql.exe"/>
+
+ <Component Id="c.shortcuts.commandline" Guid="*" Directory="ShortcutFolder">
+ <RegistryValue
+ Root="HKCU" Key="Software\@CPACK_WIX_PACKAGE_NAME@\Uninstall"
+ Name="shortcuts.commandline"
+ Value="1" Type="string" KeyPath="yes" />
+ <!-- shortcut to client-->
+ <Shortcut Id="shortcut.mysql.exe"
+ Name="MySQL Client (@CPACK_WIX_PACKAGE_NAME@)"
+ Target="[System64Folder]cmd.exe"
+ Arguments="/k &quot; &quot;[D.bin]mysql.exe&quot; &quot;--defaults-file=[DATADIR]my.ini&quot; -uroot -p&quot;"
+ Directory="ShortcutFolder"
+ WorkingDirectory="D.bin"
+ Description="Starts mysql.exe for root user" />
+ </Component>
+ <Component Id="c.shortcuts.commandprompt.db" Guid="*" Directory="ShortcutFolder" Transitive="yes">
+ <Condition>SERVICENAME</Condition>
+ <RegistryValue
+ Root="HKCU" Key="Software\@CPACK_WIX_PACKAGE_NAME@\Uninstall"
+ Name="shortcuts.commandprompt.db"
+ Value="1" Type="string" KeyPath="yes" />
+ <!-- just command prompt in the bin directory (so all utilities can be called) -->
+ <Shortcut Id="shortcut.commandprompt.exe.db"
+ Name="Command Prompt (@CPACK_WIX_PACKAGE_NAME@)"
+ Target="[System64Folder]cmd.exe"
+ Directory="ShortcutFolder"
+ Arguments="/k &quot;set MYSQL_HOME=[DATADIR]&amp;&amp; set PATH=[D.bin];%PATH%;&amp;&amp;echo Setting environment for [ProductName] &quot;"
+ Description="Opens command line in the installation bin directory" />
+ </Component>
+
+
+ </Feature>
+
+ <Feature Id="SharedClientServerComponents"
+ Title='Utilities used by both server and client.'
+ Description=
+ 'Client utilities that are also used with server.Required for upgrade.'
+ ConfigurableDirectory='INSTALLDIR'
+ AllowAdvertise='no'
+ Level='1'
+ Display='hidden'>
+
+ <Component Id="C_Permissions.bin" Guid="2ce05496-3273-4866-a5b5-1eff2837b4cb" Directory="D.bin">
+ <!-- in case service is installed now on it the future -->
+ <CreateFolder>
+ <util:PermissionEx User="ALL SERVICES" Domain="NT SERVICE" GenericRead="yes" GenericExecute="yes" />
+ </CreateFolder>
+ <Condition>SERVICENAME</Condition>
+ </Component>
+
+ <Component Id="C_Permissions.lib.plugin" Guid="ff2e8f47-83fd-4dee-9e22-f103600cfc80" Directory="D.lib.plugin">
+ <CreateFolder>
+ <util:PermissionEx User="ALL SERVICES" Domain="NT SERVICE" GenericRead="yes" GenericExecute="yes" />
+ </CreateFolder>
+ <Condition>SERVICENAME</Condition>
+ </Component>
+
+ <Component Id="C_Permissions.share" Guid="be8ee2fb-a837-4b31-b59a-68a506d97d81" Directory="D.share">
+ <CreateFolder>
+ <util:PermissionEx User="ALL SERVICES" Domain="NT SERVICE" GenericRead="yes" GenericExecute="yes" />
+ </CreateFolder>
+ <Condition>SERVICENAME</Condition>
+ </Component>
+
+ <ComponentRef Id='C.bin.mysql.exe'/>
+ <ComponentRef Id='C.bin.mysqladmin.exe'/>
+ <ComponentRef Id='C.bin.mysql_upgrade.exe'/>
+ <ComponentRef Id='C.bin.mysqlcheck.exe'/>
+ <Component Id="c.shortcuts.commandprompt.nodb" Guid="*" Directory="ShortcutFolder" Transitive="yes">
+ <Condition>NOT SERVICENAME</Condition>
+ <RegistryValue
+ Root="HKCU" Key="Software\@CPACK_WIX_PACKAGE_NAME@\Uninstall"
+ Name="shortcuts.commandprompt.nodb"
+ Value="1" Type="string" KeyPath="yes" />
+ <!-- just command prompt in the bin directory (so all utilities can be called) -->
+ <Shortcut Id="shortcut.commandprompt.exe.nodb"
+ Name="Command Prompt (@CPACK_WIX_PACKAGE_NAME@)"
+ Target="[System64Folder]cmd.exe"
+ Directory="ShortcutFolder"
+ Arguments="/k &quot;set PATH=[D.bin];%PATH%;&amp;&amp;echo Setting environment for [ProductName] &quot;"
+ Description="Opens command line in the installation bin directory" />
+ </Component>
+ <?if $(var.HaveUpgradeWizard) != "0" ?>
+ <ComponentRef Id='C.bin.mysql_upgrade_wizard.exe'/>
+ <?endif?>
+ </Feature>
+
+ <!-- Optional 3rd party tools -->
+ <DirectoryRef Id='TARGETDIR'>
+ <Directory Id='CommonFilesFolder'>
+ <Directory Id='MariaDBShared' Name='MariaDBShared'/>
+ </Directory>
+ <Directory Id='DesktopFolder'/>
+ </DirectoryRef>
+
+
+ <?if "@WITH_THIRD_PARTY@" != "" ?>
+
+ <!-- Include definition of 3party components -->
+ <?foreach tool in @WITH_THIRD_PARTY@ ?>
+ <?include "${CMAKE_CURRENT_BINARY_DIR}\$(var.tool).wxi" ?>
+ <?endforeach ?>
+
+ <Feature Id="ThirdPartyTools"
+ Title='Third party tools'
+ Description= 'Third party tools'
+ AllowAdvertise='no'
+ Level='1'
+ Display='expand'>
+ @THIRD_PARTY_FEATURE_CONDITION@
+ <!-- Include definition of 3rd party features -->
+ <?foreach tool in @WITH_THIRD_PARTY@ ?>
+ <?include "${CMAKE_CURRENT_BINARY_DIR}\$(var.tool)_feature.wxi" ?>
+ <?endforeach ?>
+
+ </Feature>
+
+ <?endif ?>
+
+
+ <!-- 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"
+ Value=
+ "&quot;[#F.bin.mysql_install_db.exe]&quot; &quot;--service=[SERVICENAME]&quot; --port=[PORT] --innodb-page-size=[PAGESIZE] &quot;--password=[ESCAPEDPASSWORD]&quot; &quot;--datadir=[DATADIR]\&quot; [SKIPNETWORKING] [ALLOWREMOTEROOTACCESS] [DEFAULTUSER] --verbose-bootstrap"
+ Execute="immediate"
+ HideTarget="yes"
+ />
+ <CustomAction Id="CreateDatabaseRollbackCommand" Property="CreateDatabaseRollback"
+ Value="[SERVICENAME]\[DATADIR]"
+ Execute="immediate"/>
+ <CustomAction Id="CreateDatabase" BinaryKey="WixCA" DllEntry="@CA_QUIET_EXEC@"
+ Execute="deferred" Return="check" Impersonate="no" />
+ <CustomAction Id="CreateDatabaseRollback" BinaryKey="wixca.dll" DllEntry="CreateDatabaseRollback"
+ Execute="rollback" Return="check" Impersonate="no"/>
+ <UI>
+ <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) -->
+ <Property Id="FailureProgram">
+ <![CDATA[
+ Function Main()
+ Main = 3
+ End Function
+ ]]>
+ </Property>
+ <CustomAction Id="FakeFailure"
+ VBScriptCall="Main"
+ Property="FailureProgram"
+ Execute="deferred" />
+
+ <CustomAction Id='ErrorDataDir'
+ Error='Invalid data directory, choose a different one. Error : [DATADIRERROR]'/>
+ <CustomAction Id="ErrorInstallDir"
+ Error="[INSTALLDIRERROR]" />
+ <InstallExecuteSequence>
+ <Custom Action="CheckDataDirectory" After="CostFinalize">
+ <![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]>
+ </Custom>
+ <Custom Action="ErrorDataDir" After="CheckDataDirectory">DATADIRERROR</Custom>
+ <Custom Action="CheckInstallDirectory" After="CostFinalize">
+ NOT Installed AND OLDERVERSIONBEINGUPGRADED=""
+ </Custom>
+ <Custom Action="ErrorInstallDir" After="CheckInstallDirectory">INSTALLDIRERROR</Custom>
+ <Custom Action="CheckDatabaseProperties" Before="CreateDatabaseCommand">SERVICENAME</Custom>
+ <Custom Action="CreateDatabaseCommand" After="CostFinalize" >
+ <![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]>
+ </Custom>
+ <Custom Action="CreateDatabase" After="InstallFiles">
+ <![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]>
+ </Custom>
+ <Custom Action="CreateDatabaseRollbackCommand" After="CostFinalize">
+ <![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]>
+ </Custom>
+ <Custom Action="CreateDatabaseRollback" Before="CreateDatabase">
+ <![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]>
+ </Custom>
+ <Custom Action='FakeFailure' Before='InstallFinalize'>
+ <![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED="" AND TESTFAIL]]>
+ </Custom>
+ </InstallExecuteSequence>
+
+
+ <!-- Custom action to remove data on uninstall -->
+ <Binary Id='wixca.dll' SourceFile='@WIXCA_LOCATION@' />
+ <CustomAction Id="RemoveDataDirectory.SetProperty" Return="check"
+ Property="RemoveDataDirectory" Value="[DATADIR]" />
+ <CustomAction Id="RemoveDataDirectory" BinaryKey="wixca.dll"
+ DllEntry="RemoveDataDirectory"
+ Execute="deferred"
+ Impersonate="no"
+ Return="ignore" />
+ <InstallExecuteSequence>
+ <Custom Action="RemoveDataDirectory.SetProperty" After="CreateDatabaseCommand" >
+ <![CDATA[($C.datadir=2) AND (CLEANUPDATA) AND NOT UPGRADINGPRODUCTCODE]]>
+ </Custom>
+ <Custom Action="RemoveDataDirectory" Before="RemoveFiles">
+ <![CDATA[($C.datadir=2) AND (CLEANUPDATA) AND NOT UPGRADINGPRODUCTCODE]]>
+ </Custom>
+ </InstallExecuteSequence>
+
+ <InstallExecuteSequence>
+ <StopServices>SERVICENAME</StopServices>
+ <DeleteServices>SERVICENAME</DeleteServices>
+ </InstallExecuteSequence>
+ <CustomAction Id="CheckDBInUse" Return="ignore"
+ BinaryKey="wixca.dll" DllEntry="CheckDBInUse" Execute="firstSequence"/>
+ <InstallExecuteSequence>
+ <Custom Action="CheckDBInUse" Before="LaunchConditions">Installed</Custom>
+ <Custom Action="PresetDatabaseProperties" After="CheckDBInUse"></Custom>
+ </InstallExecuteSequence>
+ <InstallUISequence>
+ <Custom Action="CheckDBInUse" Before="LaunchConditions">Installed</Custom>
+ <Custom Action="PresetDatabaseProperties" After="CheckDBInUse"></Custom>
+ </InstallUISequence>
+
+ <!-- Store some properties persistently in registry, mainly for upgrades -->
+
+ <Feature Id='StoreInstallLocation' Level='1' Absent='disallow' Display='hidden'>
+ <Component Directory='INSTALLDIR' Guid='*' Id='C.storeinstalllocation'>
+ <RegistryValue Root='HKLM' Key='SOFTWARE\@CPACK_WIX_PACKAGE_NAME@'
+ Name='INSTALLDIR' Value='[INSTALLDIR]' Type='string' KeyPath='yes'/>
+ </Component>
+ </Feature>
+
+ <?foreach STOREDVAR in SERVICENAME;DATADIR;INSTALLDIR?>
+
+ <Property Id='$(var.STOREDVAR)' Secure='yes'>
+ <RegistrySearch Id='$(var.STOREDVAR)Property' Root='HKLM'
+ Key='SOFTWARE\@CPACK_WIX_PACKAGE_NAME@'
+ Name='$(var.STOREDVAR)' Type='raw' />
+ </Property>
+ <CustomAction Id='SaveCmdLineValue_$(var.STOREDVAR)' Property='CMDLINE_$(var.STOREDVAR)'
+ Value='[$(var.STOREDVAR)]' Execute='firstSequence' />
+ <CustomAction Id='SetFromCmdLineValue_$(var.STOREDVAR)' Property='$(var.STOREDVAR)'
+ Value='[CMDLINE_$(var.STOREDVAR)]' Execute='firstSequence' />
+ <InstallUISequence>
+ <Custom Action='SaveCmdLineValue_$(var.STOREDVAR)' Before='AppSearch' />
+ <Custom Action='SetFromCmdLineValue_$(var.STOREDVAR)' After='AppSearch'>CMDLINE_$(var.STOREDVAR)</Custom>
+ </InstallUISequence>
+ <InstallExecuteSequence>
+ <Custom Action='SaveCmdLineValue_$(var.STOREDVAR)' Before='AppSearch' />
+ <Custom Action='SetFromCmdLineValue_$(var.STOREDVAR)' After='AppSearch'>CMDLINE_$(var.STOREDVAR)</Custom>
+ </InstallExecuteSequence>
+
+ <?endforeach?>
+
+ <!--
+ Optionally, start upgrade wizard on exit.
+ -->
+
+
+
+ <?if $(var.HaveUpgradeWizard) != "0" ?>
+ <UI>
+ <Publish Dialog="ExitDialog"
+ Control="Finish"
+ Event="DoAction"
+ Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
+ </UI>
+ <Property
+ Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT"
+ Value="Launch wizard to upgrade existing MariaDB or MySQL services." />
+ <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="0"/>
+ <Property Id="WixShellExecTarget" Value="[#F.bin.mysql_upgrade_wizard.exe]" />
+ <CustomAction Id="LaunchApplication"
+ BinaryKey="WixCA"
+ DllEntry="WixShellExec"
+ Impersonate="yes" />
+ <CustomAction
+ Id="CheckServiceUpgrades" Return="ignore" BinaryKey="wixca.dll"
+ DllEntry="CheckServiceUpgrades"
+ Execute="immediate" />
+ <InstallUISequence>
+ <Custom Action="CheckServiceUpgrades" After="CostFinalize">
+ $C.bin.mysql_upgrade_wizard.exe = 3 AND NOT Installed AND NOT OLDERVERSIONBEINGUPGRADED
+ </Custom>
+ </InstallUISequence>
+ <SetProperty Before="ExecuteAction" Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT"
+ Sequence="ui" Value="[NonExistentProperty]">
+ <![CDATA[($C.bin.mysql_upgrade_wizard.exe <> 3) AND NOT Installed OR OLDERVERSIONBEINGUPGRADED]]>
+ </SetProperty>
+ <SetProperty Before="ExecuteAction" Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX"
+ Sequence="ui" Value="[NonExistentProperty]">
+ <![CDATA[($C.bin.mysql_upgrade_wizard.exe <> 3) AND NOT Installed OR OLDERVERSIONBEINGUPGRADED]]>
+ </SetProperty>
+
+ <?endif ?> <!-- HaveUpgradeWizard -->
+
+ <!--
+ Author the registry entries for "add or remove programs"
+ We choose to define ARPSYSTEMCOMPONENT to 1 because we want to show
+ "do you want to remove data directory" on uninstall
+ -->
+ <Property Id="ARPSYSTEMCOMPONENT" Value="1" Secure="yes" />
+ <Property Id="ARPINSTALLLOCATION" Secure="yes"/>
+ <SetProperty Id="ARPINSTALLLOCATION" Value="[INSTALLDIR]" After="InstallValidate" Sequence="execute"/>
+ <SetProperty Id="USER_DOMAIN" Value="[%USERDOMAIN]" After="LaunchConditions" Sequence="first" />
+ <Feature Id='ARPRegistryEntries'
+ Title='Add or remove program entries'
+ Description='Add or remove program entries'
+ AllowAdvertise='no'
+ Absent='disallow' Display='hidden'
+ Level='1'>
+ <Component Id="C.arp_entries" Guid="*" Directory="INSTALLDIR">
+ <RemoveFolder Id="RemoveINSTALLDIR" On="uninstall"/>
+ <RegistryValue Root='HKLM'
+ Key='Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_WIX_PACKAGE_NAME@'
+ Name='DisplayName' Value='[ProductName]' Type='string' KeyPath='yes'/>
+ <RegistryValue Root='HKLM'
+ Key='Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_WIX_PACKAGE_NAME@'
+ Name='Publisher' Value='@MANUFACTURER@' Type='string'/>
+ <RegistryValue Root='HKLM'
+ Key='Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_WIX_PACKAGE_NAME@'
+ Name='DisplayVersion' Value='[ProductVersion]' Type='string'/>
+ <RegistryValue Root='HKLM'
+ Key='Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_WIX_PACKAGE_NAME@'
+ Name='InstallLocation' Value='[INSTALLDIR]' Type='string'/>
+ <RegistryValue Root='HKLM'
+ Key='Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_WIX_PACKAGE_NAME@'
+ Name='UninstallString' Value='msiexec.exe /I [ProductCode]' Type='string'/>
+ <RegistryValue Root='HKLM'
+ Key='Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_WIX_PACKAGE_NAME@'
+ Name='MajorVersion' Value='@MAJOR_VERSION@' Type='string'/>
+ <RegistryValue Root='HKLM'
+ Key='Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_WIX_PACKAGE_NAME@'
+ Name='MinorVersion' Value='@MINOR_VERSION@' Type='string'/>
+ </Component>
+ </Feature>
+ <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 Message='This application is only supported on Windows 10, Windows Server 2016, or higher.'>
+ <![CDATA[Installed OR (VersionNT >= 603)]]>
+ </Condition>
+ </Fragment>
+</Wix>
diff --git a/win/packaging/heidisql.cmake b/win/packaging/heidisql.cmake
new file mode 100644
index 00000000..45a40737
--- /dev/null
+++ b/win/packaging/heidisql.cmake
@@ -0,0 +1,16 @@
+SET(HEIDISQL_BASE_NAME "HeidiSQL_12.3_32_Portable")
+SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip")
+SET(HEIDISQL_URL "http://www.heidisql.com/downloads/releases/${HEIDISQL_ZIP}")
+SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME})
+
+IF(NOT EXISTS ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP})
+ MAKE_DIRECTORY(${HEIDISQL_DOWNLOAD_DIR})
+ MESSAGE(STATUS "Downloading ${HEIDISQL_URL} to ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP}")
+ FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP} TIMEOUT 60)
+ EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E chdir ${HEIDISQL_DOWNLOAD_DIR}
+ ${CMAKE_COMMAND} -E tar xfz ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP}
+ )
+ENDIF()
+
+CONFIGURE_FILE(${SRCDIR}/heidisql.wxi.in ${CMAKE_CURRENT_BINARY_DIR}/heidisql.wxi)
+CONFIGURE_FILE(${SRCDIR}/heidisql_feature.wxi.in ${CMAKE_CURRENT_BINARY_DIR}/heidisql_feature.wxi)
diff --git a/win/packaging/heidisql.wxi.in b/win/packaging/heidisql.wxi.in
new file mode 100644
index 00000000..03d5b579
--- /dev/null
+++ b/win/packaging/heidisql.wxi.in
@@ -0,0 +1,128 @@
+<Include>
+<Property Id="HEIDISQLINSTALLED" Secure="yes">
+<RegistrySearch Id="HeidiSQL"
+ Root="HKLM"
+ Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\HeidiSQL_is1"
+ Name="UninstallString"
+ Type="raw"
+ Win64="no"
+/>
+</Property>
+<?define pluginlist=auth_gssapi_client.dll;auth_named_pipe.dll;caching_sha2_password.dll;client_ed25519.dll;dialog.dll;mysql_clear_password.dll;pvio_npipe.dll;pvio_shmem.dll;sha256_password.dll?>
+<DirectoryRef Id="MariaDBShared">
+ <Directory Id="D.HeidiSQL" Name="HeidiSQL">
+ <Component Id="component.HeidiSQL" Guid="96ea3879-5320-4098-8f26-2f655d2f716c" Win64="no">
+
+ <File Id="heidisql.gpl.txt" Name="gpl.txt" Source="${HEIDISQL_DOWNLOAD_DIR}\gpl.txt" />
+ <File Id="heidisql.heidisql.exe" Name="heidisql.exe" Source="${HEIDISQL_DOWNLOAD_DIR}\heidisql.exe" KeyPath="yes">
+ <Shortcut Id="desktopHeidiSQL" Directory="DesktopFolder" Name="HeidiSQL" Advertise="yes"/>
+ </File>
+ <!--
+ Forced file removal for heidisql.exe might be required.
+ HeidiSQL is self-updating, thus the version that was installed by MSI not necessarily matches
+ the version of the file on uninstall. MSI would not touch such file by default and leave it after
+ uninstallation. We use RemoveFile to force delete in any case.
+ -->
+ <RemoveFile Id="Remove_HeidiSQL_exe" Name="heidisql.exe" On="uninstall" />
+ <!-- remove readme.txt too, it's not included in HeidiSQL-9.1-Portable.zip -->
+ <RemoveFile Id="Remove_readme_txt" Name="readme.txt" On="uninstall" />
+
+ <File Id="heidisql.license.txt" Name="license.txt" Source="${HEIDISQL_DOWNLOAD_DIR}\license.txt" />
+ </Component>
+ <Component Id="component.HeidiSQL_MenuShortcut" Guid="*" Win64="no">
+ <RegistryValue Root="HKCU" Key="Software\@CPACK_WIX_PACKAGE_NAME@\Uninstall" Name="shortcuts.heidisql" Value="1" Type="string" KeyPath="yes" />
+ <Shortcut Id="startmenuHeidiSQL" Directory="ShortcutFolder" Name="HeidiSQL" Target="[D.HeidiSQL]\heidisql.exe"/>
+ </Component>
+
+ <Component Id="component.HeidiSQL_libmysql.dll" Guid="*" Win64="no">
+ <File Id="heidisql.libmysql.dll" Name="libmysql.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libmysql.dll" />
+ </Component>
+ <Component Id="component.HeidiSQL_libmysql_6.1.dll" Guid="*" Win64="no">
+ <File Id="heidisql.libmysql_6.1.dll" Name="libmysql-6.1.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libmysql-6.1.dll" />
+ </Component>
+ <Component Id="component.HeidiSQL_libmariadb.dll" Guid="*" Win64="no">
+ <File Id="heidisql.libmariadb.dll" Name="libmariadb.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libmariadb.dll" />
+ </Component>
+ <Component Id="component.HeidiSQL_libssl_1_1.dll" Guid="*" Win64="no">
+ <File Id="heidisql.libssl_1_1.dll" Name="libssl-1_1.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libssl-1_1.dll" />
+ </Component>
+ <Component Id="component.HeidiSQL_libpq_10.dll" Guid="*" Win64="no">
+ <File Id="heidisql.libpq_10.dll" Name="libpq-10.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libpq-10.dll" />
+ </Component>
+ <Component Id="component.HeidiSQL_libcrypto_1_1.dll" Guid="*" Win64="no">
+ <File Id="heidisql.libcrypto_1_1.dll" Name="libcrypto-1_1.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libcrypto-1_1.dll" />
+ </Component>
+ <Component Id="component.HeidiSQL_libintl_8.dll" Guid="*" Win64="no">
+ <File Id="heidisql.libintl_8.dll" Name="libintl-8.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libintl-8.dll" />
+ </Component>
+ <Component Id="component.HeidiSQL_libiconv_2.dll" Guid="*" Win64="no">
+ <File Id="heidisql.libiconv_2.dll" Name="libiconv-2.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libiconv-2.dll" />
+ </Component>
+ <Component Id="component.HeidiSQL_sqlite3.dll" Guid="*" Win64="no">
+ <File Id="heidisql.sqlite3.dll" Name="sqlite3.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\sqlite3.dll" />
+ </Component>
+
+ <Component Id="component.HeidiSQL_fbclient_4.0.dll" Guid="*" Win64="no">
+ <File Id="fbclient4.0.dll" Name="fbclient-4.0.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\fbclient-4.0.dll" />
+ </Component>
+ <Component Id="component.HeidiSQL_gds32_14.1.dll" Guid="*" Win64="no">
+ <File Id="gds32_14.1.dll" Name="gds32-14.1.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\gds32-14.1.dll" />
+ </Component>
+ <Component Id="component.HeidiSQL_plink.exe" Guid="*" Win64="no">
+ <File Id="plink.exe" Name="plink.exe" Source="${HEIDISQL_DOWNLOAD_DIR}\plink.exe" />
+ </Component>
+
+ <Component Id="component.HeidiSQL_LICENSE_openssl" Guid="*" Win64="no">
+ <File Id="LICENSE_openssl" Name="LICENSE-openssl" Source="${HEIDISQL_DOWNLOAD_DIR}\LICENSE-openssl" />
+ </Component>
+
+ <?define functions_dblist=interbase;mariadb;mssql;mysql;postgresql;redshift;sqlite?>
+
+ <?foreach db in $(var.functions_dblist) ?>
+ <Component Id="component.HeidiSQL_functions_$(var.db).ini" Guid="*" Win64="no">
+ <File Id="functions_$(var.db).ini" Name="functions-$(var.db).ini"
+ Source="${HEIDISQL_DOWNLOAD_DIR}\functions-$(var.db).ini" />
+ </Component>
+ <?endforeach?>
+
+ <Directory Id="D.HeidiSQL.plugins" Name="plugins">
+ <?foreach dll in $(var.pluginlist) ?>
+ <Component Id="component.HeidiSQL_$(var.dll)" Guid="*" Win64="no">
+ <File Id="heidisql.$(var.dll)" Name="$(var.dll)" Source="${HEIDISQL_DOWNLOAD_DIR}\plugins\$(var.dll)" />
+ </Component>
+ <?endforeach?>
+ </Directory>
+
+ <Component Id="component.HeidiSQL_CleanupSettings" Guid="*" Win64="no">
+ <Condition>HEIDISQLINSTALLED</Condition>
+ <RegistryValue Root="HKCU" Key="Software\@CPACK_WIX_PACKAGE_NAME@\UninstallCleanupHeidiSQLSettings" Name="cleanup.heidisql" Value="1" Type="string" KeyPath="yes" />
+ <RemoveRegistryKey Id="HeidiSQL_RegistryCleanup" Root="HKCU" Key="SOFTWARE\HeidiSQL" Action="removeOnUninstall" />
+ </Component>
+ </Directory>
+</DirectoryRef>
+
+<ComponentGroup Id="HeidiSQL">
+ <ComponentRef Id="component.HeidiSQL"/>
+ <ComponentRef Id="component.HeidiSQL_MenuShortcut"/>
+ <ComponentRef Id="component.HeidiSQL_libmysql.dll"/>
+ <ComponentRef Id="component.HeidiSQL_libmariadb.dll"/>
+ <ComponentRef Id="component.HeidiSQL_libssl_1_1.dll" />
+ <ComponentRef Id="component.HeidiSQL_libpq_10.dll" />
+ <ComponentRef Id="component.HeidiSQL_libcrypto_1_1.dll" />
+ <ComponentRef Id="component.HeidiSQL_libintl_8.dll" />
+ <ComponentRef Id="component.HeidiSQL_libiconv_2.dll" />
+ <ComponentRef Id="component.HeidiSQL_sqlite3.dll" />
+ <ComponentRef Id="component.HeidiSQL_libmysql_6.1.dll" />
+ <ComponentRef Id="component.HeidiSQL_fbclient_4.0.dll" />
+ <ComponentRef Id="component.HeidiSQL_gds32_14.1.dll" />
+ <ComponentRef Id="component.HeidiSQL_plink.exe" />
+ <ComponentRef Id="component.HeidiSQL_LICENSE_openssl" />
+ <?foreach db in $(var.functions_dblist) ?>
+ <ComponentRef Id="component.HeidiSQL_functions_$(var.db).ini" />
+ <?endforeach?>
+ <?foreach dll in $(var.pluginlist)?>
+ <ComponentRef Id="component.HeidiSQL_$(var.dll)" />
+ <?endforeach?>
+ <ComponentRef Id="component.HeidiSQL_CleanupSettings"/>
+</ComponentGroup>
+</Include>
diff --git a/win/packaging/heidisql_feature.wxi.in b/win/packaging/heidisql_feature.wxi.in
new file mode 100644
index 00000000..241554e0
--- /dev/null
+++ b/win/packaging/heidisql_feature.wxi.in
@@ -0,0 +1,10 @@
+<Include>
+<Feature Id="HeidiSQL"
+ Title='HeidiSQL'
+ Description= 'Powerful, easy and free MySQL/MariaDB GUI client by Ansgar Becker'
+ AllowAdvertise='no'
+ Level='1'>
+ <Condition Level="0">HEIDISQLINSTALLED AND NOT REMOVE ~= ALL</Condition>
+ <ComponentGroupRef Id='HeidiSQL'/>
+</Feature>
+</Include>
diff --git a/win/packaging/mysql_server.wxs.in b/win/packaging/mysql_server.wxs.in
new file mode 100644
index 00000000..0d955659
--- /dev/null
+++ b/win/packaging/mysql_server.wxs.in
@@ -0,0 +1,89 @@
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
+ xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
+ <Product
+ Id="*"
+ UpgradeCode="@CPACK_WIX_UPGRADE_CODE@"
+ Name="@CPACK_WIX_PACKAGE_NAME@"
+ Version="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@.@TINY_VERSION@"
+ Language="1033"
+ Manufacturer="@MANUFACTURER@">
+
+ <Package Id='*'
+ Keywords='Installer'
+ Description='MariaDB Server'
+ Manufacturer='@MANUFACTURER@'
+ InstallerVersion='500'
+ Languages='1033'
+ Compressed='yes'
+ SummaryCodepage='1252'
+ Platform='@Platform@'/>
+
+ <MediaTemplate EmbedCab="yes" MaximumUncompressedMediaSize="2" CompressionLevel="high"/>
+
+ <!-- Upgrade -->
+ <Upgrade Id="@CPACK_WIX_UPGRADE_CODE@">
+ <?if "@PATCH_VERSION@" != "0"?>
+ <UpgradeVersion
+ Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.0"
+ IncludeMinimum="yes"
+ Maximum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@.@TINY_VERSION@"
+ IncludeMaximum="yes"
+ Property="OLDERVERSIONBEINGUPGRADED"
+ MigrateFeatures="yes"
+ />
+ <?endif?>
+ <UpgradeVersion
+ Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@.@TINY_VERSION@"
+ Maximum="@MAJOR_VERSION@.@MINOR_VERSION@.999"
+ IncludeMinimum="no"
+ OnlyDetect="yes"
+ Property="NEWERVERSIONDETECTED" />
+ </Upgrade>
+ <Condition Message="A more recent version of [ProductName] is already installed. Setup will now exit.">
+ NOT NEWERVERSIONDETECTED OR Installed
+ </Condition>
+ <InstallExecuteSequence>
+ <RemoveExistingProducts After="InstallFinalize"/>
+ </InstallExecuteSequence>
+
+
+ <InstallUISequence>
+ <AppSearch After="FindRelatedProducts"/>
+ </InstallUISequence>
+
+ <!-- UI -->
+ <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"></Property>
+ <UIRef Id="WixUI_ErrorProgressText" />
+ <UIRef Id="@CPACK_WIX_UI@" />
+
+
+ <!-- License -->
+ <WixVariable
+ Id="WixUILicenseRtf"
+ Value="@COPYING_RTF@"/>
+
+ <!-- Installation root-->
+ <Directory Id='TARGETDIR' Name='SourceDir'>
+ <Directory Id='@PlatformProgramFilesFolder@'>
+ <Directory Id='INSTALLDIR' Name='@CPACK_WIX_PACKAGE_BASE_NAME@ @MAJOR_VERSION@.@MINOR_VERSION@'>
+ </Directory>
+ </Directory>
+ </Directory>
+
+ <!-- CPACK_WIX_FEATURES -->
+ @CPACK_WIX_FEATURES@
+
+ <!-- CPACK_WIX_DIRECTORIES -->
+ @CPACK_WIX_DIRECTORIES@
+
+ <!--CPACK_WIX_COMPONENTS-->
+ @CPACK_WIX_COMPONENTS@
+
+ <!--CPACK_WIX_COMPONENTS_GROUPS -->
+ @CPACK_WIX_COMPONENT_GROUPS@
+
+ <!--CPACK_WIX_INCLUDES -->
+ @CPACK_WIX_INCLUDES@
+ </Product>
+
+</Wix>
diff --git a/win/upgrade_wizard/CMakeLists.txt b/win/upgrade_wizard/CMakeLists.txt
new file mode 100644
index 00000000..fd3560e1
--- /dev/null
+++ b/win/upgrade_wizard/CMakeLists.txt
@@ -0,0 +1,47 @@
+IF((NOT MSVC) OR CLANG_CL OR WITH_ASAN)
+ RETURN()
+ENDIF()
+
+# We need MFC
+# /permissive- flag does not play well with MFC, disable it.
+STRING(REPLACE "/permissive-" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+REMOVE_DEFINITIONS(-DNOSERVICE) # fixes "already defined" warning in an AFX header
+
+FIND_PACKAGE(MFC)
+IF(NOT MFC_FOUND)
+ IF(BUILD_RELEASE)
+ MESSAGE(FATAL_ERROR
+ "Can't find MFC. It is necessary for producing official package"
+ )
+ ENDIF()
+ RETURN()
+ENDIF()
+
+IF(MSVC_CRT_TYPE MATCHES "/MD")
+ # FORCE static CRT and MFC for upgrade wizard,
+ # so we do not have to redistribute MFC.
+ FORCE_STATIC_CRT()
+ SET(UPGRADE_WIZARD_SOURCES ${CMAKE_SOURCE_DIR}/sql/winservice.c)
+ELSE()
+ SET(UPGRADE_WIZARD_LINK_LIBRARIES winservice)
+ENDIF()
+
+# MFC should be statically linked
+SET(CMAKE_MFC_FLAG 1)
+
+# Enable exception handling (avoids warnings)
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc -DNO_WARN_MBCS_MFC_DEPRECATION")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql)
+MYSQL_ADD_EXECUTABLE(mariadb-upgrade-wizard
+ upgrade.cpp upgradeDlg.cpp upgrade.rc ${UPGRADE_WIZARD_SOURCES}
+ COMPONENT Server)
+
+
+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(mariadb-upgrade-wizard PROPERTIES
+ WIN32_EXECUTABLE 1
+ LINK_FLAGS "/MANIFESTUAC:level='requireAdministrator'"
+)
diff --git a/win/upgrade_wizard/res/upgrade.ico b/win/upgrade_wizard/res/upgrade.ico
new file mode 100644
index 00000000..33a61783
--- /dev/null
+++ b/win/upgrade_wizard/res/upgrade.ico
Binary files differ
diff --git a/win/upgrade_wizard/res/upgrade.rc2 b/win/upgrade_wizard/res/upgrade.rc2
new file mode 100644
index 00000000..8a1da417
--- /dev/null
+++ b/win/upgrade_wizard/res/upgrade.rc2
@@ -0,0 +1,13 @@
+//
+// zzz.RC2 - resources Microsoft Visual C++ does not edit directly
+//
+
+#ifdef APSTUDIO_INVOKED
+#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Add manually edited resources here...
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/win/upgrade_wizard/resource.h b/win/upgrade_wizard/resource.h
new file mode 100644
index 00000000..4c05cea2
--- /dev/null
+++ b/win/upgrade_wizard/resource.h
@@ -0,0 +1,27 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by upgrade.rc
+//
+#define IDD_UPGRADE_DIALOG 102
+#define IDR_MAINFRAME 128
+#define IDC_LIST1 1000
+#define IDC_PROGRESS1 1004
+#define IDC_EDIT1 1005
+#define IDC_EDIT2 1006
+#define IDC_EDIT3 1007
+#define IDC_EDIT7 1011
+#define IDC_EDIT8 1012
+#define IDC_EDIT9 1013
+#define IDC_BUTTON1 1014
+#define IDC_BUTTON2 1015
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_COMMAND_VALUE 32771
+#define _APS_NEXT_CONTROL_VALUE 1016
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/win/upgrade_wizard/stdafx.h b/win/upgrade_wizard/stdafx.h
new file mode 100644
index 00000000..86e4fd82
--- /dev/null
+++ b/win/upgrade_wizard/stdafx.h
@@ -0,0 +1,47 @@
+
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#pragma once
+
+#ifndef _SECURE_ATL
+#define _SECURE_ATL 1
+#endif
+
+#ifndef VC_EXTRALEAN
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#endif
+
+#include "targetver.h"
+struct IUnknown;
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+
+// turns off MFC's hiding of some common and often safely ignored warning messages
+#define _AFX_ALL_WARNINGS
+
+#include <afxwin.h> // MFC core and standard components
+#include <afxext.h> // MFC extensions
+
+
+
+
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
+#endif
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h> // MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/win/upgrade_wizard/targetver.h b/win/upgrade_wizard/targetver.h
new file mode 100644
index 00000000..87c0086d
--- /dev/null
+++ b/win/upgrade_wizard/targetver.h
@@ -0,0 +1,8 @@
+#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include <SDKDDKVer.h>
diff --git a/win/upgrade_wizard/upgrade.cpp b/win/upgrade_wizard/upgrade.cpp
new file mode 100644
index 00000000..ea2f894c
--- /dev/null
+++ b/win/upgrade_wizard/upgrade.cpp
@@ -0,0 +1,57 @@
+
+// upgrade.cpp : Defines the class behaviors for the application.
+//
+
+#include "stdafx.h"
+#include "upgrade.h"
+#include "upgradeDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+// CUpgradeApp
+
+BEGIN_MESSAGE_MAP(CUpgradeApp, CWinApp)
+ ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+
+// CUpgradeApp construction
+
+CUpgradeApp::CUpgradeApp()
+{
+ // TODO: add construction code here,
+ // Place all significant initialization in InitInstance
+}
+
+
+// The one and only CUpgradeApp object
+
+CUpgradeApp theApp;
+
+
+// CUpgradeApp initialization
+
+BOOL CUpgradeApp::InitInstance()
+{
+ // InitCommonControlsEx() is required on Windows XP if an application
+ // manifest specifies use of ComCtl32.dll version 6 or later to enable
+ // visual styles. Otherwise, any window creation will fail.
+ INITCOMMONCONTROLSEX InitCtrls;
+ InitCtrls.dwSize = sizeof(InitCtrls);
+ // Set this to include all the common control classes you want to use
+ // in your application.
+ InitCtrls.dwICC = ICC_WIN95_CLASSES;
+
+ InitCommonControlsEx(&InitCtrls);
+ CWinApp::InitInstance();
+ CUpgradeDlg dlg;
+ m_pMainWnd = &dlg;
+ dlg.DoModal();
+ // Since the dialog has been closed, return FALSE so that we exit the
+ // application, rather than start the application's message pump.
+ return FALSE;
+}
+
diff --git a/win/upgrade_wizard/upgrade.h b/win/upgrade_wizard/upgrade.h
new file mode 100644
index 00000000..b5dd10e7
--- /dev/null
+++ b/win/upgrade_wizard/upgrade.h
@@ -0,0 +1,32 @@
+
+// zzz.h : main header file for the PROJECT_NAME application
+//
+
+#pragma once
+
+#ifndef __AFXWIN_H__
+ #error "include 'stdafx.h' before including this file for PCH"
+#endif
+
+#include "resource.h" // main symbols
+
+
+// CzzzApp:
+// See zzz.cpp for the implementation of this class
+//
+
+class CUpgradeApp : public CWinApp
+{
+public:
+ CUpgradeApp();
+
+// Overrides
+public:
+ virtual BOOL InitInstance();
+
+// Implementation
+
+ DECLARE_MESSAGE_MAP()
+};
+
+extern CUpgradeApp theApp; \ No newline at end of file
diff --git a/win/upgrade_wizard/upgrade.rc b/win/upgrade_wizard/upgrade.rc
new file mode 100644
index 00000000..dbba9f67
--- /dev/null
+++ b/win/upgrade_wizard/upgrade.rc
@@ -0,0 +1,148 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#ifndef APSTUDIO_INVOKED
+#include "targetver.h"
+#endif
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#ifndef APSTUDIO_INVOKED\r\n"
+ "#include ""targetver.h""\r\n"
+ "#endif\r\n"
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+ "#define _AFX_NO_OLE_RESOURCES\r\n"
+ "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+ "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+ "\r\n"
+ "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+ "LANGUAGE 9, 1\r\n"
+ "#include ""res\\upgrade.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
+ "#include ""afxres.rc"" // Standard components\r\n"
+ "#endif\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_MAINFRAME ICON "res\\upgrade.ico"
+#endif // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (United States) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_UPGRADE_DIALOG DIALOGEX 0, 0, 320, 200
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "MariaDB Upgrade Wizard"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,113,169,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,191,169,50,14
+ LISTBOX IDC_LIST1,24,39,216,80,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+ EDITTEXT IDC_EDIT1,97,124,193,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_EDIT2,98,138,181,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ CONTROL "",IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH | WS_BORDER,26,153,243,14
+ EDITTEXT IDC_EDIT3,98,151,40,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_EDIT7,27,124,65,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_EDIT8,27,137,62,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_EDIT9,27,151,62,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ PUSHBUTTON "Select all",IDC_BUTTON1,245,61,50,14
+ PUSHBUTTON "Clear all",IDC_BUTTON2,246,88,50,14
+ LTEXT "Select services you want to upgrade and click on the [Upgrade] button.\nMake sure to backup data directories prior to upgrade.",IDC_STATIC,25,14,215,26
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_UPGRADE_DIALOG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 313
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 193
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE 9, 1
+#include "res\upgrade.rc2" // non-Microsoft Visual C++ edited resources
+#include "afxres.rc" // Standard components
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/win/upgrade_wizard/upgradeDlg.cpp b/win/upgrade_wizard/upgradeDlg.cpp
new file mode 100644
index 00000000..10a1787c
--- /dev/null
+++ b/win/upgrade_wizard/upgradeDlg.cpp
@@ -0,0 +1,641 @@
+
+// upgradeDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "upgrade.h"
+#include "upgradeDlg.h"
+#include "windows.h"
+#include "winsvc.h"
+#include <msi.h>
+#pragma comment(lib, "msi")
+#pragma comment(lib, "version")
+#include <map>
+#include <string>
+#include <vector>
+
+#include <winservice.h>
+#include <locale.h>
+
+using namespace std;
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+#define PRODUCT_NAME "MariaDB"
+
+// CUpgradeDlg dialog
+
+CUpgradeDlg::CUpgradeDlg(CWnd* pParent /*=NULL*/)
+ : CDialog(CUpgradeDlg::IDD, pParent)
+{
+ m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+void CUpgradeDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_Services);
+ DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
+ DDX_Control(pDX, IDOK, m_Ok);
+ DDX_Control(pDX, IDCANCEL, m_Cancel);
+ DDX_Control(pDX, IDC_EDIT1, m_IniFilePath);
+ DDX_Control(pDX, IDC_EDIT2, m_DataDir);
+ DDX_Control(pDX, IDC_EDIT3, m_Version);
+ DDX_Control(pDX, IDC_EDIT7, m_IniFileLabel);
+ DDX_Control(pDX, IDC_EDIT8, m_DataDirLabel);
+ DDX_Control(pDX, IDC_EDIT9, m_VersionLabel);
+ DDX_Control(pDX, IDC_BUTTON1, m_SelectAll);
+ DDX_Control(pDX, IDC_BUTTON2, m_ClearAll);
+}
+
+BEGIN_MESSAGE_MAP(CUpgradeDlg, CDialog)
+ ON_WM_PAINT()
+ ON_WM_QUERYDRAGICON()
+ ON_LBN_SELCHANGE(IDC_LIST1, &CUpgradeDlg::OnLbnSelchangeList1)
+ ON_CONTROL(CLBN_CHKCHANGE, IDC_LIST1, OnChkChange)
+ ON_BN_CLICKED(IDOK, &CUpgradeDlg::OnBnClickedOk)
+ ON_BN_CLICKED(IDCANCEL, &CUpgradeDlg::OnBnClickedCancel)
+ ON_BN_CLICKED(IDC_BUTTON1,&CUpgradeDlg::OnBnSelectAll)
+ ON_BN_CLICKED(IDC_BUTTON2,&CUpgradeDlg::OnBnClearAll)
+END_MESSAGE_MAP()
+
+
+struct ServiceProperties
+{
+ string servicename;
+ string myini;
+ string datadir;
+ string version;
+};
+
+vector<ServiceProperties> services;
+
+/*
+ Get version from an executable.
+ Returned version is either major.minor.patch or
+ <unknown> , of executable does not have any version
+ info embedded (like MySQL 5.1 for example)
+*/
+void GetExeVersion(const string& filename, int *major, int *minor, int *patch)
+{
+ DWORD handle;
+ *major= *minor= *patch= 0;
+
+ DWORD size = GetFileVersionInfoSize(filename.c_str(), &handle);
+ BYTE* versionInfo = new BYTE[size];
+ if (!GetFileVersionInfo(filename.c_str(), handle, size, versionInfo))
+ {
+ delete[] versionInfo;
+ return;
+ }
+ // we have version information
+ UINT len = 0;
+ VS_FIXEDFILEINFO* vsfi = NULL;
+ VerQueryValue(versionInfo, "\\", (void**)&vsfi, &len);
+
+ *major= (int)HIWORD(vsfi->dwFileVersionMS);
+ *minor= (int)LOWORD(vsfi->dwFileVersionMS);
+ *patch= (int)HIWORD(vsfi->dwFileVersionLS);
+ delete[] versionInfo;
+}
+
+
+void GetMyVersion(int *major, int *minor, int *patch)
+{
+ char path[MAX_PATH];
+ *major= *minor= *patch =0;
+ if (GetModuleFileName(NULL, path, MAX_PATH))
+ {
+ GetExeVersion(path, major, minor, patch);
+ }
+}
+// CUpgradeDlg message handlers
+
+/* Handle selection changes in services list */
+void CUpgradeDlg::SelectService(int index)
+{
+ m_IniFilePath.SetWindowText(services[index].myini.c_str());
+ m_DataDir.SetWindowText(services[index].datadir.c_str());
+ m_Version.SetWindowText(services[index].version.c_str());
+}
+
+
+
+/*
+ Iterate over services, lookup for mysqld.exe ones.
+ Compare mysqld.exe version with current version, and display
+ service if corresponding mysqld.exe has lower version.
+
+ The version check is not strict, i.e we allow to "upgrade"
+ for the same major.minor combination. This can be useful for
+ "upgrading" from 32 to 64 bit, or for MySQL=>Maria conversion.
+*/
+void CUpgradeDlg::PopulateServicesList()
+{
+
+ SC_HANDLE scm = OpenSCManager(NULL, NULL,
+ SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_CONNECT);
+ if (scm == NULL)
+ {
+ ErrorExit("OpenSCManager failed");
+ }
+
+ static BYTE buf[2*64*1024];
+ static BYTE configBuffer[8*1024];
+
+ DWORD bufsize= sizeof(buf);
+ DWORD bufneed;
+ DWORD num_services;
+ BOOL ok= EnumServicesStatusExW(scm, SC_ENUM_PROCESS_INFO, SERVICE_WIN32,
+ SERVICE_STATE_ALL, buf, bufsize, &bufneed, &num_services, NULL, NULL);
+ if(!ok)
+ ErrorExit("EnumServicesStatusEx failed");
+
+
+ LPENUM_SERVICE_STATUS_PROCESSW info =
+ (LPENUM_SERVICE_STATUS_PROCESSW)buf;
+ int index=-1;
+ for (ULONG i=0; i < num_services; i++)
+ {
+ SC_HANDLE service= OpenServiceW(scm, info[i].lpServiceName,
+ SERVICE_QUERY_CONFIG);
+ if (!service)
+ continue;
+ QUERY_SERVICE_CONFIGW *config=
+ (QUERY_SERVICE_CONFIGW*)(void *)configBuffer;
+ DWORD needed;
+ BOOL ok= QueryServiceConfigW(service, config,sizeof(configBuffer), &needed);
+ CloseServiceHandle(service);
+ if (ok)
+ {
+ mysqld_service_properties service_props;
+
+ if (get_mysql_service_properties(config->lpBinaryPathName,
+ &service_props))
+ continue;
+
+ /* Check if service uses mysqld in installation directory */
+ if (_strnicmp(service_props.mysqld_exe, m_InstallDir.c_str(),
+ m_InstallDir.size()) == 0)
+ continue;
+
+ if(m_MajorVersion > service_props.version_major ||
+ (m_MajorVersion == service_props.version_major && m_MinorVersion >=
+ service_props.version_minor))
+ {
+ ServiceProperties props;
+ props.myini= service_props.inifile;
+ props.datadir= service_props.datadir;
+ char service_name_buf[1024];
+ WideCharToMultiByte(GetACP(), 0, info[i].lpServiceName, -1,
+ service_name_buf, sizeof(service_name_buf),
+ 0, 0);
+ props.servicename= service_name_buf;
+ if (service_props.version_major)
+ {
+ char ver[64];
+ sprintf(ver, "%d.%d.%d", service_props.version_major,
+ service_props.version_minor, service_props.version_patch);
+ props.version= ver;
+ }
+ else
+ props.version= "<unknown>";
+
+ index = m_Services.AddString(service_name_buf);
+ services.resize(index+1);
+ services[index] = props;
+ }
+ }
+ if (index != -1)
+ {
+ m_Services.SetCurSel(0);
+ SelectService(m_Services.GetCurSel());
+ }
+ }
+ if (services.size())
+ {
+ SelectService(0);
+ }
+ else
+ {
+ char message[128];
+ sprintf(message,
+ "There is no service that can be upgraded to " PRODUCT_NAME " %d.%d.%d",
+ m_MajorVersion, m_MinorVersion, m_PatchVersion);
+ MessageBox(message, PRODUCT_NAME " Upgrade Wizard", MB_ICONINFORMATION);
+ exit(0);
+ }
+ if(scm)
+ CloseServiceHandle(scm);
+}
+
+BOOL CUpgradeDlg::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+ m_UpgradeRunning= FALSE;
+ // Set the icon for this dialog. The framework does this automatically
+ // when the application's main window is not a dialog
+ SetIcon(m_hIcon, TRUE); // Set big icon
+ SetIcon(m_hIcon, FALSE); // Set small icon
+ m_Ok.SetWindowText("Upgrade");
+ m_DataDirLabel.SetWindowText("Data directory:");
+ m_IniFileLabel.SetWindowText("Configuration file:");
+ m_VersionLabel.SetWindowText("Version:");
+
+ char myFilename[MAX_PATH];
+ GetModuleFileName(NULL, myFilename, MAX_PATH);
+ char *p= strrchr(myFilename,'\\');
+ if(p)
+ p[1]=0;
+ m_InstallDir= myFilename;
+
+ GetMyVersion(&m_MajorVersion, &m_MinorVersion, &m_PatchVersion);
+ char windowTitle[64];
+
+ sprintf(windowTitle, PRODUCT_NAME " %d.%d.%d Upgrade Wizard",
+ m_MajorVersion, m_MinorVersion, m_PatchVersion);
+ SetWindowText(windowTitle);
+
+ m_JobObject= CreateJobObject(NULL, NULL);
+
+ /*
+ Make all processes associated with the job terminate when the
+ last handle to the job is closed or job is teminated.
+ */
+ JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = {0};
+ jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
+ SetInformationJobObject(m_JobObject, JobObjectExtendedLimitInformation,
+ &jeli, sizeof(jeli));
+
+
+ m_Progress.ShowWindow(SW_HIDE);
+ m_Ok.EnableWindow(FALSE);
+ if (GetACP() == CP_UTF8)
+ {
+ /* Required for mbstowcs, used in some functions.*/
+ setlocale(LC_ALL, "en_US.UTF8");
+ }
+ PopulateServicesList();
+ return TRUE; // return TRUE unless you set the focus to a control
+}
+
+// If you add a minimize button to your dialog, you will need the code below
+// to draw the icon. For MFC applications using the document/view model,
+// this is automatically done for you by the framework.
+
+void CUpgradeDlg::OnPaint()
+{
+ if (IsIconic())
+ {
+ CPaintDC dc(this); // device context for painting
+
+ SendMessage(WM_ICONERASEBKGND,
+ reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
+
+ // Center icon in client rectangle
+ int cxIcon = GetSystemMetrics(SM_CXICON);
+ int cyIcon = GetSystemMetrics(SM_CYICON);
+ CRect rect;
+ GetClientRect(&rect);
+ int x = (rect.Width() - cxIcon + 1) / 2;
+ int y = (rect.Height() - cyIcon + 1) / 2;
+
+ // Draw the icon
+ dc.DrawIcon(x, y, m_hIcon);
+ }
+ else
+ {
+ CDialog::OnPaint();
+ }
+}
+
+// The system calls this function to obtain the cursor to display while the user
+// drags the minimized window.
+HCURSOR CUpgradeDlg::OnQueryDragIcon()
+{
+ return static_cast<HCURSOR>(m_hIcon);
+}
+
+
+void CUpgradeDlg::OnLbnSelchangeList1()
+{
+ SelectService(m_Services.GetCurSel());
+}
+
+void CUpgradeDlg::OnChkChange()
+{
+ if(m_Services.GetCheck( m_Services.GetCurSel()))
+ {
+ GetDlgItem(IDOK)->EnableWindow();
+ }
+ else
+ {
+ for(int i=0; i< m_Services.GetCount(); i++)
+ {
+ if(m_Services.GetCheck(i))
+ return;
+ }
+ // all items unchecked, disable OK button
+ GetDlgItem(IDOK)->EnableWindow(FALSE);
+ }
+}
+
+
+
+void CUpgradeDlg::ErrorExit(LPCSTR str)
+{
+ MessageBox(str, "Fatal Error", MB_ICONERROR);
+ exit(1);
+}
+
+
+const int MAX_MESSAGES=512;
+
+/* Main thread of the child process */
+static HANDLE hChildThread;
+
+void CUpgradeDlg::UpgradeOneService(const string& servicename)
+{
+ static string allMessages[MAX_MESSAGES];
+ static char npname[MAX_PATH];
+ static char pipeReadBuf[1];
+ SECURITY_ATTRIBUTES saAttr;
+ STARTUPINFO si={0};
+ PROCESS_INFORMATION pi;
+ saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
+ saAttr.bInheritHandle = TRUE;
+ saAttr.lpSecurityDescriptor = NULL;
+
+ HANDLE hPipeRead, hPipeWrite;
+ if(!CreatePipe(&hPipeRead, &hPipeWrite, &saAttr, 1))
+ ErrorExit("CreateNamedPipe failed");
+
+ /* Make sure read end of the pipe is not inherited */
+ if (!SetHandleInformation(hPipeRead, HANDLE_FLAG_INHERIT, 0) )
+ ErrorExit("Stdout SetHandleInformation");
+
+ string commandline("mysql_upgrade_service.exe --service=");
+ commandline += "\"";
+ commandline += servicename;
+ commandline += "\"";
+
+ si.cb = sizeof(si);
+ si.hStdInput= GetStdHandle(STD_INPUT_HANDLE);
+ si.hStdOutput= hPipeWrite;
+ si.hStdError= hPipeWrite;
+ si.wShowWindow= SW_HIDE;
+ si.dwFlags= STARTF_USESTDHANDLES |STARTF_USESHOWWINDOW;
+
+
+ /*
+ We will try to assign child process to a job, to be able to
+ terminate the process and all of its children. It might fail,
+ in case current process is already part of the job which does
+ not allows breakaways.
+ */
+ if (CreateProcess(NULL, (LPSTR)commandline.c_str(), NULL, NULL, TRUE,
+ CREATE_BREAKAWAY_FROM_JOB|CREATE_SUSPENDED, NULL, NULL, &si, &pi))
+ {
+ if(!AssignProcessToJobObject(m_JobObject, pi.hProcess))
+ {
+ char errmsg[128];
+ sprintf(errmsg, "AssignProcessToJobObject failed, error %d",
+ GetLastError());
+ ErrorExit(errmsg);
+ }
+ ResumeThread(pi.hThread);
+ }
+ else
+ {
+ /*
+ Creating a process with CREATE_BREAKAWAY_FROM_JOB failed, reset this flag
+ and retry.
+ */
+ if (!CreateProcess(NULL, (LPSTR)commandline.c_str(), NULL, NULL, TRUE,
+ 0, NULL, NULL, &si, &pi))
+ {
+ string errmsg("Create Process ");
+ errmsg+= commandline;
+ errmsg+= " failed";
+ ErrorExit(errmsg.c_str());
+ }
+ }
+
+ hChildThread = pi.hThread;
+ DWORD nbytes;
+ int lines=0;
+ CloseHandle(hPipeWrite);
+
+ string output_line;
+ while(ReadFile(hPipeRead, pipeReadBuf, 1, &nbytes, NULL))
+ {
+ if(pipeReadBuf[0] == '\n')
+ {
+ allMessages[lines%MAX_MESSAGES] = output_line;
+ m_DataDir.SetWindowText(allMessages[lines%MAX_MESSAGES].c_str());
+ lines++;
+
+ int curPhase, numPhases;
+
+ // Parse output line to update progress indicator
+ if (strncmp(output_line.c_str(),"Phase ",6) == 0 &&
+ sscanf(output_line.c_str() +6 ,"%d/%d",&curPhase,&numPhases) == 2
+ && numPhases > 0 )
+ {
+ int stepsTotal= m_ProgressTotal*numPhases;
+ int stepsCurrent= m_ProgressCurrent*numPhases+ curPhase;
+ int percentDone= stepsCurrent*100/stepsTotal;
+ m_Progress.SetPos(percentDone);
+ m_Progress.SetPos(stepsCurrent * 100 / stepsTotal);
+ }
+ output_line.clear();
+ }
+ else
+ {
+ if(pipeReadBuf[0] != '\r')
+ output_line.push_back(pipeReadBuf[0]);
+ }
+ }
+ CloseHandle(hPipeRead);
+
+ if(WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_OBJECT_0)
+ ErrorExit("WaitForSingleObject failed");
+ DWORD exitcode;
+ if (!GetExitCodeProcess(pi.hProcess, &exitcode))
+ ErrorExit("GetExitCodeProcess failed");
+
+ if (exitcode != 0)
+ {
+ string errmsg= "mysql_upgrade_service returned error for service ";
+ errmsg += servicename;
+ errmsg += ":\r\n";
+ errmsg+= output_line;
+ ErrorExit(errmsg.c_str());
+ }
+ CloseHandle(pi.hProcess);
+ hChildThread= 0;
+ CloseHandle(pi.hThread);
+}
+
+
+void CUpgradeDlg::UpgradeServices()
+{
+
+ /*
+ Disable some dialog items during upgrade (OK button,
+ services list)
+ */
+ m_Ok.EnableWindow(FALSE);
+ m_Services.EnableWindow(FALSE);
+ m_SelectAll.EnableWindow(FALSE);
+ m_ClearAll.EnableWindow(FALSE);
+
+ /*
+ Temporarily repurpose IniFileLabel/IniFilePath and
+ DatDirLabel/DataDir controls to show progress messages.
+ */
+ m_VersionLabel.ShowWindow(FALSE);
+ m_Version.ShowWindow(FALSE);
+ m_Progress.ShowWindow(TRUE);
+ m_IniFileLabel.SetWindowText("Converting service:");
+ m_IniFilePath.SetWindowText("");
+ m_DataDirLabel.SetWindowText("Progress message:");
+ m_DataDir.SetWindowText("");
+
+
+ m_ProgressTotal=0;
+ for(int i=0; i< m_Services.GetCount(); i++)
+ {
+ if(m_Services.GetCheck(i))
+ m_ProgressTotal++;
+ }
+ m_ProgressCurrent=0;
+ for(int i=0; i< m_Services.GetCount(); i++)
+ {
+ if(m_Services.GetCheck(i))
+ {
+ m_IniFilePath.SetWindowText(services[i].servicename.c_str());
+ m_Services.SelectString(0, services[i].servicename.c_str());
+ UpgradeOneService(services[i].servicename);
+ m_ProgressCurrent++;
+ }
+ }
+
+ MessageBox("Service(s) successfully upgraded", "Success",
+ MB_ICONINFORMATION);
+
+ /* Rebuild services list */
+ vector<ServiceProperties> new_instances;
+ for(int i=0; i< m_Services.GetCount(); i++)
+ {
+ if(!m_Services.GetCheck(i))
+ new_instances.push_back(services[i]);
+ }
+
+ services= new_instances;
+ m_Services.ResetContent();
+ for(size_t i=0; i< services.size();i++)
+ m_Services.AddString(services[i].servicename.c_str());
+ if(services.size())
+ {
+ m_Services.SelectString(0,services[0].servicename.c_str());
+ SelectService(0);
+ }
+ else
+ {
+ /* Nothing to do, there are no upgradable services */
+ exit(0);
+ }
+
+ /*
+ Restore controls that were temporarily repurposed for
+ progress info to their normal state
+ */
+ m_IniFileLabel.SetWindowText("Configuration file:");
+ m_DataDirLabel.SetWindowText("Data Directory:");
+ m_VersionLabel.ShowWindow(TRUE);
+ m_Version.ShowWindow(TRUE);
+ m_Progress.SetPos(0);
+ m_Progress.ShowWindow(FALSE);
+
+ /* Re-enable controls */
+ m_Ok.EnableWindow(TRUE);
+ m_Services.EnableWindow(TRUE);
+ m_SelectAll.EnableWindow(TRUE);
+ m_ClearAll.EnableWindow(TRUE);
+
+ m_UpgradeRunning= FALSE;
+}
+
+
+/* Thread procedure for upgrade services operation */
+static UINT UpgradeServicesThread(void *param)
+{
+ CUpgradeDlg *dlg= (CUpgradeDlg *)param;
+ dlg->UpgradeServices();
+ return 0;
+}
+
+
+/*
+ Do upgrade for all services currently selected
+ in the list. Since it is a potentially lengthy operation that
+ might block it has to be done in a background thread.
+*/
+void CUpgradeDlg::OnBnClickedOk()
+{
+ if(m_UpgradeRunning)
+ return;
+ m_UpgradeRunning= TRUE;
+ AfxBeginThread(UpgradeServicesThread, this);
+}
+
+
+/*
+ Cancel button clicked.
+ If upgrade is running, suspend mysql_upgrade_service,
+ and ask user whether he really wants to stop.Terminate
+ upgrade wizard and all subprocesses if users wants it.
+
+ If upgrade is not running, terminate the Wizard
+*/
+void CUpgradeDlg::OnBnClickedCancel()
+{
+ if(m_UpgradeRunning)
+ {
+ bool suspended = (SuspendThread(hChildThread) != (DWORD)-1);
+ int ret = MessageBox(
+ "Upgrade is in progress. Are you sure you want to terminate?",
+ 0, MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION);
+ if(ret != IDYES)
+ {
+ if(suspended)
+ ResumeThread(hChildThread);
+ return;
+ }
+ }
+ TerminateJobObject(m_JobObject, 1);
+ exit(1);
+}
+
+/*
+ Select all services from the list
+*/
+void CUpgradeDlg::OnBnSelectAll()
+{
+ for(int i=0; i < m_Services.GetCount(); i++)
+ m_Services.SetCheck(i, 1);
+ m_Ok.EnableWindow(TRUE);
+}
+
+/*
+ Clear all services in the list
+*/
+void CUpgradeDlg::OnBnClearAll()
+{
+ for(int i=0; i < m_Services.GetCount(); i++)
+ m_Services.SetCheck(i, 0);
+ m_Ok.EnableWindow(FALSE);
+}
diff --git a/win/upgrade_wizard/upgradeDlg.h b/win/upgrade_wizard/upgradeDlg.h
new file mode 100644
index 00000000..636f9489
--- /dev/null
+++ b/win/upgrade_wizard/upgradeDlg.h
@@ -0,0 +1,73 @@
+
+// upgradeDlg.h : header file
+//
+
+#pragma once
+#include "afxcmn.h"
+#include "afxwin.h"
+#include <string>
+
+
+// CUpgradeDlg dialog
+class CUpgradeDlg : public CDialog
+{
+ // Construction
+public:
+ CUpgradeDlg(CWnd* pParent = NULL); // standard constructor
+
+ // Dialog Data
+ enum { IDD = IDD_UPGRADE_DIALOG };
+
+protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+
+ // job object for current process and children
+ HANDLE m_JobObject;
+
+ // Services are being upgraded
+ BOOL m_UpgradeRunning;
+
+ // ProgressBar related: number of services to upgrade
+ int m_ProgressTotal;
+
+ //ProgressBar related: current service being upgraded
+ int m_ProgressCurrent;
+
+protected:
+ HICON m_hIcon;
+
+ // Generated message map functions
+ virtual BOOL OnInitDialog();
+ void PopulateServicesList();
+ afx_msg void OnPaint();
+ afx_msg HCURSOR OnQueryDragIcon();
+ DECLARE_MESSAGE_MAP()
+public:
+ void SelectService(int index);
+ void UpgradeServices();
+ void UpgradeOneService(const std::string& name);
+ void ErrorExit(const char *);
+ std::string m_InstallDir;
+ CCheckListBox m_Services;
+ CProgressCtrl m_Progress;
+ CButton m_Ok;
+ CButton m_Cancel;
+ CButton m_SelectAll;
+ CButton m_ClearAll;
+ int m_MajorVersion;
+ int m_MinorVersion;
+ int m_PatchVersion;
+
+ CEdit m_IniFilePath;
+ afx_msg void OnLbnSelchangeList1();
+ afx_msg void OnChkChange();
+ CEdit m_DataDir;
+ CEdit m_Version;
+ afx_msg void OnBnClickedOk();
+ afx_msg void OnBnClickedCancel();
+ afx_msg void OnBnSelectAll();
+ afx_msg void OnBnClearAll();
+ CEdit m_IniFileLabel;
+ CEdit m_DataDirLabel;
+ CEdit m_VersionLabel;
+};
diff --git a/win/upgrade_wizard/upgrade_wizard.exe.manifest b/win/upgrade_wizard/upgrade_wizard.exe.manifest
new file mode 100644
index 00000000..ca89deae
--- /dev/null
+++ b/win/upgrade_wizard/upgrade_wizard.exe.manifest
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel>
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
+ </dependentAssembly>
+ </dependency>
+</assembly> \ No newline at end of file