summaryrefslogtreecommitdiff
path: root/win
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2011-01-29 19:06:50 +0100
committerVladislav Vaintroub <wlad@montyprogram.com>2011-01-29 19:06:50 +0100
commite353bc80f721fc415ab2977f503878d69b43e63e (patch)
tree78b70b20ed5a3b60bf1d12dd981c99667ebcdb3b /win
parente15f914813e1b3da2d0098715a1df2612191a49d (diff)
downloadmariadb-git-e353bc80f721fc415ab2977f503878d69b43e63e.tar.gz
MWL#55 : implement MSI installer
The general technique to generate MSI using CMake is taken from MySQL 5.5 Additional features not present in 5.5 installer : -optionally creating a new database (as Windows service), using new mysql_install_db.exe to do the job - optional upgrade of existing services from old MySQL or Maria installation. This work is actually done by the upgrade wizard that is launched at the end of installation.
Diffstat (limited to 'win')
-rw-r--r--win/packaging/CMakeLists.txt134
-rw-r--r--win/packaging/COPYING.rtf61
-rw-r--r--win/packaging/CPackWixConfig.cmake114
-rw-r--r--win/packaging/ca/CMakeLists.txt50
-rw-r--r--win/packaging/ca/CustomAction.cpp726
-rw-r--r--win/packaging/ca/CustomAction.def9
-rw-r--r--win/packaging/ca/CustomAction.rc18
-rw-r--r--win/packaging/create_msi.cmake.in419
-rw-r--r--win/packaging/custom_ui.wxs183
-rw-r--r--win/packaging/extra.wxs.in642
-rw-r--r--win/packaging/mysql_server.wxs.in85
11 files changed, 2441 insertions, 0 deletions
diff --git a/win/packaging/CMakeLists.txt b/win/packaging/CMakeLists.txt
new file mode 100644
index 00000000000..67d22b15ab9
--- /dev/null
+++ b/win/packaging/CMakeLists.txt
@@ -0,0 +1,134 @@
+# 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-1301 USA
+
+IF(NOT WIN32)
+ RETURN()
+ENDIF()
+
+SET(MANUFACTURER "Monty Program AB")
+FIND_PATH(WIX_DIR heat.exe
+ $ENV{WIX_DIR}/bin
+ $ENV{ProgramFiles}/wix/bin
+ "$ENV{ProgramFiles}/Windows Installer XML v3/bin"
+ "$ENV{ProgramFiles}/Windows Installer XML v3.5/bin"
+)
+
+SET(CPACK_WIX_PACKAGE_BASE_NAME "MariaDB")
+IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ SET(CPACK_WIX_UPGRADE_CODE "49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3")
+ SET(CPACK_WIX_PACKAGE_NAME "MariaDB @MAJOR_VERSION@.@MINOR_VERSION@")
+ELSE()
+ SET(CPACK_WIX_UPGRADE_CODE "2331E7BD-EE58-431B-9E18-B2B918BCEB1B")
+ SET(CPACK_WIX_PACKAGE_NAME "MariaDB @MAJOR_VERSION@.@MINOR_VERSION@ (x64)")
+ENDIF()
+
+
+IF(NOT WIX_DIR)
+ IF(NOT _WIX_DIR_CHECKED)
+ SET(_WIX_DIR_CHECKED 1 CACHE INTERNAL "")
+ MESSAGE(STATUS "Cannot find wix 3, installer project will not be generated")
+ ENDIF()
+ RETURN()
+ENDIF()
+
+ADD_SUBDIRECTORY(ca)
+
+# extra.wxs.in needs DATADIR_MYSQL_FILES and DATADIR_PERFORMANCE_SCHEMA_FILES, i.e
+# Wix-compatible file lists for ${builddir}\sql\data\{mysql,performance_schema}
+
+FOREACH(dir mysql performance_schema)
+ FILE(GLOB files ${CMAKE_BINARY_DIR}/sql/data/${dir}/*)
+ SET(filelist)
+ FOREACH(f ${files})
+ IF(NOT f MATCHES ".rule")
+ FILE(TO_NATIVE_PATH "${f}" file_native_path)
+ GET_FILENAME_COMPONENT(file_name "${f}" NAME)
+ SET(filelist
+"${filelist}
+<File Id='${file_name}' Source='${file_native_path}'/>")
+ ENDIF()
+ ENDFOREACH()
+ STRING(TOUPPER ${dir} DIR_UPPER)
+ SET(DATADIR_${DIR_UPPER}_FILES "${filelist}")
+ENDFOREACH()
+
+
+FIND_PROGRAM(CANDLE_EXECUTABLE candle ${WIX_DIR})
+FIND_PROGRAM(LIGHT_EXECUTABLE light ${WIX_DIR})
+
+# 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()
+GET_TARGET_PROPERTY(WIXCA_LOCATION wixca LOCATION)
+SET(CPACK_WIX_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/CPackWixConfig.cmake)
+
+GET_TARGET_PROPERTY(upgrade_wizard_location upgrade_wizard LOCATION)
+IF(NOT upgrade_wizard_location)
+ SET(EXTRA_WIX_PREPROCESSOR_FLAGS "-dHaveUpgradeWizard=0")
+ENDIF()
+
+IF(NOT CPACK_WIX_UI)
+ SET(CPACK_WIX_UI "MyWixUI_Mondo")
+ENDIF()
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/create_msi.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake
+ @ONLY)
+
+
+IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ SET(WixWin64 " Win64='yes'")
+ELSE()
+ SET(WixWin64)
+ENDIF()
+
+
+IF(CMAKE_GENERATOR MATCHES "Visual Studio")
+ SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}")
+ENDIF()
+
+
+ADD_CUSTOM_TARGET(
+ MSI
+ COMMAND set VS_UNICODE_OUTPUT=
+ COMMAND ${CMAKE_COMMAND}
+ ${CONFIG_PARAM}
+ -P ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake
+)
+ADD_DEPENDENCIES(MSI wixca)
+
+ADD_CUSTOM_TARGET(
+ MSI_ESSENTIALS
+ COMMAND set VS_UNICODE_OUTPUT=
+ COMMAND ${CMAKE_COMMAND} -DESSENTIALS=1
+ ${CONFIG_PARAM}
+ -P ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake
+)
+ADD_DEPENDENCIES(MSI_ESSENTIALS wixca)
+
diff --git a/win/packaging/COPYING.rtf b/win/packaging/COPYING.rtf
new file mode 100644
index 00000000000..de1f0bbefde
--- /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. 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 00000000000..34f661b393e
--- /dev/null
+++ b/win/packaging/CPackWixConfig.cmake
@@ -0,0 +1,114 @@
+
+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;Embedded;Debuginfo;Documentation;IniFiles;Readme;Server_Scripts;scripts;DebugBinaries")
+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")
+
+# 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 "Data Files"
+ SET(CPACK_COMPONENT_DATAFILES_GROUP "MySQLServer")
+ SET(CPACK_COMPONENT_DATAFILES_DISPLAY_NAME "Server data files")
+ SET(CPACK_COMPONENT_DATAFILES_DESCRIPTION "Server data files" )
+ SET(CPACK_COMPONENT_DATAFILES_HIDDEN 1)
+
+
+#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/ca/CMakeLists.txt b/win/packaging/ca/CMakeLists.txt
new file mode 100644
index 00000000000..d09fae1918c
--- /dev/null
+++ b/win/packaging/ca/CMakeLists.txt
@@ -0,0 +1,50 @@
+# 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-1301 USA
+
+INCLUDE_DIRECTORIES(${WIX_DIR}/../SDK/inc)
+LINK_DIRECTORIES(${WIX_DIR}/../SDK/lib)
+
+SET(WIXCA_SOURCES CustomAction.cpp CustomAction.def)
+
+
+IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ SET(WIX_ARCH_SUFFIX "_x64")
+ELSE()
+ SET(WIX_ARCH_SUFFIX)
+ENDIF()
+
+IF(MSVC_VERSION EQUAL 1400)
+ SET(WIX35_MSVC_SUFFIX "_2005")
+ELSEIF(MSVC_VERSION EQUAL 1500)
+ SET(WIX35_MSVC_SUFFIX "_2008")
+ELSEIF(MSVC_VERSION EQUAL 1600)
+ SET(WIX35_MSVC_SUFFIX "_2010")
+ELSE()
+ # When next VS is out, add the correct version here
+ MESSAGE(FATAL_ERROR "Unknown VS version")
+ENDIF()
+
+FIND_LIBRARY(WIX_WCAUTIL_LIBRARY
+ NAMES wcautil${WIX_ARCH_SUFFIX} wcautil${WIX35_MSVC_SUFFIX}${WIX_ARCH_SUFFIX}
+ HINTS ${WIX_DIR}/../SDK/lib)
+
+FIND_LIBRARY(WIX_DUTIL_LIBRARY
+ NAMES dutil${WIX_ARCH_SUFFIX} dutil${WIX35_MSVC_SUFFIX}${WIX_ARCH_SUFFIX}
+ PATHS ${WIX_DIR}/../SDK/lib)
+
+ADD_VERSION_INFO(wixca SHARED WIXCA_SOURCES)
+ADD_LIBRARY(wixca SHARED EXCLUDE_FROM_ALL ${WIXCA_SOURCES})
+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 00000000000..1910aa4c1d3
--- /dev/null
+++ b/win/packaging/ca/CustomAction.cpp
@@ -0,0 +1,726 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef UNICODE
+#define UNICODE
+#endif
+
+#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>
+
+
+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;
+
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ ExitOnFailure(hr, "Failed to initialize");
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
+
+ wchar_t dir[MAX_PATH];
+ DWORD len = MAX_PATH;
+ MsiGetPropertyW(hInstall, L"CustomActionData", dir, &len);
+
+ er= ExecRemoveDataDirectory(dir);
+ WcaLog(LOGMSG_STANDARD, "SHFileOperation returned %d", er);
+LExit:
+ return WcaFinalize(er);
+}
+
+/* Check for if directory is empty during install, sets "<PROPERTY>_NOT_EMPTY" otherise */
+extern "C" UINT __stdcall CheckDirectoryEmpty(MSIHANDLE hInstall, const wchar_t *PropertyName)
+{
+ HRESULT hr = S_OK;
+ UINT er = ERROR_SUCCESS;
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ ExitOnFailure(hr, "Failed to initialize");
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
+
+
+ wchar_t buf[MAX_PATH];
+ DWORD len = MAX_PATH;
+ MsiGetPropertyW(hInstall, PropertyName, buf, &len);
+ wcscat_s(buf, MAX_PATH, L"*.*");
+
+ WcaLog(LOGMSG_STANDARD, "Checking files in %S", buf);
+ WIN32_FIND_DATAW data;
+ HANDLE h;
+ bool empty;
+ h= FindFirstFile(buf, &data);
+ if (h != INVALID_HANDLE_VALUE)
+ {
+ empty= true;
+ for(;;)
+ {
+ if (wcscmp(data.cFileName, L".") || wcscmp(data.cFileName, L".."))
+ {
+ empty= false;
+ break;
+ }
+ if (!FindNextFile(h, &data))
+ break;
+ }
+ FindClose(h);
+ }
+ else
+ {
+ /* Non-existent directory, we handle it as empty */
+ empty = true;
+ }
+
+ if(empty)
+ WcaLog(LOGMSG_STANDARD, "Directory %S is empty or non-existent", PropertyName);
+ else
+ WcaLog(LOGMSG_STANDARD, "Directory %S is NOT empty", PropertyName);
+
+ wcscpy_s(buf, MAX_PATH, PropertyName);
+ wcscat_s(buf, L"NOTEMPTY");
+ WcaSetProperty(buf, empty? L"":L"1");
+
+LExit:
+ return WcaFinalize(er);
+}
+
+extern "C" UINT __stdcall CheckDataDirectoryEmpty(MSIHANDLE hInstall)
+{
+ return CheckDirectoryEmpty(hInstall, L"DATADIR");
+}
+
+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;
+}
+
+/*
+ Check if port is free by trying to bind to the port
+*/
+bool IsPortFree(short port)
+{
+ WORD wVersionRequested;
+ WSADATA wsaData;
+
+ wVersionRequested = MAKEWORD(2, 2);
+
+ WSAStartup(wVersionRequested, &wsaData);
+
+ struct sockaddr_in sin;
+ SOCKET sock;
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ if(sock == -1)
+ {
+ return false;
+ }
+ sin.sin_port = htons(port);
+ sin.sin_addr.s_addr = 0;
+ sin.sin_addr.s_addr = INADDR_ANY;
+ sin.sin_family = AF_INET;
+ if(bind(sock, (struct sockaddr *)&sin,sizeof(struct sockaddr_in) ) == -1)
+ {
+ return false;
+ }
+ closesocket(sock);
+ WSACleanup();
+ return true;
+}
+
+
+/*
+ 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 retained.
+*/
+
+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);
+ WcaLog(LOGMSG_VERBOSE, "CommandLine= %S", commandline);
+ if(!argv || !argv[0] || ! wcsstr(argv[0], L"mysqld"))
+ {
+ goto end;
+ }
+
+ WcaLog(LOGMSG_STANDARD, "MySQL service %S found: CommandLine= %S", other_servicename, commandline);
+ if (wcsstr(argv[0], bindir))
+ {
+ WcaLog(LOGMSG_STANDARD, "executable under bin directory");
+ same_bindir = true;
+ }
+
+ bool 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;
+ }
+
+ wchar_t current_datadir_buf[MAX_PATH]={0};
+ wchar_t normalized_current_datadir[MAX_PATH+1];
+ wchar_t *current_datadir= current_datadir_buf;
+ wchar_t *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 possible 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;
+
+ 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");
+ }
+
+ BOOL 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);
+}
+
+
+
+extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
+{
+ wchar_t ServiceName[MAX_PATH]={0};
+ wchar_t SkipNetworking[MAX_PATH]={0};
+ wchar_t Port[6];
+ DWORD PortLen=6;
+ bool haveInvalidPort=false;
+ const wchar_t *ErrorMsg=0;
+
+ DWORD ServiceNameLen = MAX_PATH;
+ MsiGetPropertyW (hInstall, L"SERVICENAME", ServiceName, &ServiceNameLen);
+ if(ServiceName[0])
+ {
+ if(ServiceNameLen > 256)
+ {
+ ErrorMsg= L"Invalid service name. The maximum length is 256 characters.";
+ goto err;
+ }
+ 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 err;
+ }
+ }
+ if(CheckServiceExists(ServiceName))
+ {
+ ErrorMsg= L"A service with the same name already exists. Please use a different name.";
+ goto err;
+ }
+ }
+
+ DWORD SkipNetworkingLen= MAX_PATH;
+
+ 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 err;
+ }
+
+ short port = (short)_wtoi(Port);
+ if (!IsPortFree(port))
+ {
+ ErrorMsg = L"The TCP Port you selected is already in use. Please choose a different port.";
+ goto err;
+ }
+ }
+
+err:
+ MsiSetPropertyW (hInstall, L"WarningText", ErrorMsg);
+ return ERROR_SUCCESS;
+}
+
+/* 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;
+
+ hr = WcaInitialize(hInstall, __FUNCTION__);
+ ExitOnFailure(hr, "Failed to initialize");
+ WcaLog(LOGMSG_STANDARD, "Initialized.");
+ wchar_t data[2*MAX_PATH];
+ DWORD len= MAX_PATH;
+ 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)
+ {
+ ExecRemoveDataDirectory(dir);
+ }
+LExit:
+ return WcaFinalize(er);
+}
+
+/*
+ Extract major and minor version from
+ mysqld.exe, using commandline in service definition
+*/
+static void GetMySQLVersion(
+ wchar_t *cmdline,
+ wchar_t *programBuf,
+ bool *isMySQL, int *major, int *minor)
+{
+ *major= 0;
+ *minor= 0;
+ *isMySQL= false;
+ int argc;
+ wchar_t **wargv = CommandLineToArgvW(cmdline, &argc);
+ if(argc != 3)
+ return;
+
+ wchar_t path[MAX_PATH];
+ wchar_t *filepart;
+
+ wcscpy_s(programBuf, MAX_PATH, wargv[0]);
+ if(!wcsstr(programBuf, L".exe"))
+ wcscat_s(programBuf,MAX_PATH, L".exe");
+
+ GetFullPathNameW(programBuf,MAX_PATH, path, &filepart);
+ if(wcsicmp(filepart, L"mysqld.exe") == 0)
+ {
+ *isMySQL = true;
+ DWORD handle;
+ DWORD size = GetFileVersionInfoSizeW(path, &handle);
+ BYTE* versionInfo = new BYTE[size];
+ if (GetFileVersionInfo(path, handle, size, versionInfo))
+ {
+ UINT len = 0;
+ VS_FIXEDFILEINFO* vsfi = NULL;
+ VerQueryValueW(versionInfo, L"\\", (void**)&vsfi, &len);
+ *major= HIWORD(vsfi->dwFileVersionMS);
+ *minor= LOWORD(vsfi->dwFileVersionMS);
+ }
+ delete[] versionInfo;
+ }
+}
+
+
+/*
+ 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* service= 0;
+ wchar_t* dir= 0;
+ wchar_t installerVersion[MAX_VERSION_PROPERTY_SIZE];
+ wchar_t installDir[MAX_PATH];
+ DWORD size =MAX_VERSION_PROPERTY_SIZE;
+ int installerMajorVersion, installerMinorVersion, installerPatchVersion;
+ bool upgradableServiceFound=false;
+
+ 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 (MsiGetPropertyW(hInstall,L"INSTALLDIR", installDir, &size)
+ != ERROR_SUCCESS)
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ ExitOnFailure(hr, "MsiGetPropertyW failed");
+ }
+
+
+ SC_HANDLE 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];
+
+ 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)
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ ExitOnFailure(hr,"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 *)config_buffer;
+ DWORD needed;
+ BOOL ok= QueryServiceConfigW(service, config,sizeof(config_buffer), &needed);
+ CloseServiceHandle(service);
+ if (ok)
+ {
+ bool isMySQL;
+ int major;
+ int minor;
+ wchar_t program[MAX_PATH]={0};
+ GetMySQLVersion(config->lpBinaryPathName, program, &isMySQL, &major, &minor);
+
+ /*
+ Only look for services that have mysqld.exe outside of the current
+ installation directory.
+ */
+ if(isMySQL && (wcsstr(program,installDir) == 0))
+ {
+ WcaLog(LOGMSG_STANDARD, "found service %S, major=%d, minor=%d",
+ info[i].lpServiceName, major, minor);
+ if(major < installerMajorVersion
+ || (major == installerMajorVersion && 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"");
+ }
+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 00000000000..f625d48ae2c
--- /dev/null
+++ b/win/packaging/ca/CustomAction.def
@@ -0,0 +1,9 @@
+LIBRARY "wixca"
+VERSION 1.0
+EXPORTS
+RemoveDataDirectory
+CreateDatabaseRollback
+CheckDatabaseProperties
+CheckDataDirectoryEmpty
+CheckDBInUse
+CheckServiceUpgrades
diff --git a/win/packaging/ca/CustomAction.rc b/win/packaging/ca/CustomAction.rc
new file mode 100644
index 00000000000..3f37126ee77
--- /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.in b/win/packaging/create_msi.cmake.in
new file mode 100644
index 00000000000..6f13546cc37
--- /dev/null
+++ b/win/packaging/create_msi.cmake.in
@@ -0,0 +1,419 @@
+SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@")
+SET(CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
+SET(CANDLE_EXECUTABLE "@CANDLE_EXECUTABLE@")
+SET(LIGHT_EXECUTABLE "@LIGHT_EXECUTABLE@")
+SET(CMAKE_COMMAND "@CMAKE_COMMAND@")
+SET(CMAKE_CFG_INTDIR "@CMAKE_CFG_INTDIR@")
+SET(VERSION "@VERSION@")
+SET(MAJOR_VERSION "@MAJOR_VERSION@")
+SET(MINOR_VERSION "@MINOR_VERSION@")
+SET(PATCH_VERSION "@PATCH@")
+SET(CMAKE_SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@)
+SET(MANUFACTURER "@MANUFACTURER@")
+SET(WIXCA_LOCATION "@WIXCA_LOCATION@")
+SET(COPYING_RTF "@COPYING_RTF@")
+SET(CPACK_WIX_CONFIG "@CPACK_WIX_CONFIG@")
+SET(CPACK_WIX_INCLUDE "@CPACK_WIX_INCLUDE@")
+SET(CPACK_WIX_UPGRADE_CODE "@CPACK_WIX_UPGRADE_CODE@")
+SET(CPACK_WIX_PACKAGE_NAME "@CPACK_WIX_PACKAGE_NAME@")
+SET(CPACK_WIX_PACKAGE_BASE_NAME "@CPACK_WIX_PACKAGE_BASE_NAME@")
+SET(SIGNCODE "@SIGNCODE@")
+SET(SIGNTOOL_EXECUTABLE "@SIGNTOOL_EXECUTABLE@")
+SET(SIGNTOOL_PARAMETERS "@SIGNTOOL_PARAMETERS@")
+SET(SIGNCODE_ENABLED "@SIGNCODE_ENABLED@")
+SET(CMAKE_FULL_VER
+ "@CMAKE_MAJOR_VERSION@.@CMAKE_MINOR_VERSION@.@CMAKE_PATCH_VERSION@")
+SET(EXTRA_WIX_PREPROCESSOR_FLAGS "@EXTRA_WIX_PREPROCESSOR_FLAGS@")
+
+
+
+IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ SET(CANDLE_ARCH -arch x64)
+ SET(Win64 " Win64='yes'")
+ SET(Platform x64)
+ SET(PlatformProgramFilesFolder ProgramFiles64Folder)
+ELSE()
+ SET(CANDLE_ARCH -arch x86)
+ SET(Platform x86)
+ SET(PlatformProgramFilesFolder ProgramFilesFolder)
+ SET(Win64)
+ENDIF()
+
+SET(ENV{VS_UNICODE_OUTPUT})
+# Workaround for CMake bug#11452
+# Switch off the monolithic install
+EXECUTE_PROCESS(
+ COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=0 ${CMAKE_BINARY_DIR}
+ OUTPUT_QUIET
+)
+
+
+INCLUDE(${CMAKE_BINARY_DIR}/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 ${CMAKE_BINARY_DIR}/cmake_install.cmake
+ OUTPUT_QUIET
+
+ )
+ # Exclude empty install components
+ SET(INCLUDE_THIS_COMPONENT 1)
+ SET(MANIFEST_FILENAME "${CMAKE_BINARY_DIR}/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()
+ IF(CPACK_COMPONENT_${c_upper}_HIDDEN)
+ SET(CPACK_WIX_FEATURES
+ "${CPACK_WIX_FEATURES}
+ <ComponentGroupRef Id='componentgroup.${c}'/>")
+ ELSE()
+ SET(CPACK_WIX_FEATURES
+ "${CPACK_WIX_FEATURES}
+ <Feature Id='${c}'
+ Title='${TITLE}'
+ Description='${DESCRIPTION}'
+ ConfigurableDirectory='INSTALLDIR'
+ AllowAdvertise='no'
+ Level='${Level}'>
+ <ComponentGroupRef Id='componentgroup.${c}'/>
+ </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()
+
+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()
+
+
+
+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(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}'")
+ 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 AND 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()
+ FILE(GLOB all_files ${dir}/*)
+ FOREACH(f ${all_files})
+ IF(IS_DIRECTORY ${f})
+ TRAVERSE_DIRECTORIES(${f} ${topdir} ${file} "${prefix} ")
+ ENDIF()
+ ENDFOREACH()
+ IF(rel AND IS_DIRECTORY "${f}")
+ FILE(APPEND ${file} "${prefix}</Directory>\n")
+ 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)
+ 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(${CMAKE_CURRENT_SOURCE_DIR}/mysql_server.wxs.in
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql_server.wxs)
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/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)
+EXECUTE_PROCESS(
+ COMMAND ${CANDLE_EXECUTABLE}
+ ${EXTRA_WIX_PREPROCESSOR_FLAGS}
+ ${CANDLE_ARCH}
+ -ext WixUtilExtension
+ -ext WixFirewallExtension
+ mysql_server.wxs
+ ${EXTRA_CANDLE_ARGS}
+)
+
+EXECUTE_PROCESS(
+ COMMAND ${CANDLE_EXECUTABLE} ${CANDLE_ARCH}
+ ${EXTRA_WIX_PREPROCESSOR_FLAGS}
+ -ext WixUtilExtension
+ -ext WixFirewallExtension
+ ${CMAKE_CURRENT_BINARY_DIR}/extra.wxs
+ ${EXTRA_CANDLE_ARGS}
+)
+
+EXECUTE_PROCESS(
+ COMMAND ${LIGHT_EXECUTABLE} -ext WixUIExtension -ext WixUtilExtension
+ -ext WixFirewallExtension
+ mysql_server.wixobj extra.wixobj -out ${CPACK_PACKAGE_FILE_NAME}.msi
+ ${EXTRA_LIGHT_ARGS}
+)
+
+IF(SIGNCODE AND SIGNCODE_ENABLED)
+ EXECUTE_PROCESS(
+ COMMAND ${SIGNTOOL_EXECUTABLE} sign ${SIGNTOOL_PARAMETERS}
+ ${CPACK_PACKAGE_FILE_NAME}.msi
+)
+ENDIF()
+CONFIGURE_FILE(${CPACK_PACKAGE_FILE_NAME}.msi
+ ${CMAKE_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME}.msi
+ COPYONLY)
+
+# Workaround for CMake bug#11452
+# Switch monolithic install on again
+EXECUTE_PROCESS(
+ COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=1 ${CMAKE_BINARY_DIR}
+ OUTPUT_QUIET
+)
+
diff --git a/win/packaging/custom_ui.wxs b/win/packaging/custom_ui.wxs
new file mode 100644
index 00000000000..8a87fb4d246
--- /dev/null
+++ b/win/packaging/custom_ui.wxs
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+ <Fragment>
+ <Property Id="PortTemplate" Value="####" />
+ <Property Id="PORT" Value="3306"></Property>
+ <Property Id="MSIRESTARTMANAGERCONTROL" Value="Disable"/>
+ <Property Id="CREATEDBINSTANCE"><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Property>
+ <UI>
+ <Dialog Id="DatabaseCreationDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
+ <Control Id="ServiceNameLabel" Type="Text" X="20" Y="73" Width="70" Height="15" TabSkip="no" Text="Service Name:" />
+ <Control Id="ServiceName" Type="Edit" X="90" Y="73" Width="120" Height="15" Property="SERVICENAME" Text="{20}" />
+
+ <Control Id="RootPasswordLabel" Type="Text" X="20" Y="90" Width="120" Height="15" TabSkip="no" Text="&amp;Root password:" />
+ <Control Id="RootPassword" Type="Edit" X="20" Y="105" Width="120" Height="18" Property="ROOT_PASSWORD" Password="yes" Text="{20}" />
+
+ <Control Id="RootPasswordConfirmLabel" Type="Text" X="150" Y="90" Width="150" Height="15" TabSkip="no" Text="&amp;Confirm Root password:" />
+ <Control Id="RootPasswordConfirm" Type="Edit" X="150" Y="105" Width="120" Height="18" Property="ROOT_PASSWORD_CONFIRM" Password="yes" Text="{20}" />
+ <Control Id="BannerLine0" Type="Line" X="0" Y="128" Width="370" Height="0" />
+
+ <Control Id="PortLabel" Type="Text" X="20" Y="137" Width="40" Height="15" TabSkip="no" Text="TCP port:" />
+
+ <Control Id="Port" Type="MaskedEdit" X="60" Y="136" Width="30" Height="15" Property="PORT" Text="[PortTemplate]"/>
+ <!--<Control Id="FirewallExceptionCheckBox" Type="CheckBox" X="150" Y="136" Height="15" Property="FIREWALL_EXCEPTION" Width="200" CheckBoxValue="1"
+ Text="Create Firewall exception for this port"/>-->
+
+ <Control Id="BannerLine2" Type="Line" X="0" Y="155" Width="370" Height="0" />
+
+ <Control Id="FolderLabel" Type="Text" X="20" Y="181" Width="100" Height="15" TabSkip="no" Text="Database location:" />
+ <Control Id="Folder" Type="PathEdit" X="20" Y="204" Width="200" Height="18" Property="DATABASELOCATION" Indirect="no" />
+
+ <!-- Navigation buttons-->
+ <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" Default="yes" Text="&amp;Next">
+ <!--
+ <Publish Event="ValidateProductID" Value="0">1</Publish>
+ <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
+ -->
+ <!--<Publish Event="NewDialog" Value="SetupTypeDlg">ProductID</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 default [ProductName] 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}Default instance properties</Text>
+ </Control>
+ <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
+ </Dialog>
+
+ <Dialog Id="ConfirmDataCleanupDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
+ <Control Id="ServiceRemoveText" Type="Text" X="20" Y="73" Width="300" Height="15" TabSkip="no">
+ <Text>Service '[SERVICENAME]' will be removed</Text>
+ </Control>
+ <Control Id="CleanupDataCheckBox" Type="CheckBox" X="20" Y="100" Height="15" Property="CLEANUP_DATA" Width="15" CheckBoxValue="0"/>
+ <Control Id="RemoveDataText" Type="Text" X="37" Y="101" Width="300" Height="200" TabSkip="no">
+ <Text>Remove default database directory '[DATABASELOCATION]'</Text>
+ </Control>
+
+ <!-- Navigation buttons-->
+ <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" Default="yes" Text="&amp;Next">
+ <Publish Event="NewDialog" Value="VerifyReadyDlg">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>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>
+ </UI>
+ <UI Id="MyWixUI_Mondo">
+ <UIRef Id="WixUI_FeatureTree" />
+ <UIRef Id="WixUI_ErrorProgressText" />
+ <DialogRef Id="DatabaseCreationDlg" />
+ <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="DatabaseCreationDlg" Order="999"><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Publish>
+ <Publish Dialog="DatabaseCreationDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="3">1</Publish>
+ <Publish Dialog="DatabaseCreationDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="3">1</Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="DatabaseCreationDlg" Order="3" ><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="3" ><![CDATA[(&DBInstance=2) AND (!DBInstance=3)]]></Publish>
+ <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="999"><![CDATA[(&DBInstance=2) AND (!DBInstance=3)]]></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</Publish>
+ <Publish Dialog="ConfirmDataCleanupDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg">WixUI_InstallMode = "Remove"</Publish>
+ </UI>
+
+ <DirectoryRef Id='TARGETDIR'>
+ <Directory Id="CommonAppDataFolder">
+ <Directory Id="DatabasesRoot" Name="MariaDB">
+ <Directory Id="DATABASELOCATION" Name="MariaDB Server 5.1">
+ </Directory>
+ </Directory>
+ </Directory>
+ </DirectoryRef>
+
+ <Feature Id='DBInstance'
+ Title='Database instance'
+ Description='Install database instance'
+ ConfigurableDirectory='DATABASELOCATION'
+ AllowAdvertise='no'
+ Level='1'>
+ <Component Id="C.datadir" Guid="*" Directory="DATABASELOCATION">
+ <RegistryValue Root='HKLM'
+ Key='SOFTWARE\[Manufacturer]\[ProductName]'
+ Name='DatabaseLocation' Value='[DATABASELOCATION]' Type='string' KeyPath='yes'/>
+ <CreateFolder />
+ </Component>
+ <Component Id="C.service" Guid="*" Directory="DATABASELOCATION">
+ <Condition>SERVICENAME</Condition>
+ <RegistryValue Root='HKLM'
+ Key='SOFTWARE\[Manufacturer]\[ProductName]'
+ Name='ServiceName' Value='[SERVICENAME]' Type='string' KeyPath='yes'/>
+ <ServiceControl Id='DBInstanceServiceStop' Name='[SERVICENAME]' Stop='uninstall' Wait='yes'></ServiceControl>
+ <ServiceControl Id='DBInstanceServiceStart' Name='[SERVICENAME]' Start='install' Wait='no'></ServiceControl>
+ <ServiceControl Id='DBInstanceServiceRemove' Name='[SERVICENAME]' Remove='uninstall' Wait='yes'></ServiceControl>
+ </Component>
+ </Feature>
+
+ <CustomAction Id="QtExecDeferredExampleWithProperty_Cmd" Property="QtExecDeferredExampleWithProperty"
+ Value="&quot;[#F.bin.mysql_install_db.exe]&quot; &quot;--service=[SERVICENAME]&quot; &quot;--password=[ROOT_PASSWORD]&quot; &quot;--datadir=[DATABASELOCATION]&quot;"
+ Execute="immediate"/>
+ <CustomAction Id="QtExecDeferredExampleWithProperty" BinaryKey="WixCA" DllEntry="CAQuietExec"
+ Execute="deferred" Return="check" Impersonate="no"/>
+
+ <UI>
+ <ProgressText Action="QtExecDeferredExampleWithProperty">Running mysql_install_db.exe</ProgressText>
+ </UI>
+
+ <!-- Use Wix toolset "remember property" pattern to store properties between major upgrades etc -->
+ <InstallExecuteSequence>
+ <Custom Action="QtExecDeferredExampleWithProperty_Cmd" After="CostFinalize"><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Custom>
+ <Custom Action="QtExecDeferredExampleWithProperty" After="InstallFiles"><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Custom>
+ </InstallExecuteSequence>
+
+ <Property Id='SERVICENAME'>
+ <RegistrySearch Id='ServiceNameProperty' Root='HKLM'
+ Key='SOFTWARE\[Manufacturer]\[ProductName]'
+ Name='ServiceName' Type='raw' />
+ </Property>
+ <SetProperty After='AppSearch' Id="SERVICENAME" Value="MariaDB_51"><![CDATA[NOT SERVICENAME]]></SetProperty>
+ <Property Id="DATABASELOCATION">
+ <RegistrySearch Id='DatabaseLocationProperty' Root='HKLM'
+ Key='SOFTWARE\[Manufacturer]\[ProductName]'
+ Name='´DatabaseLocation' Type='raw' />
+ </Property>
+ <SetProperty After='AppSearch' Id="DATABASELOCATION" Value="[CommonAppDataFolder]\MariaDB\[ProductName]"><![CDATA[NOT DATABASELOCATION]]></SetProperty>
+ <CustomAction Id='SaveCmdLineValue_SERVICENAME' Property='CMDLINE_SERVICENAME'
+ Value='[SERVICENAME]' Execute='firstSequence' />
+ <CustomAction Id='SetFromCmdLineValue_SERVICENAME' Property='SERVICENAME' Value='[CMDLINE_SERVICENAME]' Execute='firstSequence' />
+ <CustomAction Id='SaveCmdLineValue_DATABASELOCATION' Property='CMDLINE_DATABASELOCATION'
+ Value='[DATABASELOCATION]' Execute='firstSequence' />
+ <CustomAction Id='SetFromCmdLineValue_DATABASELOCATION' Property='DATABASELOCATION' Value='[CMDLINE_DATABASELOCATION]' Execute='firstSequence' />
+
+ <InstallUISequence>
+ <Custom Action='SaveCmdLineValue_SERVICENAME' Before='AppSearch' />
+ <Custom Action='SetFromCmdLineValue_SERVICENAME' After='AppSearch'>CMDLINE_SERVICENAME</Custom>
+ <Custom Action='SaveCmdLineValue_DATABASELOCATION' Before='AppSearch' />
+ <Custom Action='SetFromCmdLineValue_DATABASELOCATION' After='AppSearch'>CMDLINE_DATABASELOCATION</Custom>
+ </InstallUISequence>
+ <InstallExecuteSequence>
+ <Custom Action='SaveCmdLineValue_SERVICENAME' Before='AppSearch' />
+ <Custom Action='SetFromCmdLineValue_SERVICENAME' After='AppSearch'>CMDLINE_SERVICENAME</Custom>
+ <Custom Action='SaveCmdLineValue_DATABASELOCATION' Before='AppSearch' />
+ <Custom Action='SetFromCmdLineValue_DATABASELOCATION' After='AppSearch'>CMDLINE_DATABASELOCATION</Custom>
+ </InstallExecuteSequence>
+ </Fragment>
+</Wix> \ No newline at end of file
diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in
new file mode 100644
index 00000000000..f2488f20b7c
--- /dev/null
+++ b/win/packaging/extra.wxs.in
@@ -0,0 +1,642 @@
+<?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>
+ <Property Id="PortTemplate" Value="#####" />
+
+ <!--
+ 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" />
+ <!-- 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"/>
+ <!-- Whether to data on uninstall (default yes, after asking user consent) -->
+ <Property Id="CLEANUPDATA" Secure="yes" Value="1"/>
+
+
+ <!--
+ User interface dialogs
+ -->
+ <WixVariable Id='WixUIBannerBmp' Value='@CMAKE_CURRENT_SOURCE_DIR@\WixUIBannerBmp.jpg' />
+ <WixVariable Id='WixUIDialogBmp' Value='@CMAKE_CURRENT_SOURCE_DIR@\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="20">
+ <Text>Remove default database directory [DATADIR]. Ensures proper cleanup on uninstall.</Text>
+ </Control>
+
+ <Control Id="KeepDatadirButton" Type="PushButton" X="40" Y="118" 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="138" 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>
+
+ <!-- Error popup dialog -->
+ <Dialog Id="WarningDlg" Width="320" Height="85" Title="[ProductName] Setup" NoMinimize="yes">
+ <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 root password</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 root access from remote machines</Text>
+ <Condition Action="enable">ModifyRootPassword</Condition>
+ <Condition Action="disable">NOT ModifyRootPassword</Condition>
+ </Control>
+
+ <Control Id="CheckBoxCreateDefaultUser" Type="CheckBox" X="8" Y="154" Width="200" Height="18" Property="DEFAULTUSER"
+ CheckBoxValue="--default-user" TabSkip="no">
+ <Text>{\Font1}Create An Anonymous Account</Text>
+ </Control>
+ <Control Id="Text14" Type="Text" X="21" Y="174" Width="268" Height="16" TabSkip="yes">
+ <Text>This option will create an anonymous account on this server. </Text>
+ </Control>
+ <Control Id="Text13" Type="Text" X="21" Y="190" Width="254" Height="24" TabSkip="yes">
+ <Text>Please note: this setting can lead to insecure systems.</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">1</Publish>
+ </Control>
+ <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
+ <Publish Property="WarningText" Value="Passwords do not match."><![CDATA[PASSWORD <> RootPasswordConfirm]]></Publish>
+ <Publish Event="SpawnDialog" Value="WarningDlg"><![CDATA[WarningText <>""]]></Publish>
+ <Publish Property="SERVICENAME" Value="MySQL">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>
+ <!-- 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="CheckDataDirectoryEmpty" BinaryKey="wixca.dll" DllEntry="CheckDataDirectoryEmpty" 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="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="Next" Event="DoAction" Value="CheckDataDirectoryEmpty" Order="1"><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Publish>
+ <Publish Dialog="CustomizeDlg" Property="DATADIRNOTEMPTY" Control="Next" Order="1"><![CDATA[NOT(&DBInstance=3 AND NOT !DBInstance=3)]]></Publish>
+ <Publish Dialog="CustomizeDlg" Control="Next" Property="WarningText" Order="2"
+ Value="Selected data directory [DATADIR] is not empty. Either clean it, or choose another location for 'Database Instance' feature.">
+ DATADIRNOTEMPTY
+ </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\@MANUFACTURER@\@CPACK_WIX_PACKAGE_NAME@'
+ Name='DATADIR' Value='[DATADIR]' Type='string' KeyPath='yes'/>
+ <CreateFolder>
+ <util:PermissionEx User="[LogonUser]" GenericAll="yes" />
+ <util:PermissionEx User="NetworkService" 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\@MANUFACTURER@\@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>
+
+ <!--- Grant service account permission to the database folder (Windows 7 and later) -->
+ <Component Id="C.serviceaccount.permission" Guid="*" Directory='DATADIR' Transitive='yes'>
+ <Condition><![CDATA[SERVICENAME AND (VersionNT > 600)]]></Condition>
+ <RegistryValue Root='HKLM'
+ Key='SOFTWARE\@MANUFACTURER@\@CPACK_WIX_PACKAGE_NAME@'
+ Name='servicepermission' Value='1' Type='string' KeyPath='yes'/>
+ <CreateFolder>
+ <util:PermissionEx User="NT SERVICE\[SERVICENAME]" GenericAll="yes" />
+ </CreateFolder>
+ </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'>
+ <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>
+ </Feature>
+
+ <!-- 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="CreateDatabaseCommand" Property="CreateDatabase"
+ Value=
+ "&quot;[#F.bin.mysql_install_db.exe]&quot; &quot;--service=[SERVICENAME]&quot; --port=[PORT] &quot;--password=[PASSWORD]&quot; &quot;--datadir=[DATADIR]\&quot; [SKIPNETWORKING] [ALLOWREMOTEROOTACCESS] [DEFAULTUSER]"
+ Execute="immediate"
+ HideTarget="yes"
+ />
+ <CustomAction Id="CreateDatabaseRollbackCommand" Property="CreateDatabaseRollback"
+ Value="[SERVICENAME]\[DATADIR]"
+ Execute="immediate"/>
+ <CustomAction Id="CreateDatabase" BinaryKey="WixCA" DllEntry="CAQuietExec"
+ 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 mysql_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='ErrorDataDirNotEmpty'
+ Error='Chosen data directory [DATADIR] is not empty. It must be empty prior to installation.'/>
+ <InstallExecuteSequence>
+ <Custom Action="CheckDataDirectoryEmpty" After="CostFinalize">
+ <![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]>
+ </Custom>
+ <Custom Action="ErrorDataDirNotEmpty" After="CheckDataDirectoryEmpty" >DATADIRNOTEMPTY</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>
+ </InstallExecuteSequence>
+ <InstallUISequence>
+ <Custom Action="CheckDBInUse" Before="LaunchConditions">Installed</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\@MANUFACTURER@\@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\@MANUFACTURER@\@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.
+ -->
+
+ <!--
+ 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 $(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="1"/>
+ <Property Id="WixShellExecTarget" Value="[#F.bin.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" Before="ExecuteAction">
+ $C.bin.upgrade_wizard.exe = 3 AND NOT Installed
+ </Custom>
+ </InstallUISequence>
+ <SetProperty Before="ExecuteAction" Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT"
+ Sequence="ui" Value="[NonExistentProperty]">
+ <![CDATA[($C.bin.upgrade_wizard.exe <> 3) AND NOT Installed]]>
+ </SetProperty>
+ <SetProperty Before="ExecuteAction" Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX"
+ Sequence="ui" Value="[NonExistentProperty]">
+ <![CDATA[($C.bin.upgrade_wizard.exe <> 3) AND NOT Installed]]>
+ </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"/>
+ <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>
+
+ <!-- Extra condition to block the installer if NSIS based installation is detected-->
+ <Property Id="NSISINSTALLKEY">
+ <RegistrySearch Id='NSISKey' Type='raw'
+ Root='HKLM' Key='Software\Microsoft\Windows\CurrentVersion\Uninstall\MariaDB' Name='DisplayName' />
+ </Property>
+ <Condition
+ Message=
+ 'Previous version of MariaDB was found, that used incompatible installer.&#xD;&#xA;Please remove &quot;[NSISINSTALLKEY]&quot; before you proceed with this installation.'
+ >
+ NOT NSISINSTALLKEY OR Installed
+ </Condition>
+ </Fragment>
+</Wix>
diff --git a/win/packaging/mysql_server.wxs.in b/win/packaging/mysql_server.wxs.in
new file mode 100644
index 00000000000..4874e65a00b
--- /dev/null
+++ b/win/packaging/mysql_server.wxs.in
@@ -0,0 +1,85 @@
+<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@"
+ Language="1033"
+ Manufacturer="@MANUFACTURER@">
+
+ <Package Id='*'
+ Keywords='Installer'
+ Description='MariaDB Server'
+ Manufacturer='@MANUFACTURER@'
+ InstallerVersion='200'
+ Languages='1033'
+ Compressed='yes'
+ SummaryCodepage='1252'
+ Platform='@Platform@'/>
+
+ <Media Id='1' Cabinet='product.cab' EmbedCab='yes' CompressionLevel='high' />
+
+ <!-- Upgrade -->
+ <Upgrade Id="@CPACK_WIX_UPGRADE_CODE@">
+ <UpgradeVersion
+ Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.0"
+ IncludeMinimum="yes"
+ Maximum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@"
+ Property="OLDERVERSIONBEINGUPGRADED"
+ MigrateFeatures="yes"
+ />
+ <UpgradeVersion
+ Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@"
+ Maximum="@MAJOR_VERSION@.@MINOR_VERSION@.999"
+ 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>