Commit 75625f56 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

merge mwl#55

parents 2f957915 41d43246
......@@ -17,25 +17,57 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
IF(COMMAND cmake_policy)
cmake_policy(SET CMP0005 NEW)
ENDIF(COMMAND cmake_policy)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/win/cmake)
PROJECT(MySql)
include(package_name)
include(mysql_version)
include(mysql_add_executable)
include(install_macros)
include(install_layout)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)
# Hardcode WITH_XXX_STORAGE_ENGINE to ON for storage engines that go into the
# distributable package, this is temporary solution to get rid of configure.js stuff,
# 5.5 will handle it more nicely.
SET(WITH_ARCHIVE_STORAGE_ENGINE 1 CACHE BOOL "Include archive storage engine")
SET(WITH_BLACKHOLE_STORAGE_ENGINE 1 CACHE BOOL "Include blockhole storage engine")
SET(WITH_FEDERATEDX_STORAGE_ENGINE 1 CACHE BOOL "Include federatedx storage engine")
SET(WITH_PARTITION_STORAGE_ENGINE 1 CACHE BOOL "Include partition storage engine")
SET(WITH_ARIA_STORAGE_ENGINE 1 CACHE BOOL "Include aria storage engine")
SET(WITH_PBXT_STORAGE_ENGINE 1 CACHE BOOL "Include pbxt storage engine")
SET(WITH_XTRADB_STORAGE_ENGINE 1 CACHE BOOL "Include xtradb storage engine")
IF(WIN32)
LINK_LIBRARIES(ws2_32)
# This reads user configuration, generated by configure.js.
INCLUDE(win/configure.data OPTIONAL)
ENDIF()
IF(BUILD_RELEASE)
MESSAGE("Building release package")
ENDIF()
# This reads user configuration, generated by configure.js.
INCLUDE(win/configure.data)
# Hardcode support for CSV storage engine
SET(WITH_CSV_STORAGE_ENGINE TRUE)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY)
${CMAKE_BINARY_DIR}/include/mysql_version.h @ONLY)
# Speed up multiprocessor build
IF (MSVC_VERSION GREATER 1400)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ENDIF()
SET(CMAKE_INSTALL_PREFIX "C:/MariaDB${MYSQL_BASE_VERSION}")
SET(INSTALL_ROOT "${CMAKE_INSTALL_PREFIX}")
# Set standard options
ADD_DEFINITIONS(-DHAVE_YASSL)
ADD_DEFINITIONS(-DCMAKE_CONFIGD)
ADD_DEFINITIONS(-DDEFAULT_MYSQL_HOME="c:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}/")
ADD_DEFINITIONS(-DDEFAULT_BASEDIR="c:/Program Files/MySQL/")
ADD_DEFINITIONS(-DMYSQL_DATADIR="c:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}/data")
ADD_DEFINITIONS(-DDEFAULT_CHARSET_HOME="c:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}/")
ADD_DEFINITIONS(-DDEFAULT_MYSQL_HOME="${INSTALL_ROOT}")
ADD_DEFINITIONS(-DDEFAULT_BASEDIR="${INSTALL_ROOT}")
ADD_DEFINITIONS(-DMYSQL_DATADIR="data")
ADD_DEFINITIONS(-DDEFAULT_CHARSET_HOME="${INSTALL_ROOT}")
ADD_DEFINITIONS(-DPACKAGE=mysql)
ADD_DEFINITIONS(-DSHAREDIR="share")
ADD_DEFINITIONS(-DPLUGINDIR="lib/plugin")
......@@ -45,15 +77,15 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFORCE_INIT_OF_VARS")
SET(localstatedir "C:\\\\mysql\\\\data\\\\")
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-huge.cnf.sh
${CMAKE_SOURCE_DIR}/support-files/my-huge.ini @ONLY)
${CMAKE_BINARY_DIR}/support-files/my-huge.ini @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-innodb-heavy-4G.cnf.sh
${CMAKE_SOURCE_DIR}/support-files/my-innodb-heavy-4G.ini @ONLY)
${CMAKE_BINARY_DIR}/support-files/my-innodb-heavy-4G.ini @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-large.cnf.sh
${CMAKE_SOURCE_DIR}/support-files/my-large.ini @ONLY)
${CMAKE_BINARY_DIR}/support-files/my-large.ini @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-medium.cnf.sh
${CMAKE_SOURCE_DIR}/support-files/my-medium.ini @ONLY)
${CMAKE_BINARY_DIR}/support-files/my-medium.ini @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-small.cnf.sh
${CMAKE_SOURCE_DIR}/support-files/my-small.ini @ONLY)
${CMAKE_BINARY_DIR}/support-files/my-small.ini @ONLY)
ADD_DEFINITIONS(-D__NT__)
......@@ -302,7 +334,7 @@ ADD_DEFINITIONS(${STORAGE_ENGINE_DEFS})
# Now write out our mysql_plugin_defs struct
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc @ONLY)
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc @ONLY)
# Add subdirectories for storage engines
SET (ENGINE_BUILD_TYPE "STATIC")
......@@ -329,12 +361,14 @@ ADD_SUBDIRECTORY(extra/yassl)
ADD_SUBDIRECTORY(extra/yassl/taocrypt)
ADD_SUBDIRECTORY(extra/libevent)
ADD_SUBDIRECTORY(extra)
ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(sql)
ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(server-tools/instance-manager)
ADD_SUBDIRECTORY(libmysql)
ADD_SUBDIRECTORY(libservices)
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(mysql-test)
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(unittest/mytap)
ADD_SUBDIRECTORY(unittest/mysys)
IF(WITH_EMBEDDED_SERVER)
......@@ -342,126 +376,31 @@ IF(WITH_EMBEDDED_SERVER)
ADD_SUBDIRECTORY(libmysqld/examples)
ENDIF(WITH_EMBEDDED_SERVER)
ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)
IF(WIN32)
ADD_SUBDIRECTORY(win/upgrade_wizard)
ADD_SUBDIRECTORY(win/packaging)
ENDIF()
# Set up the installer
SET(CPACK_PACKAGE_NAME "MariaDB")
STRING(REPLACE "-MariaDB" "" CPACK_PACKAGE_VERSION ${VERSION})
SET(CPACK_PACKAGE_VENDOR "Monty Program AB http://www.montyprogram.com")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MariaDB")
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING)
SET(CPACK_GENERATOR NSIS)
# Use our own NSIS template
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/win/cmake" ${CMAKE_MODULE_PATH})
# Installer components and grouping
SET(CPACK_COMPONENT_GROUP_SERVER_DESCRIPTION "The files necessary for running the MariaDB server.")
SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION "Files used in development on the MariaDB server.")
SET(CPACK_ALL_INSTALL_TYPES Normal Development)
SET(CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "MariaDB server")
SET(CPACK_COMPONENT_RUNTIME_DESCRIPTION "The server itself. You want to install this one.")
SET(CPACK_COMPONENT_RUNTIME_GROUP "Server")
SET(CPACK_COMPONENT_RUNTIME_INSTALL_TYPES Normal Development)
SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Development headers")
SET(CPACK_COMPONENT_HEADERS_DESCRIPTION "Header files for development on MariaDB.")
SET(CPACK_COMPONENT_HEADERS_DEPENDS runtime)
SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Development)
SET(CPACK_COMPONENT_EMBEDDED_DISPLAY_NAME "Embedded")
SET(CPACK_COMPONENT_EMBEDDED_DESCRIPTION "Files for embedding MariaDB in other projects.")
SET(CPACK_COMPONENT_EMBEDDED_DEPENDS headers)
SET(CPACK_COMPONENT_EMBEDDED_GROUP "Development")
SET(CPACK_COMPONENT_EMBEDDED_INSTALL_TYPES Development)
SET(CPACK_COMPONENT_SCRIPTS_DISPLAY_NAME "Server scripts")
SET(CPACK_COMPONENT_SCRIPTS_DESCRIPTION "SQL and Perl scripts to control and modify the server. You need a perl installation for some of these to work.")
SET(CPACK_COMPONENT_SCRIPTS_DEPENDS runtime)
SET(CPACK_COMPONENT_SCRIPTS_GROUP "Server")
SET(CPACK_COMPONENT_SCRIPTS_INSTALL_TYPES Normal Development)
SET(CPACK_COMPONENT_MYSQLTEST_DISPLAY_NAME "MariaDB test suite")
SET(CPACK_COMPONENT_MYSQLTEST_DESCRIPTION "The MariaDB regression test suite.")
SET(CPACK_COMPONENT_MYSQLTEST_DEPENDS runtime)
SET(CPACK_COMPONENT_MYSQLTEST_GROUP "Testing")
SET(CPACK_COMPONENT_MYSQLTEST_INSTALL_TYPES Normal Development)
SET(CPACK_COMPONENT_SQLBENCH_DISPLAY_NAME "SQL Bench")
SET(CPACK_COMPONENT_SQLBENCH_DESCRIPTION "The MariaDB benchmark suite.")
SET(CPACK_COMPONENT_SQLBENCH_DEPENDS runtime)
SET(CPACK_COMPONENT_SQLBENCH_GROUP "Testing")
SET(CPACK_COMPONENT_SQLBENCH_INSTALL_TYPES Normal Development)
# Add files to the installer
INSTALL(FILES COPYING EXCEPTIONS-CLIENT DESTINATION .)
INSTALL(FILES support-files/my-huge.ini support-files/my-innodb-heavy-4G.ini DESTINATION .)
INSTALL(FILES support-files/my-large.ini support-files/my-medium.ini DESTINATION .)
INSTALL(FILES support-files/my-small.ini DESTINATION .)
INSTALL(FILES Docs/INSTALL-BINARY DESTINATION Docs)
INSTALL(FILES COPYING DESTINATION Docs)
FILE(GLOB headerfiles "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
INSTALL(FILES ${headerfiles} DESTINATION include COMPONENT headers)
INSTALL(FILES include/mysql/plugin.h DESTINATION include/mysql COMPONENT headers)
INSTALL(FILES libmysql/libmysql.def DESTINATION include COMPONENT headers)
# Handle the database files
FILE(GLOB datafiles "${CMAKE_CURRENT_SOURCE_DIR}/win/data/mysql/*")
INSTALL(FILES ${datafiles} DESTINATION data/clean/mysql)
INSTALL(FILES win/data/aria_log.00000001 win/data/aria_log_control DESTINATION data/clean)
INSTALL(DIRECTORY win/data/test DESTINATION data/clean)
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}
IfFileExists '$INSTDIR\\\\data\\\\mysql\\\\db.frm' 0 CopyDatabaseFiles
MessageBox MB_OK 'There are already database files present in the data directory. Clean database files are not written to the directory'
GoTo EndCopyDatabaseFiles
CopyDatabaseFiles:
CopyFiles '$INSTDIR\\\\data\\\\clean\\\\*' '$INSTDIR\\\\data'
EndCopyDatabaseFiles:")
SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS}
MessageBox MB_OK 'This will not delete the database files in $INSTDIR\\\\data'")
# Files in the share dir
INSTALL(FILES sql/share/errmsg.txt DESTINATION share COMPONENT runtime)
FILE(GLOB charsets sql/share/charsets/*)
INSTALL(FILES ${charsets} DESTINATION share/charsets COMPONENT runtime)
FILE(GLOB share_dirs sql/share/*/errmsg.sys)
FOREACH(ERRMSGFILE ${share_dirs})
STRING(REPLACE "//" "/" ERRMSGFILE ${ERRMSGFILE}) # Work around a cmake bug
FILE(RELATIVE_PATH DIRNAME ${PROJECT_SOURCE_DIR}/sql/share ${ERRMSGFILE})
STRING(REPLACE "/errmsg.sys" "" DIRNAME ${DIRNAME})
INSTALL(FILES ${ERRMSGFILE} DESTINATION share/${DIRNAME} COMPONENT runtime)
ENDFOREACH(ERRMSGFILE ${share_dirs})
# MTR files
FILE(GLOB_RECURSE testfiles mysql-test/*)
FOREACH(testfile ${testfiles})
FILE(RELATIVE_PATH dirname ${PROJECT_SOURCE_DIR} ${testfile})
GET_FILENAME_COMPONENT(dirname ${dirname} PATH)
GET_FILENAME_COMPONENT(filename ${testfile} NAME)
GET_FILENAME_COMPONENT(ext ${testfile} EXT)
SET(ok "yes")
IF (NOT "x_${ext}" STREQUAL "x_")
# Test if this is one of the extensions we don't want to install
STRING(TOLOWER ${ext} ext)
IF(${ext} STREQUAL ".dir" OR ${ext} STREQUAL ".vcproj" OR ${ext} STREQUAL ".user" OR ${ext} STREQUAL ".ilk"
OR ${ext} STREQUAL ".idb" OR ${ext} STREQUAL ".map" OR ${ext} STREQUAL ".gcov"
OR ${ext} STREQUAL ".supp" OR ${ext} STREQUAL ".am" OR ${ext} STREQUAL ".stress")
SET(ok "no")
ENDIF()
ENDIF(NOT "x_${ext}" STREQUAL "x_")
IF (${ok} STREQUAL "yes")
# Message("Dir: ${dirname}. File: ${filename}. Ext: ${ext}")
INSTALL(FILES ${testfile} DESTINATION ${dirname} COMPONENT mysqltest)
ENDIF(${ok} STREQUAL "yes")
ENDFOREACH(testfile ${testfiles})
# SQL Bench
FILE(GLOB_RECURSE benchfiles sql-bench/*)
FOREACH(testfile ${testfiles})
FILE(RELATIVE_PATH dirname ${PROJECT_SOURCE_DIR} ${testfile})
GET_FILENAME_COMPONENT(dirname ${dirname} PATH)
GET_FILENAME_COMPONENT(filename ${testfile} NAME)
IF(NOT ${dirname} STREQUAL "sql-bench" OR ${filename} STREQUAL "README")
INSTALL(FILES ${testfile} DESTINATION ${dirname} COMPONENT sqlbench)
ENDIF()
ENDFOREACH(testfile ${testfiles})
INCLUDE(InstallRequiredSystemLibraries)
IF(WIN32)
SET(CPACK_GENERATOR "ZIP")
ENDIF()
INSTALL(FILES
${CMAKE_BINARY_DIR}/support-files/my-huge.ini
${CMAKE_BINARY_DIR}/support-files/my-large.ini
${CMAKE_BINARY_DIR}/support-files/my-medium.ini
${CMAKE_BINARY_DIR}/support-files/my-small.ini
DESTINATION .
COMPONENT IniFiles
)
INSTALL(FILES
COPYING
EXCEPTIONS-CLIENT
DESTINATION .
COMPONENT Readme
)
IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" STREQUAL "2.8.3")
# CMake bug#11452, only in 2.8.3
SET(CPACK_MONOLITHIC_INSTALL 1 CACHE INTERNAL "")
ENDIF()
# This must always be the last line
INCLUDE(CPack)
......@@ -25,63 +25,48 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/libmysql
${CMAKE_SOURCE_DIR}/regex
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/strings)
${CMAKE_SOURCE_DIR}/strings
${CMAKE_CURRENT_BINARY_DIR})
ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c)
MYSQL_ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c DESTINATION bin)
TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqltest mysqltest.cc)
MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc DESTINATION bin)
SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys regex wsock32 dbug)
ADD_EXECUTABLE(mysqlcheck mysqlcheck.c)
MYSQL_ADD_EXECUTABLE(mysqlcheck mysqlcheck.c DESTINATION bin)
TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c ../mysys/mf_getdate.c)
MYSQL_ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c ../mysys/mf_getdate.c DESTINATION bin)
TARGET_LINK_LIBRARIES(mysqldump mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqlimport mysqlimport.c)
MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c DESTINATION bin)
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c)
MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c DESTINATION bin)
TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient_notls wsock32)
ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs)
ADD_EXECUTABLE(mysqlshow mysqlshow.c)
MYSQL_ADD_EXECUTABLE(mysqlshow mysqlshow.c DESTINATION bin)
TARGET_LINK_LIBRARIES(mysqlshow mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc
MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc
../mysys/mf_tempdir.c
../mysys/my_new.cc
../mysys/my_bit.c
../mysys/my_bitmap.c
../mysys/my_vle.c
../mysys/base64.c)
../mysys/base64.c
DESTINATION bin)
TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqladmin mysqladmin.cc)
MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc DESTINATION bin)
TARGET_LINK_LIBRARIES(mysqladmin mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqlslap mysqlslap.c)
MYSQL_ADD_EXECUTABLE(mysqlslap mysqlslap.c DESTINATION bin)
SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib wsock32 dbug)
ADD_EXECUTABLE(echo echo.c)
IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("mysql" "asInvoker")
MYSQL_EMBED_MANIFEST("mysqltest" "asInvoker")
MYSQL_EMBED_MANIFEST("mysqlcheck" "asInvoker")
MYSQL_EMBED_MANIFEST("mysqldump" "asInvoker")
MYSQL_EMBED_MANIFEST("mysqlimport" "asInvoker")
MYSQL_EMBED_MANIFEST("mysql_upgrade" "asInvoker")
MYSQL_EMBED_MANIFEST("mysqlshow" "asInvoker")
MYSQL_EMBED_MANIFEST("mysqlbinlog" "asInvoker")
MYSQL_EMBED_MANIFEST("mysqladmin" "asInvoker")
MYSQL_EMBED_MANIFEST("echo" "asInvoker")
ENDIF(EMBED_MANIFESTS)
ADD_DEFINITIONS(-DHAVE_DLOPEN)
INSTALL(TARGETS mysql mysqltest mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow
mysqlbinlog mysqladmin mysqlslap echo DESTINATION bin COMPONENT runtime)
MYSQL_ADD_EXECUTABLE(echo echo.c COMPONENT Test)
......@@ -22,19 +22,19 @@ TARGET_LINK_LIBRARIES(comp_err debug dbug mysys strings zlib wsock32)
GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION)
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/include/mysqld_error.h
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/include/mysqld_error.h
COMMAND ${COMP_ERR_EXE}
--charset=${PROJECT_SOURCE_DIR}/sql/share/charsets
--out-dir=${PROJECT_SOURCE_DIR}/sql/share/
--header_file=${PROJECT_SOURCE_DIR}/include/mysqld_error.h
--name_file=${PROJECT_SOURCE_DIR}/include/mysqld_ername.h
--state_file=${PROJECT_SOURCE_DIR}/include/sql_state.h
--out-dir=${CMAKE_BINARY_DIR}/sql/share/
--header_file=${CMAKE_BINARY_DIR}/include/mysqld_error.h
--name_file=${CMAKE_BINARY_DIR}/include/mysqld_ername.h
--state_file=${CMAKE_BINARY_DIR}/include/sql_state.h
--in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt
DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt)
ADD_CUSTOM_TARGET(GenError
ALL
DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_error.h)
DEPENDS ${CMAKE_BINARY_DIR}/include/mysqld_error.h)
ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
TARGET_LINK_LIBRARIES(my_print_defaults strings mysys debug dbug taocrypt wsock32)
......@@ -48,8 +48,4 @@ TARGET_LINK_LIBRARIES(resolveip strings mysys debug dbug wsock32)
ADD_EXECUTABLE(replace replace.c)
TARGET_LINK_LIBRARIES(replace strings mysys debug dbug wsock32)
IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("myTest" "asInvoker")
ENDIF(EMBED_MANIFESTS)
INSTALL(TARGETS comp_err my_print_defaults perror resolveip replace DESTINATION bin COMPONENT runtime)
MYSQL_INSTALL_TARGETS(comp_err my_print_defaults perror resolveip replace DESTINATION bin COMPONENT Server)
......@@ -2,7 +2,9 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/extra/libevent
${CMAKE_SOURCE_DIR}/extra/libevent/compat
${CMAKE_SOURCE_DIR}/extra/libevent/WIN32-Code
${CMAKE_SOURCE_DIR}/include)
${CMAKE_BINARY_DIR}/extra/libevent
${CMAKE_SOURCE_DIR}/include
)
IF(MSVC)
ADD_DEFINITIONS("-DWIN32 -DHAVE_CONFIG_H")
......@@ -28,8 +30,14 @@ SET(LIBEVENT_SOURCES
min_heap.h
strlcpy-internal.h
)
IF(WIN32)
# Workaround source distribution bug, remove preconfigured event-config
IF(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
FILE(REMOVE ${CMAKE_SOURCE_DIR}/extra/libevent/event-config.h)
ENDIF()
CONFIGURE_FILE(WIN32-Code/config.h ${CMAKE_BINARY_DIR}/extra/libevent/event-config.h COPYONLY)
ENDIF()
CONFIGURE_FILE(WIN32-Code/config.h ${CMAKE_SOURCE_DIR}/extra/libevent/event-config.h COPYONLY)
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(libevent ${LIBEVENT_SOURCES})
ENDIF(NOT SOURCE_SUBLIBS)
# Copyright (c) 2006, 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
SET(HEADERS_GEN_CONFIGURE
${CMAKE_CURRENT_BINARY_DIR}/mysql_version.h
#${CMAKE_CURRENT_BINARY_DIR}/my_config.h
${CMAKE_CURRENT_BINARY_DIR}/mysqld_ername.h
${CMAKE_CURRENT_BINARY_DIR}/mysqld_error.h
${CMAKE_CURRENT_BINARY_DIR}/sql_state.h
)
SET(HEADERS_ABI
mysql.h
mysql_com.h
mysql_time.h
my_list.h
my_alloc.h
typelib.h
mysql/plugin.h
mysql/plugin_auth.h
mysql/client_plugin.h
)
SET(HEADERS
${HEADERS_ABI}
config-win.h
my_dbug.h
m_string.h
my_sys.h
my_xml.h
mysql_embed.h
my_pthread.h
my_no_pthread.h
decimal.h
errmsg.h
my_global.h
my_net.h
my_getopt.h
sslopt-longopts.h
my_dir.h
sslopt-vars.h
sslopt-case.h
sql_common.h
keycache.h
m_ctype.h
my_attribute.h
my_compiler.h
${HEADERS_GEN_CONFIGURE}
)
INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development)
INSTALL(DIRECTORY mysql/ DESTINATION ${INSTALL_INCLUDEDIR}/mysql COMPONENT Development FILES_MATCHING PATTERN "*.h" )
......@@ -46,7 +46,7 @@ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \
wqueue.h waiting_threads.h
EXTRA_DIST = mysql.h.pp mysql/plugin_auth.h.pp mysql/client_plugin.h.pp
EXTRA_DIST = mysql.h.pp mysql/plugin_auth.h.pp mysql/client_plugin.h.pp CMakeLists.txt
# Remove built files and the symlinked directories
CLEANFILES = $(BUILT_SOURCES) readline openssl
......
......@@ -124,14 +124,8 @@ ADD_DEPENDENCIES(libmysql GenError)
TARGET_LINK_LIBRARIES(libmysql wsock32)
ADD_DEFINITIONS(-DHAVE_DLOPEN)
IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("myTest" "asInvoker")
ENDIF(EMBED_MANIFESTS)
# TODO: Install mysqlclient_notls?
# TODO: Which component should these be part of, development?
INSTALL(TARGETS mysqlclient DESTINATION lib/opt COMPONENT runtime)
INSTALL(TARGETS libmysql DESTINATION lib/opt COMPONENT runtime)
# Also install libmysql.dll to the bin dir
INSTALL(TARGETS libmysql DESTINATION bin COMPONENT runtime)
INSTALL(TARGETS mysqlclient DESTINATION lib COMPONENT Development)
INSTALL_DEBUG_SYMBOLS(mysqlclient DESTINATION lib)
INSTALL(TARGETS libmysql DESTINATION lib COMPONENT SharedLibraries)
INSTALL_DEBUG_SYMBOLS(libmysql DESTINATION lib)
......@@ -28,14 +28,15 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/regex
${CMAKE_SOURCE_DIR}/extra/yassl/include
${CMAKE_SOURCE_DIR}/zlib)
${CMAKE_SOURCE_DIR}/zlib
${CMAKE_BINARY_DIR}/sql)
SET(GEN_SOURCES ${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc
${CMAKE_SOURCE_DIR}/sql/sql_yacc.h
SET(GEN_SOURCES ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
${CMAKE_BINARY_DIR}/sql/sql_yacc.h
${CMAKE_SOURCE_DIR}/sql/message.h
${CMAKE_SOURCE_DIR}/sql/message.rc
${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc
${CMAKE_SOURCE_DIR}/sql/lex_hash.h)
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
${CMAKE_BINARY_DIR}/sql/lex_hash.h)
SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED 1)
......@@ -97,7 +98,7 @@ ENDFOREACH(ENGINE_LIB)
SET(SOURCE_SUBLIBS FALSE)
SET(LIBMYSQLD_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
SET(LIBMYSQLD_SOURCES libmysqld.c emb_qcache.cc lib_sql.cc
../libmysql/libmysql.c ../libmysql/errmsg.c ../client/get_password.c
../sql-common/client.c ../sql-common/my_time.c
../sql-common/my_user.c ../sql-common/pack.c
......@@ -177,6 +178,9 @@ ADD_LIBRARY(libmysqld SHARED cmake_dummy.c libmysqld.def)
ADD_DEPENDENCIES(libmysqld mysqlserver)
TARGET_LINK_LIBRARIES(libmysqld mysqlserver wsock32)
INSTALL(TARGETS mysqlserver DESTINATION Embedded/static COMPONENT embedded)
INSTALL(TARGETS mysqlserver DESTINATION lib COMPONENT Embedded)
INSTALL_DEBUG_SYMBOLS(mysqlserver)
INSTALL_DEBUG_TARGET(mysqlserver DESTINATION lib/debug COMPONENT Embedded)
INSTALL(TARGETS libmysqld DESTINATION Embedded/DLL COMPONENT embedded)
INSTALL(TARGETS libmysqld DESTINATION lib COMPONENT Embedded)
INSTALL_DEBUG_SYMBOLS(libmysqld)
......@@ -26,16 +26,17 @@ ENDIF(WIN32)
ADD_DEFINITIONS(-DEMBEDDED_LIBRARY)
ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc
MYSQL_ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc
../../client/mysql.cc ../../client/readline.cc
../../client/sql_string.cc)
COMPONENT Test)
TARGET_LINK_LIBRARIES(mysql_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
TARGET_LINK_LIBRARIES(mysql_embedded libmysqld)
TARGET_LINK_LIBRARIES(mysql_embedded mysqlserver)
ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc)
MYSQL_ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc COMPONENT Test)
TARGET_LINK_LIBRARIES(mysqltest_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
TARGET_LINK_LIBRARIES(mysqltest_embedded libmysqld)
TARGET_LINK_LIBRARIES(mysqltest_embedded mysqlserver)
ADD_EXECUTABLE(mysql_client_test_embedded ../../tests/mysql_client_test.c)
MYSQL_ADD_EXECUTABLE(mysql_client_test_embedded ../../tests/mysql_client_test.c COMPONENT Test)
TARGET_LINK_LIBRARIES(mysql_client_test_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
TARGET_LINK_LIBRARIES(mysql_client_test_embedded libmysqld)
TARGET_LINK_LIBRARIES(mysql_client_test_embedded mysqlserver)
# Copyright (c) 2006, 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(INSTALL_MYSQLTESTDIR)
INSTALL(
DIRECTORY .
DESTINATION ${INSTALL_MYSQLTESTDIR}
USE_SOURCE_PERMISSIONS
COMPONENT Test
PATTERN "var/" EXCLUDE
PATTERN "lib/My/SafeProcess" EXCLUDE
PATTERN "lib/t*" EXCLUDE
PATTERN "CPack" EXCLUDE
PATTERN "CMake*" EXCLUDE
PATTERN "mtr.out*" EXCLUDE
PATTERN ".cvsignore" EXCLUDE
PATTERN "*.am" EXCLUDE
PATTERN "*.in" EXCLUDE
PATTERN "*.vcproj" EXCLUDE
PATTERN "*.vcxproj" EXCLUDE
PATTERN "*.vcxproj.*" EXCLUDE
)
ENDIF()
IF(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
# Enable running mtr from build directory
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/mtr.out-of-source
${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run.pl
@ONLY
)
ENDIF()
IF(UNIX)
EXECUTE_PROCESS(
COMMAND chmod +x mysql-test-run.pl
COMMAND ${CMAKE_COMMAND} -E create_symlink
./mysql-test-run.pl mtr
COMMAND ${CMAKE_COMMAND} -E create_symlink
./mysql-test-run.pl mysql-test-run
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
IF(INSTALL_MYSQLTESTDIR)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mtr
${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run
DESTINATION ${INSTALL_MYSQLTESTDIR}
COMPONENT Test)
ENDIF()
ENDIF()
IF(CMAKE_GENERATOR MATCHES "Visual Studio")
SET(SETCONFIG_COMMAND set MTR_VS_CONFIG=${CMAKE_CFG_INTDIR})
ELSEIF(CMAKE_GENERATOR MATCHES "Xcode")
SET(SETCONFIG_COMMAND export MTR_VS_CONFIG=${CMAKE_CFG_INTDIR})
ELSE()
SET(SETCONFIG_COMMAND echo Running tests)
ENDIF()
IF(CYGWIN)
# On cygwin, pretend to be "Unix" system
SET(SETOS_COMMAND export MTR_CYGWIN_IS_UNIX=1)
ELSE()
SET(SETOS_COMMAND echo OS=${CMAKE_SYSTEM_NAME})
ENDIF()
SET(EXP --experimental=collections/default.experimental)
IF(WIN32)
SET(SET_ENV set)
ELSE()
SET(SET_ENV export)
ENDIF()
SET(MTR_FORCE perl ./mysql-test-run.pl --force)
IF(EXISTS ${CMAKE_SOURCE_DIR}/mysql-test/suite/nist)
SET(TEST_NIST ${MTR_FORCE} --comment=nist suite=nist ${EXP} &&
${MTR_FORCE} --comment=nist --force --suite=nist+ps ${EXP})
ELSE()
SET(TEST_NIST echo "NIST tests not found")
ENDIF()
IF(WITH_EMBEDDED_SERVER)
SET(TEST_EMBEDDED ${MTR_FORCE} --comment=embedded --timer --embedded-server
--skip-rpl --skip-ndbcluster $(EXP))
ELSE()
SET(TEST_EMBEDDED echo "Can not test embedded, not compiled in")
ENDIF()
SET(TEST_BT_START
COMMAND ${SETCONFIG_COMMAND}
COMMAND ${SETOS_COMMAND}
COMMAND ${SET_ENV} MTR_BUILD_THREAD=auto
)
ADD_CUSTOM_TARGET(test-force
${TEST_BT_START}
COMMAND ${MTR_FORCE}
)
ADD_CUSTOM_TARGET(test-bt
${TEST_BT_START}
COMMAND ${MTR_FORCE} --comment=normal --timer --skip-ndbcluster --report-features ${EXP}
COMMAND ${MTR_FORCE} --comment=ps --timer --skip-ndbcluster --ps-protocol ${EXP}
COMMAND ${MTR_FORCE} --comment=funcs1+ps --ps-protocol --reorder --suite=funcs_1 ${EXP}
COMMAND ${MTR_FORCE} --comment=funcs2 --suite=funcs_2 ${EXP}
COMMAND ${MTR_FORCE} --comment=partitions --suite=parts ${EXP}
COMMAND ${MTR_FORCE} --comment=stress --suite=stress ${EXP}
COMMAND ${MTR_FORCE} --force --comment=jp --suite=jp ${EXP}
COMMAND ${TEST_NIST}
COMMAND ${TEST_EMBEDDED}
)
ADD_CUSTOM_TARGET(test-bt-fast
${TEST_BT_START}
COMMAND ${MTR_FORCE} --comment=ps --timer --skip-ndbcluster --ps-protocol --report-features ${EXP}
COMMAND ${MTR_FORCE} --comment=stress --suite=stress ${EXP}
)
ADD_CUSTOM_TARGET(test-bt-debug
${TEST_BT_START}
COMMAND ${MTR_FORCE} --comment=debug --timer --skip-ndbcluster --skip-rpl --report-features ${EXP}
)
......@@ -72,7 +72,9 @@ SUBDIRS = lib/My/SafeProcess
EXTRA_DIST = README README.suites \
$(test_SCRIPTS) \
$(nobase_test_DATA)
$(nobase_test_DATA) \
CMakeLists.txt \
mtr.out-of-source
# List of directories containing test + result files and the
# related test data files that should be copied
......@@ -109,7 +111,7 @@ TEST_DIRS = t r include std_data std_data/parts collections \
suite/innodb suite/innodb/t suite/innodb/r suite/innodb/include \
suite/innodb_plugin suite/innodb_plugin/t suite/innodb_plugin/r \
suite/innodb_plugin/include \
suite/handler \
suite/percona suite/handler \
suite/engines suite/engines/funcs suite/engines/iuds suite/engines/rr_trx \
suite/engines/funcs/r suite/engines/funcs/t suite/engines/iuds/r \
suite/engines/iuds/t suite/engines/rr_trx/include suite/engines/rr_trx/r \
......
......@@ -37,6 +37,15 @@ sub get_testdir {
return $testdir;
}
# Retrive build directory (which is different from basedir in out-of-source build)
sub get_bindir {
if (defined $ENV{MTR_BINDIR})
{
return $ENV{MTR_BINDIR};
}
my ($self, $group)= @_;
return $self->get_basedir($group);
}
sub fix_charset_dir {
my ($self, $config, $group_name, $group)= @_;
......@@ -46,7 +55,7 @@ sub fix_charset_dir {
sub fix_language {
my ($self, $config, $group_name, $group)= @_;
return my_find_dir($self->get_basedir($group),
return my_find_dir($self->get_bindir($group),
\@share_locations, "english");
}
......@@ -338,6 +347,7 @@ my @mysql_upgrade_rules=
sub post_check_client_group {
my ($self, $config, $client_group_name, $mysqld_group_name)= @_;
# Settings needed for client, copied from its "mysqld"
my %client_needs=
(
......@@ -347,7 +357,6 @@ sub post_check_client_group {
user => '#user',
password => '#password',
);
my $group_to_copy_from= $config->group($mysqld_group_name);
while (my ($name_to, $name_from)= each( %client_needs )) {
my $option= $group_to_copy_from->option($name_from);
......
......@@ -84,23 +84,34 @@ sub is_child {
my @safe_process_cmd;
my $safe_kill;
my $bindir;
if(defined $ENV{MTR_BINDIR})
{
# This is an out-of-source build. Build directory
# is given in MTR_BINDIR env.variable
$bindir = $ENV{MTR_BINDIR}."/mysql-test";
}
else
{
$bindir = ".";
}
# Find the safe process binary or script
sub find_bin {
if (IS_WIN32PERL or IS_CYGWIN)
{
# Use my_safe_process.exe
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
my $exe= my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
push(@safe_process_cmd, $exe);
# Use my_safe_kill.exe
$safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill");
$safe_kill= my_find_bin($bindir, "lib/My/SafeProcess", "my_safe_kill");
}
else
{
# Use my_safe_process
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
my $exe= my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
push(@safe_process_cmd, $exe);
}
......
# Copyright (C) 2006 MySQL AB
# Copyright (c) 2006, 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
......@@ -11,7 +11,18 @@
#
# 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
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
ADD_EXECUTABLE(my_safe_process safe_process_win.cc)
ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc)
SET(INSTALL_ARGS
DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess"
COMPONENT Test
)
IF (WIN32)
MYSQL_ADD_EXECUTABLE(my_safe_process safe_process_win.cc ${INSTALL_ARGS})
MYSQL_ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc ${INSTALL_ARGS})
ELSE()
MYSQL_ADD_EXECUTABLE(my_safe_process safe_process.cc ${INSTALL_ARGS})
ENDIF()
INSTALL(FILES safe_process.pl Base.pm DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess" COMPONENT Test)
#!/usr/bin/perl
# Call mtr in out-of-source build
$ENV{MTR_BINDIR} = "@CMAKE_BINARY_DIR@";
chdir("@CMAKE_SOURCE_DIR@/mysql-test");
exit(system($^X, "@CMAKE_SOURCE_DIR@/mysql-test/mysql-test-run.pl", @ARGV) >> 8);
\ No newline at end of file
......@@ -94,6 +94,7 @@ $SIG{INT}= sub { mtr_error("Got ^C signal"); };
our $mysql_version_id;
our $glob_mysql_test_dir;
our $basedir;
our $bindir;
our $path_charsetsdir;
our $path_client_bindir;
......@@ -515,7 +516,7 @@ sub run_test_server ($$$) {
my $completed= [];
my %running;
my $result;
my $exe_mysqld= find_mysqld($basedir) || ""; # Used as hint to CoreDump
my $exe_mysqld= find_mysqld($bindir) || ""; # Used as hint to CoreDump
my $suite_timeout= start_timer(suite_timeout());
......@@ -891,7 +892,7 @@ sub run_worker ($) {
$valgrind_reports= valgrind_exit_reports();
}
if ( $opt_gprof ) {
gprof_collect (find_mysqld($basedir), keys %gprof_dirs);
gprof_collect (find_mysqld($bindir), keys %gprof_dirs);
}
exit($valgrind_reports);
}
......@@ -1130,6 +1131,10 @@ sub command_line_setup {
$basedir= dirname($basedir);
}
# Respect MTR_BINDIR variable, which is typically set in to the
# build directory in out-of-source builds.
$bindir=$ENV{MTR_BINDIR}||$basedir;
fix_vs_config_dir();
# Look for the client binaries directory
......@@ -1140,21 +1145,25 @@ sub command_line_setup {
}
else
{
$path_client_bindir= mtr_path_exists("$basedir/client_release",
"$basedir/client_debug",
"$basedir/client$opt_vs_config",
"$basedir/client",
"$basedir/bin");
$path_client_bindir= mtr_path_exists("$bindir/client_release",
"$bindir/client_debug",
"$bindir/client$opt_vs_config",
"$bindir/client",
"$bindir/bin");
}
# Look for language files and charsetsdir, use same share
$path_language= mtr_path_exists("$basedir/share/mariadb/english",
"$basedir/share/mysql/english",
"$basedir/sql/share/english",
"$basedir/share/english");
$path_language= mtr_path_exists("$bindir/share/mariadb/english",
"$bindir/share/mysql/english",
"$bindir/sql/share/english",
"$bindir/share/english");
my $path_share= dirname($path_language);
$path_charsetsdir= mtr_path_exists("$path_share/charsets");
$path_charsetsdir= mtr_path_exists("$basedir/share/charsets",
"$basedir/share/mysql/charsets",
"$basedir/sql/share/charsets",
"$basedir/share/charsets");
if ( $opt_comment )
{
......@@ -1306,7 +1315,15 @@ sub command_line_setup {
# --------------------------------------------------------------------------
# Set the "var/" directory, the base for everything else
# --------------------------------------------------------------------------
$default_vardir= "$glob_mysql_test_dir/var";
if(defined $ENV{MTR_BINDIR})
{
$default_vardir= "$ENV{MTR_BINDIR}/mysql-test/var";
}
else
{
$default_vardir= "$glob_mysql_test_dir/var";
}
if ( ! $opt_vardir )
{
$opt_vardir= $default_vardir;
......@@ -1377,19 +1394,6 @@ sub command_line_setup {
# --------------------------------------------------------------------------
if ( $opt_embedded_server )
{
if ( IS_WINDOWS )
{
# Add the location for libmysqld.dll to the path.
my $separator= ";";
my $lib_mysqld=
mtr_path_exists("$basedir/libmysqld$opt_vs_config");
if ( IS_CYGWIN )
{
$lib_mysqld= posix_path($lib_mysqld);
$separator= ":";
}
$ENV{'PATH'}= "$ENV{'PATH'}".$separator.$lib_mysqld;
}
$opt_skip_ndbcluster= 1; # Turn off use of NDB cluster
$opt_skip_ssl= 1; # Turn off use of SSL
......@@ -1683,7 +1687,7 @@ sub collect_mysqld_features {
mtr_add_arg($args, "--user=root");
}
my $exe_mysqld= find_mysqld($basedir);
my $exe_mysqld= find_mysqld($bindir);
my $cmd= join(" ", $exe_mysqld, @$args);
my $list= `$cmd`;
......@@ -1808,7 +1812,7 @@ sub find_mysqld {
unshift(@mysqld_names, "mysqld-debug");
}
return my_find_bin($mysqld_basedir,
return my_find_bin($bindir,
["sql", "libexec", "sbin", "bin"],
[@mysqld_names]);
}
......@@ -1858,7 +1862,7 @@ sub executable_setup () {
if ( $opt_embedded_server )
{
$exe_mysqltest=
mtr_exe_exists("$basedir/libmysqld/examples$opt_vs_config/mysqltest_embedded",
mtr_exe_exists("$bindir/libmysqld/examples$opt_vs_config/mysqltest_embedded",
"$path_client_bindir/mysqltest_embedded");
}
else
......@@ -1968,11 +1972,11 @@ sub mysql_client_test_arguments(){
# mysql_client_test executable may _not_ exist
if ( $opt_embedded_server ) {
$exe= mtr_exe_maybe_exists(
"$basedir/libmysqld/examples$opt_vs_config/mysql_client_test_embedded",
"$basedir/bin/mysql_client_test_embedded");
"$bindir/libmysqld/examples$opt_vs_config/mysql_client_test_embedded",
"$bindir/bin/mysql_client_test_embedded");
} else {
$exe= mtr_exe_maybe_exists("$basedir/tests$opt_vs_config/mysql_client_test",
"$basedir/bin/mysql_client_test");
$exe= mtr_exe_maybe_exists("$bindir/tests$opt_vs_config/mysql_client_test",
"$bindir/bin/mysql_client_test");
}
my $args;
......@@ -1984,13 +1988,13 @@ sub mysql_client_test_arguments(){
mtr_add_arg($args, "--testcase");
mtr_add_arg($args, "--vardir=$opt_vardir");
client_debug_arg($args,"mysql_client_test");
return mtr_args2str($exe, @$args);
my $ret=mtr_args2str($exe, @$args);
return $ret;
}
sub tool_arguments ($$) {
my($sedir, $tool_name) = @_;
my $exe= my_find_bin($basedir,
my $exe= my_find_bin($bindir,
[$sedir, "bin"],
$tool_name);
......@@ -2004,7 +2008,7 @@ sub tool_arguments ($$) {
# scripts to run the mysqld binary to test invalid server startup options.
sub mysqld_client_arguments () {
my $default_mysqld= default_mysqld();
my $exe = find_mysqld($basedir);
my $exe = find_mysqld($bindir);
my $args;
mtr_init_args(\$args);
mtr_add_arg($args, "--no-defaults");
......@@ -2195,24 +2199,24 @@ sub environment_setup {
# some versions, test using it should be skipped
# ----------------------------------------------------
my $exe_bug25714=
mtr_exe_maybe_exists("$basedir/tests$opt_vs_config/bug25714");
mtr_exe_maybe_exists("$bindir/tests$opt_vs_config/bug25714");
$ENV{'MYSQL_BUG25714'}= native_path($exe_bug25714);
# ----------------------------------------------------
# mysql_fix_privilege_tables.sql
# ----------------------------------------------------
my $file_mysql_fix_privilege_tables=
mtr_file_exists("$basedir/scripts/mysql_fix_privilege_tables.sql",
"$basedir/share/mysql_fix_privilege_tables.sql",
"$basedir/share/mariadb/mysql_fix_privilege_tables.sql",
"$basedir/share/mysql/mysql_fix_privilege_tables.sql");
mtr_file_exists("$bindir/scripts/mysql_fix_privilege_tables.sql",
"$bindir/share/mysql_fix_privilege_tables.sql",
"$bindir/share/mariadb/mysql_fix_privilege_tables.sql",
"$bindir/share/mysql/mysql_fix_privilege_tables.sql");
$ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables;
# ----------------------------------------------------
# my_print_defaults
# ----------------------------------------------------
my $exe_my_print_defaults=
mtr_exe_exists("$basedir/extra$opt_vs_config/my_print_defaults",
mtr_exe_exists("$bindir/extra$opt_vs_config/my_print_defaults",
"$path_client_bindir/my_print_defaults");
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= native_path($exe_my_print_defaults);
......@@ -2237,7 +2241,7 @@ sub environment_setup {
# mysqlhotcopy
# ----------------------------------------------------
my $mysqlhotcopy=
mtr_pl_maybe_exists("$basedir/scripts/mysqlhotcopy");
mtr_pl_maybe_exists("$bindir/scripts/mysqlhotcopy");
# Since mysqltest interprets the real path as "false" in an if,
# use 1 ("true") to indicate "not exists" so it can be tested for
$ENV{'MYSQLHOTCOPY'}= $mysqlhotcopy || 1;
......@@ -2245,7 +2249,7 @@ sub environment_setup {
# ----------------------------------------------------
# perror
# ----------------------------------------------------
my $exe_perror= mtr_exe_exists("$basedir/extra$opt_vs_config/perror",
my $exe_perror= mtr_exe_exists("$bindir/extra$opt_vs_config/perror",
"$path_client_bindir/perror");
$ENV{'MY_PERROR'}= native_path($exe_perror);
......@@ -2426,9 +2430,9 @@ sub setup_vardir() {
mkpath($plugindir);
if (IS_WINDOWS && !$opt_embedded_server)
{
for (<../storage/*$opt_vs_config/*.dll>,
<../plugin/*$opt_vs_config/*.dll>,
<../sql$opt_vs_config/*.dll>)
for (<$bindir/storage/*$opt_vs_config/*.dll>,
<$bindir/plugin/*$opt_vs_config/*.dll>,
<$bindir/sql$opt_vs_config/*.dll>)
{
my $pname=basename($_);
copy rel2abs($_), "$plugindir/$pname";
......@@ -2437,7 +2441,7 @@ sub setup_vardir() {
}
else
{
for (<../storage/*/.libs/*.so>,<../plugin/*/.libs/*.so>,<../sql/.libs/*.so>)
for (<$bindir/storage/*/.libs/*.so>,<$bindir/plugin/*/.libs/*.so>,<$bindir/sql/.libs/*.so>)
{
my $pname=basename($_);
symlink rel2abs($_), "$plugindir/$pname";
......@@ -2448,8 +2452,8 @@ sub setup_vardir() {
else
{
# hm, what paths work for debs and for rpms ?
for (<$basedir/lib/mysql/plugin/*.so>,
<$basedir/lib/plugin/*.dll>)
for (<$bindir/lib/mysql/plugin/*.so>,
<$bindir/lib/plugin/*.dll>)
{
my $pname=basename($_);
set_plugin_var($pname);
......@@ -2564,7 +2568,7 @@ sub fix_vs_config_dir () {
$opt_vs_config="";
for (<$basedir/sql/*/mysqld.exe>) {
for (<$bindir/sql/*/mysqld.exe>) {
if (-M $_ < $modified)
{
$modified = -M _;
......
......@@ -138,6 +138,7 @@ Tables_in_test
DROP TABLE `@`;
CREATE TABLE `я` (a INT);
SET NAMES DEFAULT;
call mtr.add_suppression("@003f.frm' \\(errno: 22\\)");
mysqlcheck --default-character-set="latin1" --databases test
test.?
Error : Table doesn't exist
......
......@@ -136,6 +136,7 @@ DROP TABLE `@`;
CREATE TABLE `я` (a INT);
SET NAMES DEFAULT;
call mtr.add_suppression("@003f.frm' \\(errno: 22\\)");
--echo mysqlcheck --default-character-set="latin1" --databases test
# Error returned depends on platform, replace it with "Table doesn't exist"
--replace_result "Can't find file: './test/@003f.frm' (errno: 22)" "Table doesn't exist" "Table 'test.?' doesn't exist" "Table doesn't exist"
......
......@@ -48,6 +48,4 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(mysys ${MYSYS_SOURCES})
INSTALL(TARGETS mysys DESTINATION lib/opt COMPONENT runtime) # TODO: Component?
ENDIF(NOT SOURCE_SUBLIBS)
......@@ -20,6 +20,4 @@ SET(REGEX_SOURCES regcomp.c regerror.c regexec.c regfree.c reginit.c)
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(regex ${REGEX_SOURCES})
INSTALL(TARGETS regex DESTINATION lib/opt COMPONENT runtime) # TODO: Component
ENDIF(NOT SOURCE_SUBLIBS)
......@@ -14,10 +14,12 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# Build mysql_fix_privilege_tables.sql
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql
COMMAND copy /b
mysql_system_tables.sql + mysql_system_tables_fix.sql
mysql_fix_privilege_tables.sql
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables.sql
native_outfile )
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/scripts/mysql_fix_privilege_tables.sql
COMMAND COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_SOURCE_DIR}
cmd /c copy /b mysql_system_tables.sql + mysql_system_tables_fix.sql
${native_outfile}
DEPENDS
${PROJECT_SOURCE_DIR}/scripts/mysql_system_tables.sql
${PROJECT_SOURCE_DIR}/scripts/mysql_system_tables_fix.sql)
......@@ -29,24 +31,26 @@ TARGET_LINK_LIBRARIES(comp_sql debug dbug mysys strings)
# Use comp_sql to build mysql_fix_privilege_tables_sql.c
GET_TARGET_PROPERTY(COMP_SQL_EXE comp_sql LOCATION)
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/scripts/mysql_fix_privilege_tables_sql.c
COMMAND ${COMP_SQL_EXE}
mysql_fix_privilege_tables
mysql_fix_privilege_tables.sql
${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables.sql
mysql_fix_privilege_tables_sql.c
DEPENDS comp_sql ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS comp_sql
${CMAKE_BINARY_DIR}/scripts/mysql_fix_privilege_tables.sql)
# Add dummy target for the above to be built
ADD_CUSTOM_TARGET(GenFixPrivs
ALL
DEPENDS ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c)
DEPENDS ${CMAKE_BINARY_DIR}/scripts/mysql_fix_privilege_tables_sql.c)
# ----------------------------------------------------------------------
# Replace some variables @foo@ in the .in/.sh file, and write the new script
# ----------------------------------------------------------------------
SET(CFLAGS "-D_WINDOWS ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
SET(prefix "${CMAKE_INSTALL_PREFIX}/MySQL Server ${MYSQL_BASE_VERSION}")
SET(prefix "${CMAKE_INSTALL_PREFIX}")
SET(sysconfdir ${prefix})
SET(bindir ${prefix}/bin)
SET(libexecdir ${prefix}/bin)
......@@ -76,11 +80,14 @@ CONFIGURE_FILE(mysqldumpslow.sh
CONFIGURE_FILE(mysqlhotcopy.sh
${CMAKE_BINARY_DIR}/scripts/mysqlhotcopy.pl ESCAPE_QUOTES @ONLY)
INSTALL(FILES mysqldumpslow.pl mysqlhotcopy.pl mysql_config.pl
FOREACH(f mysqldumpslow.pl mysqlhotcopy.pl mysql_config.pl
mysql_convert_table_format.pl mysql_install_db.pl
mysql_secure_installation.pl mysqld_multi.pl
DESTINATION scripts COMPONENT scripts)
INSTALL(FILES fill_help_tables.sql mysql_fix_privilege_tables.sql mysql_system_tables.sql
mysql_system_tables_data.sql mysql_system_tables_fix.sql mysql_test_data_timezone.sql
DESTINATION share COMPONENT scripts)
mysql_secure_installation.pl mysqld_multi.pl)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${f}
DESTINATION scripts COMPONENT Server_Scripts)
ENDFOREACH()
INSTALL(FILES fill_help_tables.sql mysql_system_tables.sql
mysql_system_tables_data.sql mysql_system_tables_fix.sql mysql_test_data_timezone.sql
DESTINATION share COMPONENT Server)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables.sql DESTINATION share COMPONENT Server)
\ No newline at end of file
......@@ -25,6 +25,10 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
/* Compiler-dependent constant for maximum string constant */
#define MAX_STRING_CONSTANT_LENGTH 65535
FILE *in, *out;
......@@ -58,64 +62,99 @@ static void die(const char *fmt, ...)
int main(int argc, char *argv[])
{
char buff[512];
struct stat st;
char* struct_name= argv[1];
char* infile_name= argv[2];
char* outfile_name= argv[3];
if (argc != 4)
die("Usage: comp_sql <struct_name> <sql_filename> <c_filename>");
/* Open input and output file */
if (!(in= fopen(infile_name, "r")))
die("Failed to open SQL file '%s'", infile_name);
if (!(out= fopen(outfile_name, "w")))
die("Failed to open output file '%s'", outfile_name);
fprintf(out, "const char %s[]={\n",struct_name);
/*
Some compilers have limitations how long a string constant can be.
We'll output very long strings as hexadecimal arrays, and short ones
as strings (prettier)
*/
stat(infile_name, &st);
if (st.st_size > MAX_STRING_CONSTANT_LENGTH)
{
int cnt=0;
int c;
int first_char= 1;
for(cnt=0;;cnt++)
{
c= fgetc(in);
if (c== -1)
break;
if(cnt != 0)
fputc(',', out);
fprintf(out, "const char* %s={\n\"", struct_name);
/* Put line break after each 16 hex characters */
if(cnt && (cnt%16 == 0))
fputc('\n', out);
while (fgets(buff, sizeof(buff), in))
fprintf(out,"0x%02x",c);
}
fprintf(out,",0x00",c);
}
else
{
char *curr= buff;
while (*curr)
fprintf(out,"\"");
while (fgets(buff, sizeof(buff), in))
{
if (*curr == '\n')
{
/*
Reached end of line, add escaped newline, escaped
backslash and a newline to outfile
*/
fprintf(out, "\\n \"\n\"");
curr++;
}
else if (*curr == '\r')
{
curr++; /* Skip */
}
else
char *curr= buff;
while (*curr)
{
if (*curr == '"')
if (*curr == '\n')
{
/* Needs escape */
fputc('\\', out);
/*
Reached end of line, add escaped newline, escaped
backslash and a newline to outfile
*/
fprintf(out, "\\n \"\n\"");
curr++;
}
else if (*curr == '\r')
{
curr++; /* Skip */
}
else
{
if (*curr == '"')
{
/* Needs escape */
fputc('\\', out);
}
fputc(*curr, out);
curr++;
}
fputc(*curr, out);
curr++;
}
if (*(curr-1) != '\n')
{
/*
Some compilers have a max string length,
insert a newline at every 512th char in long
strings
*/
fprintf(out, "\"\n\"");
}
}
if (*(curr-1) != '\n')
{
/*
Some compilers have a max string length,
insert a newline at every 512th char in long
strings
*/
fprintf(out, "\"\n\"");
}
fprintf(out, "\\\n\"");
}
fprintf(out, "\\\n\"};\n");
fprintf(out, "};\n");
fclose(in);
fclose(out);
......
......@@ -360,7 +360,7 @@ my $hostname = hostname();
my $resolved;
if ( !$opt->{'cross-bootstrap'} and !$opt->{rpm} and !$opt->{force} )
{
my $resolveip;
my $resolveip = $bindir/resolveip;
$resolved = `$resolveip $hostname 2>&1`;
if ( $? != 0 )
......@@ -418,9 +418,7 @@ my $mysqld_install_cmd_line = quote_options($mysqld_bootstrap,
"--bootstrap",
"--basedir=$opt->{basedir}",
"--datadir=$opt->{ldata}",
"--skip-innodb",
"--skip-bdb",
"--skip-ndbcluster",
"--loose-skip-innodb",
"--max_allowed_packet=8M",
"--net_buffer_length=16K",
@args,
......
......@@ -34,5 +34,3 @@ TARGET_LINK_LIBRARIES(mysqlmanager debug dbug mysys strings taocrypt vio yassl z
IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("mysqlmanager" "asInvoker")
ENDIF(EMBED_MANIFESTS)
INSTALL(TARGETS mysqlmanager DESTINATION bin COMPONENT runtime)
......@@ -21,17 +21,19 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/regex
${CMAKE_SOURCE_DIR}/zlib
${CMAKE_SOURCE_DIR}/extra/libevent
${CMAKE_SOURCE_DIR}/extra/libevent
${CMAKE_BINARY_DIR}/extra/libevent
${CMAKE_CURRENT_BINARY_DIR}
)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/sql/sql_yacc.h
${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc
${CMAKE_SOURCE_DIR}/include/mysql_version.h
${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc
${CMAKE_SOURCE_DIR}/sql/lex_hash.h
${PROJECT_SOURCE_DIR}/include/mysqld_error.h
${PROJECT_SOURCE_DIR}/include/mysqld_ername.h
${PROJECT_SOURCE_DIR}/include/sql_state.h
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/sql/sql_yacc.h
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
${CMAKE_BINARY_DIR}/include/mysql_version.h
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
${CMAKE_BINARY_DIR}/sql/lex_hash.h
${CMAKE_BINARY_DIR}/include/mysqld_error.h
${CMAKE_BINARY_DIR}/include/mysqld_ername.h
${CMAKE_BINARY_DIR}/include/sql_state.h
PROPERTIES GENERATED 1)
ADD_DEFINITIONS(-DMYSQL_SERVER -D_CONSOLE -DHAVE_DLOPEN -DHAVE_EVENT_SCHEDULER)
......@@ -81,20 +83,23 @@ SET (SQL_SOURCE
opt_index_cond_pushdown.cc
create_options.cc
sql_expression_cache.cc
${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
${PROJECT_SOURCE_DIR}/sql/sql_yacc.h
${PROJECT_SOURCE_DIR}/include/mysqld_error.h
${PROJECT_SOURCE_DIR}/include/mysqld_ername.h
${PROJECT_SOURCE_DIR}/include/sql_state.h
${PROJECT_SOURCE_DIR}/include/mysql_version.h
${PROJECT_SOURCE_DIR}/sql/sql_builtin.cc
${PROJECT_SOURCE_DIR}/sql/lex_hash.h)
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
${CMAKE_BINARY_DIR}/sql/sql_yacc.h
${CMAKE_BINARY_DIR}/include/mysqld_error.h
${CMAKE_BINARY_DIR}/include/mysqld_ername.h
${CMAKE_BINARY_DIR}/include/sql_state.h
${CMAKE_BINARY_DIR}/include/mysql_version.h
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
${CMAKE_BINARY_DIR}/sql/lex_hash.h)
ADD_LIBRARY(sql ${SQL_SOURCE})
IF (NOT EXISTS cmake_dummy.cc)
FILE (WRITE cmake_dummy.cc "")
ENDIF (NOT EXISTS cmake_dummy.cc)
ADD_EXECUTABLE(mysqld cmake_dummy.cc message.rc)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/win/cmake/dummy.in cmake_dummy.cc COPYONLY)
MYSQL_ADD_EXECUTABLE(mysqld cmake_dummy.cc message.rc DESTINATION ${INSTALL_SBINDIR} COMPONENT Server)
INSTALL_DEBUG_TARGET(mysqld
DESTINATION ${INSTALL_SBINDIR}
PDB_DESTINATION ${INSTALL_SBINDIR}/debug
RENAME mysqld-debug)
SET_TARGET_PROPERTIES(mysqld PROPERTIES OUTPUT_NAME mysqld${MYSQLD_EXE_SUFFIX})
SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
......@@ -118,17 +123,17 @@ IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)
ADD_CUSTOM_COMMAND(TARGET mysqld PRE_LINK
COMMAND cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js
${PLATFORM} ${LIB_LOCATIONS} > mysqld.def
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/sql)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
ENDIF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)
ADD_DEPENDENCIES(sql GenError)
# Sql Parser custom command
ADD_CUSTOM_COMMAND(
OUTPUT ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h
${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
OUTPUT ${CMAKE_BINARY_DIR}/sql/sql_yacc.h
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
COMMAND bison ARGS -y -p MYSQL --defines=sql_yacc.h
--output=sql_yacc.cc sql_yacc.yy
--output=sql_yacc.cc "${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.yy"
DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.yy)
......@@ -137,17 +142,15 @@ ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc)
TARGET_LINK_LIBRARIES(gen_lex_hash debug dbug mysqlclient strings wsock32)
GET_TARGET_PROPERTY(GEN_LEX_HASH_EXE gen_lex_hash LOCATION)
ADD_CUSTOM_COMMAND(
OUTPUT ${PROJECT_SOURCE_DIR}/sql/lex_hash.h
OUTPUT ${CMAKE_BINARY_DIR}/sql/lex_hash.h
COMMAND ${GEN_LEX_HASH_EXE} ARGS > lex_hash.h
DEPENDS ${GEN_LEX_HASH_EXE})
ADD_CUSTOM_TARGET(
GenServerSource ALL
DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h
${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
${PROJECT_SOURCE_DIR}/sql/message.h
${PROJECT_SOURCE_DIR}/sql/message.rc
${PROJECT_SOURCE_DIR}/sql/lex_hash.h)
DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc.h
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
${CMAKE_BINARY_DIR}/sql/lex_hash.h)
ADD_DEPENDENCIES(sql GenServerSource)
......@@ -159,7 +162,91 @@ ADD_LIBRARY(udf_example MODULE udf_example.c udf_example.def)
ADD_DEPENDENCIES(udf_example strings GenError)
TARGET_LINK_LIBRARIES(udf_example strings wsock32)
INSTALL(TARGETS mysqld
RUNTIME DESTINATION bin COMPONENT runtime
LIBRARY DESTINATION lib COMPONENT runtime
ARCHIVE DESTINATION lib COMPONENT runtime)
ADD_SUBDIRECTORY(share)
IF(WIN32)
SET(my_bootstrap_sql ${CMAKE_CURRENT_BINARY_DIR}/my_bootstrap.sql)
FILE(TO_NATIVE_PATH ${my_bootstrap_sql} native_outfile)
# Create bootstrapper SQL script
ADD_CUSTOM_COMMAND(OUTPUT
${my_bootstrap_sql}
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR}/scripts
cmd /c copy mysql_system_tables.sql+mysql_system_tables_data.sql+fill_help_tables.sql ${native_outfile}
DEPENDS
${CMAKE_SOURCE_DIR}/scripts/mysql_system_tables.sql
${CMAKE_SOURCE_DIR}/scripts/mysql_system_tables_data.sql
${CMAKE_SOURCE_DIR}/scripts/fill_help_tables.sql
)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mysql_bootstrap_sql.c
COMMAND comp_sql
mysql_bootstrap_sql
${CMAKE_CURRENT_BINARY_DIR}/my_bootstrap.sql
mysql_bootstrap_sql.c
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS comp_sql ${my_bootstrap_sql})
MYSQL_ADD_EXECUTABLE(mysql_install_db
mysql_install_db.cc
${CMAKE_CURRENT_BINARY_DIR}/mysql_bootstrap_sql.c
COMPONENT Server)
TARGET_LINK_LIBRARIES(mysql_install_db mysys strings dbug)
ADD_LIBRARY(winservice STATIC winservice.c)
MYSQL_ADD_EXECUTABLE(mysql_upgrade_service
mysql_upgrade_service.cc
COMPONENT Server)
TARGET_LINK_LIBRARIES(mysql_upgrade_service mysys strings dbug winservice)
# mysql_install_db should be in the same directory as mysqld
# to work correctly
GET_TARGET_PROPERTY(MYSQLD_EXECUTABLE mysqld LOCATION)
IF(NOT MYSQLD_EXECUTABLE)
MESSAGE(FATAL_ERROR "Unexpected")
ENDIF()
ENDIF()
# We need to create empty directories (data/test) the installation.
# This does not work with current CPack due to http://www.cmake.org/Bug/view.php?id=8767
# Avoid completely empty directories and install dummy file instead.
SET(DUMMY_FILE ${CMAKE_CURRENT_BINARY_DIR}/.empty )
FILE(WRITE ${DUMMY_FILE} "")
INSTALL(FILES ${DUMMY_FILE} DESTINATION data/test COMPONENT DataFiles)
# Install initial database on windows
IF(NOT CMAKE_CROSSCOMPILING)
GET_TARGET_PROPERTY(MYSQLD_EXECUTABLE mysqld LOCATION)
ENDIF()
IF(WIN32 AND MYSQLD_EXECUTABLE)
CONFIGURE_FILE(
${CMAKE_SOURCE_DIR}/win/cmake/create_initial_db.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake
@ONLY
)
IF(MSVC_IDE OR CMAKE_GENERATOR MATCHES "Xcode")
SET (CONFIG_PARAM -DCONFIG=${CMAKE_CFG_INTDIR})
ENDIF()
MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/data)
ADD_CUSTOM_COMMAND(
OUTPUT initdb.dep
COMMAND ${CMAKE_COMMAND}
${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep
DEPENDS mysqld
)
ADD_CUSTOM_TARGET(initial_database
ALL
DEPENDS initdb.dep
)
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data DESTINATION .
COMPONENT DataFiles PATTERN "initdb.dep" EXCLUDE PATTERN "bootstrap.sql" EXCLUDE)
ELSE()
# Not windows or cross compiling, just install an empty directory
INSTALL(FILES ${DUMMY_FILE} DESTINATION data/mysql COMPONENT DataFiles)
ENDIF()
......@@ -160,8 +160,9 @@ DEFS = -DMYSQL_SERVER \
BUILT_MAINT_SRC = sql_yacc.cc sql_yacc.h
BUILT_SOURCES = $(BUILT_MAINT_SRC) lex_hash.h link_sources
EXTRA_DIST = udf_example.c udf_example.def $(BUILT_MAINT_SRC) \
nt_servc.cc nt_servc.h \
nt_servc.cc nt_servc.h mysql_install_db.cc mysql_upgrade_service.cc \
message.mc message.h message.rc MSG00001.bin \
winservice.c winservice.h \
CMakeLists.txt opt_range_mrr.cc
CLEANFILES = lex_hash.h sql_yacc.output link_sources
......
/* Copyright (C) 2010-2011 Monty Program Ab & Vladislav Vaintroub
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 */
/*
mysql_install_db creates a new database instance (optionally as service)
on Windows.
*/
#define DONT_DEFINE_VOID
#include <my_global.h>
#include <my_getopt.h>
#include <my_sys.h>
#include <m_string.h>
#include <windows.h>
#include <assert.h>
#include <shellapi.h>
#include <accctrl.h>
#include <aclapi.h>
#define USAGETEXT \
"mysql_install_db.exe Ver 1.00 for Windows\n" \
"Copyright (C) 2010-2011 Monty Program Ab & Vladislav Vaintroub\n" \
"This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n" \
"and you are welcome to modify and redistribute it under the GPL v2 license\n" \
"Usage: mysql_install_db.exe [OPTIONS]\n" \
"OPTIONS:"
extern "C" const char mysql_bootstrap_sql[];
char default_os_user[]= "NT AUTHORITY\\NetworkService";
static int create_db_instance();
static uint opt_silent;
static char datadir_buffer[FN_REFLEN];
static char mysqld_path[FN_REFLEN];
static char *opt_datadir;
static char *opt_service;
static char *opt_password;
static int opt_port;
static char *opt_socket;
static char *opt_os_user;
static char *opt_os_password;
static my_bool opt_default_user;
static my_bool opt_allow_remote_root_access;
static my_bool opt_skip_networking;
static my_bool verbose_errors;
static struct my_option my_long_options[]=
{
{"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"datadir", 'd', "Data directory of the new database",
&opt_datadir, &opt_datadir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"service", 'S', "Name of the Windows service",
&opt_service, &opt_service, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', "Root password",
&opt_password, &opt_password, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "mysql port",
&opt_port, &opt_port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"socket", 'W',
"named pipe name (if missing, it will be set the same as service)",
&opt_socket, &opt_socket, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"default-user", 'D', "Create default user",
&opt_default_user, &opt_default_user, 0 , GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"allow-remote-root-access", 'R',
"Allows remote access from network for user root",
&opt_allow_remote_root_access, &opt_allow_remote_root_access, 0 , GET_BOOL,
OPT_ARG, 0, 0, 0, 0, 0, 0},
{"skip-networking", 'N', "Do not use TCP connections, use pipe instead",
&opt_skip_networking, &opt_skip_networking, 0 , GET_BOOL, OPT_ARG, 0, 0, 0, 0,
0, 0},
{"silent", 's', "Print less information", &opt_silent,
&opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static my_bool
get_one_option(int optid,
const struct my_option *opt __attribute__ ((unused)),
char *argument __attribute__ ((unused)))
{
DBUG_ENTER("get_one_option");
switch (optid) {
case '?':
printf("%s\n", USAGETEXT);
my_print_help(my_long_options);
exit(0);
break;
}
DBUG_RETURN(0);
}
static void die(const char *fmt, ...)
{
va_list args;
DBUG_ENTER("die");
/* Print the error message */
va_start(args, fmt);
fprintf(stderr, "FATAL ERROR: ");
vfprintf(stderr, fmt, args);
fputc('\n', stderr);
if (verbose_errors)
{
fprintf(stderr,
"http://kb.askmonty.org/v/installation-issues-on-windows contains some help\n"
"for solving the most common problems. If this doesn't help you, please\n"
"leave a comment in the knowledge base or file a bug report at\n"
"https://bugs.launchpad.net/maria");
}
fflush(stderr);
va_end(args);
my_end(0);
exit(1);
}
static void verbose(const char *fmt, ...)
{
va_list args;
if (opt_silent)
return;
/* Print the verbose message */
va_start(args, fmt);
vfprintf(stdout, fmt, args);
fputc('\n', stdout);
fflush(stdout);
va_end(args);
}
int main(int argc, char **argv)
{
int error;
char self_name[FN_REFLEN];
char *p;
MY_INIT(argv[0]);
GetModuleFileName(NULL, self_name, FN_REFLEN);
strcpy(mysqld_path,self_name);
p= strrchr(mysqld_path, FN_LIBCHAR);
if (p)
{
strcpy(p, "\\mysqld.exe");
}
if ((error= handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(error);
if (!opt_datadir)
{
my_print_help(my_long_options);
die("parameter --datadir=# is mandatory");
}
/* Print some help on errors */
verbose_errors= TRUE;
if (!opt_os_user)
{
opt_os_user= default_os_user;
opt_os_password= NULL;
}
/* Workaround WiX bug (strip possible quote character at the end of path) */
size_t len= strlen(opt_datadir);
if (len > 0)
{
if (opt_datadir[len-1] == '"')
{
opt_datadir[len-1]= 0;
}
}
GetFullPathName(opt_datadir, FN_REFLEN, datadir_buffer, NULL);
opt_datadir= datadir_buffer;
if (create_db_instance())
{
die("database creation failed");
}
printf("Creation of the database was successfull");
return 0;
}
/**
Convert slashes in paths into MySQL-compatible form
*/
static void convert_slashes(char *s)
{
for (; *s ; s++)
if (*s == '\\')
*s= '/';
}
/**
Calculate basedir from mysqld.exe path.
Basedir assumed to be is one level up from the mysqld.exe directory location.
E.g basedir for C:\my\bin\mysqld.exe would be C:\my
*/
static void get_basedir(char *basedir, int size, const char *mysqld_path)
{
strcpy_s(basedir, size, mysqld_path);
convert_slashes(basedir);
char *p= strrchr(basedir,'/');
if (p)
{
*p = 0;
p= strrchr(basedir, '/');
if (p)
*p= 0;
}
}
/**
Allocate and initialize command line for mysqld --bootstrap.
The resulting string is passed to popen, so it has a lot of quoting
quoting around the full string plus quoting around parameters with spaces.
*/
static char *init_bootstrap_command_line(char *cmdline, size_t size)
{
char basedir[MAX_PATH];
get_basedir(basedir, sizeof(basedir), mysqld_path);
my_snprintf(cmdline, size-1,
"\"\"%s\" --no-defaults --bootstrap"
" \"--language=%s\\share\\english\""
" --basedir=. --datadir=. --default-storage-engine=myisam"
" --max_allowed_packet=9M --loose-skip-innodb --loose-skip-pbxt"
" --net-buffer-length=16k\"", mysqld_path, basedir);
return cmdline;
}
/**
Create my.ini in current directory (this is assumed to be
data directory as well).
*/
static int create_myini()
{
my_bool enable_named_pipe= FALSE;
printf("Creating my.ini file\n");
char path_buf[MAX_PATH];
GetCurrentDirectory(MAX_PATH, path_buf);
/* Create ini file. */
FILE *myini= fopen("my.ini","wt");
if (!myini)
{
die("Cannot create my.ini in data directory");
}
/* Write out server settings. */
fprintf(myini, "[mysqld]\n");
convert_slashes(path_buf);
fprintf(myini, "datadir=%s\n", path_buf);
if (opt_skip_networking)
{
fprintf(myini,"skip-networking\n");
if (!opt_socket)
opt_socket= opt_service;
}
enable_named_pipe= (my_bool)
((opt_socket && opt_socket[0]) || opt_skip_networking);
if (enable_named_pipe)
{
fprintf(myini,"enable-named-pipe\n");
}
if (opt_socket && opt_socket[0])
{
fprintf(myini, "socket=%s\n", opt_socket);
}
if (opt_port)
{
fprintf(myini,"port=%d\n", opt_port);
}
/* Write out client settings. */
fprintf(myini, "[client]\n");
/* Used for named pipes */
if (opt_socket && opt_socket[0])
fprintf(myini,"socket=%s\n",opt_socket);
if (opt_skip_networking)
fprintf(myini,"protocol=pipe\n");
else if (opt_port)
fprintf(myini,"port=%d\n",opt_port);
fclose(myini);
return 0;
}
static const char update_root_passwd_part1[]=
"UPDATE mysql.user SET Password = PASSWORD('";
static const char update_root_passwd_part2[]=
"') where User='root';\n";
static const char remove_default_user_cmd[]=
"DELETE FROM mysql.user where User='';\n";
static const char allow_remote_root_access_cmd[]=
"CREATE TEMPORARY TABLE tmp_user LIKE user engine=memory;\n"
"INSERT INTO tmp_user SELECT * from user where user='root' "
" AND host='localhost';\n"
"UPDATE tmp_user SET host='%';\n"
"INSERT INTO user SELECT * FROM tmp_user;\n"
"DROP TABLE tmp_user;\n";
static const char end_of_script[]="-- end.";
/* Register service. Assume my.ini is in datadir */
static int register_service()
{
char buf[3*MAX_PATH +32]; /* path to mysqld.exe, to my.ini, service name */
SC_HANDLE sc_manager, sc_service;
size_t datadir_len= strlen(opt_datadir);
const char *backslash_after_datadir= "\\";
if (datadir_len && opt_datadir[datadir_len-1] == '\\')
backslash_after_datadir= "";
verbose("Registering service '%s'", opt_service);
my_snprintf(buf, sizeof(buf)-1,
"\"%s\" \"--defaults-file=%s%smy.ini\" \"%s\"" , mysqld_path, opt_datadir,
backslash_after_datadir, opt_service);
/* Get a handle to the SCM database. */
sc_manager= OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (!sc_manager)
{
die("OpenSCManager failed (%u)\n", GetLastError());
}
/* Create the service. */
sc_service= CreateService(sc_manager, opt_service, opt_service,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL, buf, NULL, NULL, NULL, opt_os_user, opt_os_password);
if (!sc_service)
{
CloseServiceHandle(sc_manager);
die("CreateService failed (%u)", GetLastError());
}
SERVICE_DESCRIPTION sd= { "MariaDB database server" };
ChangeServiceConfig2(sc_service, SERVICE_CONFIG_DESCRIPTION, &sd);
CloseServiceHandle(sc_service);
CloseServiceHandle(sc_manager);
return 0;
}
static void clean_directory(const char *dir)
{
char dir2[MAX_PATH+2];
*(strmake(dir2, dir, MAX_PATH+1)+1)= 0;
SHFILEOPSTRUCT fileop;
fileop.hwnd= NULL; /* no status display */
fileop.wFunc= FO_DELETE; /* delete operation */
fileop.pFrom= dir2; /* 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;
SHFileOperation(&fileop);
}
/*
Define directory permission to have inheritable all access for a user
(defined as username or group string or as SID)
*/
static int set_directory_permissions(const char *dir, const char *os_user)
{
struct{
TOKEN_USER tokenUser;
BYTE buffer[SECURITY_MAX_SID_SIZE];
} tokenInfoBuffer;
HANDLE hDir= CreateFile(dir,READ_CONTROL|WRITE_DAC,0,NULL,OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,NULL);
if (hDir == INVALID_HANDLE_VALUE)
return -1;
ACL* pOldDACL;
SECURITY_DESCRIPTOR* pSD= NULL;
EXPLICIT_ACCESS ea={0};
BOOL isWellKnownSID= FALSE;
WELL_KNOWN_SID_TYPE wellKnownSidType = WinNullSid;
PSID pSid= NULL;
GetSecurityInfo(hDir, SE_FILE_OBJECT , DACL_SECURITY_INFORMATION,NULL, NULL,
&pOldDACL, NULL, (void**)&pSD);
if (os_user)
{
/* Check for 3 predefined service users
They might have localized names in non-English Windows, thus they need
to be handled using well-known SIDs.
*/
if (stricmp(os_user, "NT AUTHORITY\\NetworkService") == 0)
{
wellKnownSidType= WinNetworkServiceSid;
}
else if (stricmp(os_user, "NT AUTHORITY\\LocalService") == 0)
{
wellKnownSidType= WinLocalServiceSid;
}
else if (stricmp(os_user, "NT AUTHORITY\\LocalSystem") == 0)
{
wellKnownSidType= WinLocalSystemSid;
}
if (wellKnownSidType != WinNullSid)
{
DWORD size= SECURITY_MAX_SID_SIZE;
pSid= (PSID)tokenInfoBuffer.buffer;
if (!CreateWellKnownSid(wellKnownSidType, NULL, pSid,
&size))
{
return 1;
}
ea.Trustee.TrusteeForm= TRUSTEE_IS_SID;
ea.Trustee.ptstrName= (LPTSTR)pSid;
}
else
{
ea.Trustee.TrusteeForm= TRUSTEE_IS_NAME;
ea.Trustee.ptstrName= (LPSTR)os_user;
}
}
else
{
HANDLE token;
if (OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY, &token))
{
DWORD length= (DWORD) sizeof(tokenInfoBuffer);
if (GetTokenInformation(token, TokenUser, &tokenInfoBuffer,
length, &length))
{
pSid= tokenInfoBuffer.tokenUser.User.Sid;
}
}
if (!pSid)
return 0;
ea.Trustee.TrusteeForm= TRUSTEE_IS_SID;
ea.Trustee.ptstrName= (LPTSTR)pSid;
}
ea.grfAccessMode= GRANT_ACCESS;
ea.grfAccessPermissions= GENERIC_ALL;
ea.grfInheritance= CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE;
ea.Trustee.TrusteeType= TRUSTEE_IS_UNKNOWN;
ACL* pNewDACL= 0;
DWORD err= SetEntriesInAcl(1,&ea,pOldDACL,&pNewDACL);
if (pNewDACL)
{
SetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL, NULL,
pNewDACL, NULL);
}
if (pSD != NULL)
LocalFree((HLOCAL) pSD);
if (pNewDACL != NULL)
LocalFree((HLOCAL) pNewDACL);
CloseHandle(hDir);
return 0;
}
/*
Give directory permissions for special service user NT SERVICE\servicename
this user is available only on Win7 and later.
*/
void grant_directory_permissions_to_service()
{
char service_user[MAX_PATH+ 12];
OSVERSIONINFO info;
info.dwOSVersionInfoSize= sizeof(info);
GetVersionEx(&info);
if (info.dwMajorVersion >6 ||
(info.dwMajorVersion== 6 && info.dwMinorVersion > 0)
&& opt_service)
{
my_snprintf(service_user,sizeof(service_user), "NT SERVICE\\%s",
opt_service);
set_directory_permissions(opt_datadir, service_user);
}
}
/* Create database instance (including registering as service etc) .*/
static int create_db_instance()
{
int ret= 0;
char cwd[MAX_PATH];
DWORD cwd_len= MAX_PATH;
char cmdline[3*MAX_PATH];
FILE *in;
verbose("Running bootstrap");
GetCurrentDirectory(cwd_len, cwd);
CreateDirectory(opt_datadir, NULL); /*ignore error, it might already exist */
if (!SetCurrentDirectory(opt_datadir))
{
die("Cannot set current directory to '%s'\n",opt_datadir);
return -1;
}
CreateDirectory("mysql",NULL);
CreateDirectory("test", NULL);
/*
Set data directory permissions for both current user and
default_os_user (the one who runs services).
*/
set_directory_permissions(opt_datadir, NULL);
set_directory_permissions(opt_datadir, default_os_user);
/* Do mysqld --bootstrap. */
init_bootstrap_command_line(cmdline, sizeof(cmdline));
/* verbose("Executing %s", cmdline); */
in= popen(cmdline, "wt");
if (!in)
goto end;
if (fwrite("use mysql;\n",11,1, in) != 1)
{
verbose("ERROR: Cannot write to mysqld's stdin");
ret= 1;
goto end;
}
/* Write the bootstrap script to stdin. */
if (fwrite(mysql_bootstrap_sql, strlen(mysql_bootstrap_sql), 1, in) != 1)
{
verbose("ERROR: Cannot write to mysqld's stdin");
ret= 1;
goto end;
}
/* Remove default user, if requested. */
if (!opt_default_user)
{
verbose("Removing default user",remove_default_user_cmd);
fputs(remove_default_user_cmd, in);
fflush(in);
}
if (opt_allow_remote_root_access)
{
verbose("Allowing remote access for user root",remove_default_user_cmd);
fputs(allow_remote_root_access_cmd,in);
fflush(in);
}
/* Change root password if requested. */
if (opt_password)
{
verbose("Changing root password",remove_default_user_cmd);
fputs(update_root_passwd_part1, in);
fputs(opt_password, in);
fputs(update_root_passwd_part2, in);
fflush(in);
}
/*
On some reason, bootstrap chokes if last command sent via stdin ends with
newline, so we supply a dummy comment, that does not end with newline.
*/
fputs(end_of_script, in);
fflush(in);
/* Check if bootstrap has completed successfully. */
ret= pclose(in);
if (ret)
{
verbose("mysqld returned error %d in pclose",ret);
goto end;
}
/* Create my.ini file in data directory.*/
ret= create_myini();
if (ret)
goto end;
/* Register service if requested. */
if (opt_service && opt_service[0])
{
ret= register_service();
grant_directory_permissions_to_service();
if (ret)
goto end;
}
end:
if (ret)
{
SetCurrentDirectory(cwd);
clean_directory(opt_datadir);
}
return ret;
}
/* Copyright (C) 2010-2011 Monty Program Ab & Vladislav Vaintroub
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 */
/*
mysql_upgrade_service upgrades mysql service on Windows.
It changes service definition to point to the new mysqld.exe, restarts the
server and runs mysql_upgrade
*/
#define DONT_DEFINE_VOID
#include <process.h>
#include <my_global.h>
#include <my_getopt.h>
#include <my_sys.h>
#include <m_string.h>
#include <mysql_version.h>
#include <winservice.h>
#include <windows.h>
/* We're using version APIs */
#pragma comment(lib, "version")
#define USAGETEXT \
"mysql_upgrade_service.exe Ver 1.00 for Windows\n" \
"Copyright (C) 2010-2011 Monty Program Ab & Vladislav Vaintroub" \
"This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n" \
"and you are welcome to modify and redistribute it under the GPL v2 license\n" \
"Usage: mysql_upgrade_service.exe [OPTIONS]\n" \
"OPTIONS:"
static char mysqld_path[MAX_PATH];
static char mysqladmin_path[MAX_PATH];
static char mysqlupgrade_path[MAX_PATH];
static char defaults_file_param[MAX_PATH + 16]; /*--defaults-file=<path> */
static char logfile_path[MAX_PATH];
static char *opt_service;
static SC_HANDLE service;
static SC_HANDLE scm;
HANDLE mysqld_process; // mysqld.exe started for upgrade
DWORD initial_service_state= -1; // initial state of the service
HANDLE logfile_handle;
/*
Startup and shutdown timeouts, in seconds.
Maybe,they can be made parameters
*/
static unsigned int startup_timeout= 60;
static unsigned int shutdown_timeout= 60;
static struct my_option my_long_options[]=
{
{"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"service", 'S', "Name of the existing Windows service",
&opt_service, &opt_service, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
};
static my_bool
get_one_option(int optid,
const struct my_option *opt __attribute__ ((unused)),
char *argument __attribute__ ((unused)))
{
DBUG_ENTER("get_one_option");
switch (optid) {
case '?':
printf("%s\n", USAGETEXT);
my_print_help(my_long_options);
exit(0);
break;
}
DBUG_RETURN(0);
}
static void log(const char *fmt, ...)
{
va_list args;
/* Print the error message */
va_start(args, fmt);
vfprintf(stdout,fmt, args);
va_end(args);
fputc('\n', stdout);
fflush(stdout);
}
static void die(const char *fmt, ...)
{
va_list args;
DBUG_ENTER("die");
/* Print the error message */
va_start(args, fmt);
fprintf(stderr, "FATAL ERROR: ");
vfprintf(stderr, fmt, args);
if (logfile_path[0])
{
fprintf(stderr, "Additional information can be found in the log file %s",
logfile_path);
}
va_end(args);
fputc('\n', stderr);
fflush(stdout);
/* Cleanup */
/*
Stop service that we started, if it was not initally running at
program start.
*/
if (initial_service_state != -1 && initial_service_state != SERVICE_RUNNING)
{
SERVICE_STATUS service_status;
ControlService(service, SERVICE_CONTROL_STOP, &service_status);
}
if (scm)
CloseServiceHandle(scm);
if (service)
CloseServiceHandle(service);
/* Stop mysqld.exe, if it was started for upgrade */
if (mysqld_process)
TerminateProcess(mysqld_process, 3);
if (logfile_handle)
CloseHandle(logfile_handle);
my_end(0);
exit(1);
}
/*
spawn-like function to run subprocesses.
We also redirect the full output to the log file.
Typical usage could be something like
run_tool(P_NOWAIT, "cmd.exe", "/c" , "echo", "foo", NULL)
@param wait_flag (P_WAIT or P_NOWAIT)
@program program to run
Rest of the parameters is NULL terminated strings building command line.
@return intptr containing either process handle, if P_NOWAIT is used
or return code of the process (if P_WAIT is used)
*/
static intptr_t run_tool(int wait_flag, const char *program,...)
{
static char cmdline[32*1024];
char *end;
va_list args;
va_start(args, program);
if (!program)
die("Invalid call to run_tool");
end= strxmov(cmdline, "\"", program, "\"", NullS);
for(;;)
{
char *param= va_arg(args,char *);
if(!param)
break;
end= strxmov(end, " \"", param, "\"", NullS);
}
va_end(args);
/* Create output file if not alredy done */
if (!logfile_handle)
{
char tmpdir[FN_REFLEN];
GetTempPath(FN_REFLEN, tmpdir);
sprintf_s(logfile_path, "%s\\mysql_upgrade_service.%s.log", tmpdir,
opt_service);
logfile_handle= CreateFile(logfile_path, GENERIC_WRITE, FILE_SHARE_READ,
NULL, TRUNCATE_EXISTING, 0, NULL);
if (!logfile_handle)
{
die("Cannot open log file %s, windows error %u",
logfile_path, GetLastError());
}
}
/* Start child process */
STARTUPINFO si= {0};
si.cb= sizeof(si);
si.hStdInput= GetStdHandle(STD_INPUT_HANDLE);
si.hStdError= logfile_handle;
si.hStdOutput= logfile_handle;
si.dwFlags= STARTF_USESTDHANDLES;
PROCESS_INFORMATION pi;
if (!CreateProcess(NULL, cmdline, NULL,
NULL, TRUE, NULL, NULL, NULL, &si, &pi))
{
die("CreateProcess failed (commandline %s)", cmdline);
}
CloseHandle(pi.hThread);
if (wait_flag == P_NOWAIT)
{
/* Do not wait for process to complete, return handle. */
return (intptr_t)pi.hProcess;
}
/* Wait for process to complete. */
if (WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_OBJECT_0)
{
die("WaitForSingleObject() failed");
}
DWORD exit_code;
if (!GetExitCodeProcess(pi.hProcess, &exit_code))
{
die("GetExitCodeProcess() failed");
}
return (intptr_t)exit_code;
}
void stop_mysqld_service()
{
DWORD needed;
SERVICE_STATUS_PROCESS ssp;
int timeout= shutdown_timeout*1000;
for(;;)
{
if (!QueryServiceStatusEx(service, SC_STATUS_PROCESS_INFO,
(LPBYTE)&ssp,
sizeof(SERVICE_STATUS_PROCESS),
&needed))
{
die("QueryServiceStatusEx failed (%u)\n", GetLastError());
}
/*
Remeber initial state of the service, we will restore it on
exit.
*/
if(initial_service_state == -1)
initial_service_state= ssp.dwCurrentState;
switch(ssp.dwCurrentState)
{
case SERVICE_STOPPED:
return;
case SERVICE_RUNNING:
if(!ControlService(service, SERVICE_CONTROL_STOP,
(SERVICE_STATUS *)&ssp))
die("ControlService failed, error %u\n", GetLastError());
case SERVICE_START_PENDING:
case SERVICE_STOP_PENDING:
if(timeout < 0)
die("Service does not stop after %d seconds timeout",shutdown_timeout);
Sleep(100);
timeout -= 100;
break;
default:
die("Unexpected service state %d",ssp.dwCurrentState);
}
}
}
/*
Shutdown mysql server. Not using mysqladmin, since
our --skip-grant-tables do not work anymore after mysql_upgrade
that does "flush privileges". Instead, the shutdown event is set.
*/
void initiate_mysqld_shutdown()
{
char event_name[32];
DWORD pid= GetProcessId(mysqld_process);
sprintf_s(event_name, "MySQLShutdown%d", pid);
HANDLE shutdown_handle= OpenEvent(EVENT_MODIFY_STATE, FALSE, event_name);
if(!shutdown_handle)
{
die("OpenEvent() failed for shutdown event");
}
if(!SetEvent(shutdown_handle))
{
die("SetEvent() failed");
}
}
/*
Change service configuration (binPath) to point to mysqld from
this installation.
*/
static void change_service_config()
{
char defaults_file[MAX_PATH];
char default_character_set[64];
char buf[MAX_PATH];
char commandline[3*MAX_PATH + 19];
int i;
scm= OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(!scm)
die("OpenSCManager failed with %u", GetLastError());
service= OpenService(scm, opt_service, SERVICE_ALL_ACCESS);
if (!service)
die("OpenService failed with %u", GetLastError());
BYTE config_buffer[8*1024];
LPQUERY_SERVICE_CONFIGW config= (LPQUERY_SERVICE_CONFIGW)config_buffer;
DWORD size= sizeof(config_buffer);
DWORD needed;
if (!QueryServiceConfigW(service, config, size, &needed))
die("QueryServiceConfig failed with %u", GetLastError());
mysqld_service_properties props;
if (get_mysql_service_properties(config->lpBinaryPathName, &props))
{
die("Not a valid MySQL service");
}
int my_major= MYSQL_VERSION_ID/10000;
int my_minor= (MYSQL_VERSION_ID %10000)/100;
int my_patch= MYSQL_VERSION_ID%100;
if(my_major < props.version_major ||
(my_major == props.version_major && my_minor < props.version_minor))
{
die("Can not downgrade, the service is currently running as version %d.%d.%d"
", my version is %d.%d.%d", props.version_major, props.version_minor,
props.version_patch, my_major, my_minor, my_patch);
}
if(props.inifile[0] == 0)
{
/*
Weird case, no --defaults-file in service definition, need to create one.
*/
sprintf_s(props.inifile, MAX_PATH, "%s\\my.ini", props.datadir);
}
/*
Write datadir to my.ini, after converting backslashes to
unix style slashes.
*/
strcpy_s(buf, MAX_PATH, props.datadir);
for(i= 0; buf[i]; i++)
{
if (buf[i] == '\\')
buf[i]= '/';
}
WritePrivateProfileString("mysqld", "datadir",buf, props.inifile);
/*
Remove basedir from defaults file, otherwise the service wont come up in
the new version, and will complain about mismatched message file.
*/
WritePrivateProfileString("mysqld", "basedir",NULL, props.inifile);
/*
Replace default-character-set with character-set-server, to avoid
"default-character-set is deprecated and will be replaced ..."
message.
*/
default_character_set[0]= 0;
GetPrivateProfileString("mysqld", "default-character-set", NULL,
default_character_set, sizeof(default_character_set), defaults_file);
if (default_character_set[0])
{
WritePrivateProfileString("mysqld", "default-character-set", NULL,
defaults_file);
WritePrivateProfileString("mysqld", "character-set-server",
default_character_set, defaults_file);
}
sprintf(defaults_file_param,"--defaults-file=%s", props.inifile);
sprintf_s(commandline, "\"%s\" \"%s\" \"%s\"", mysqld_path,
defaults_file_param, opt_service);
if (!ChangeServiceConfig(service, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE,
SERVICE_NO_CHANGE, commandline, NULL, NULL, NULL, NULL, NULL, NULL))
{
die("ChangeServiceConfig failed with %u", GetLastError());
}
}
int main(int argc, char **argv)
{
int error;
MY_INIT(argv[0]);
char bindir[FN_REFLEN];
char *p;
/* Parse options */
if ((error= handle_options(&argc, &argv, my_long_options, get_one_option)))
die("");
if (!opt_service)
die("--service=# parameter is mandatory");
/*
Get full path to mysqld, we need it when changing service configuration.
Assume installation layout, i.e mysqld.exe, mysqladmin.exe, mysqlupgrade.exe
and mysql_upgrade_service.exe are in the same directory.
*/
GetModuleFileName(NULL, bindir, FN_REFLEN);
p= strrchr(bindir, FN_LIBCHAR);
if(p)
{
*p= 0;
}
sprintf_s(mysqld_path, "%s\\mysqld.exe", bindir);
sprintf_s(mysqladmin_path, "%s\\mysqladmin.exe", bindir);
sprintf_s(mysqlupgrade_path, "%s\\mysql_upgrade.exe", bindir);
char *paths[]= {mysqld_path, mysqladmin_path, mysqlupgrade_path};
for(int i= 0; i< 3;i++)
{
if(GetFileAttributes(paths[i]) == INVALID_FILE_ATTRIBUTES)
die("File %s does not exist", paths[i]);
}
/*
Messages written on stdout should not be buffered, GUI upgrade program
reads them from pipe and uses as progress indicator.
*/
setvbuf(stdout, NULL, _IONBF, 0);
log("Phase 1/8: Changing service configuration");
change_service_config();
log("Phase 2/8: Stopping service");
stop_mysqld_service();
/*
Start mysqld.exe as non-service skipping privileges (so we do not
care about the password). But disable networking and enable pipe
for communication, for security reasons.
*/
char socket_param[FN_REFLEN];
sprintf_s(socket_param,"--socket=mysql_upgrade_service_%d",
GetCurrentProcessId());
log("Phase 3/8: Starting mysqld for upgrade");
mysqld_process= (HANDLE)run_tool(P_NOWAIT, mysqld_path,
defaults_file_param, "--skip-networking", "--skip-grant-tables",
"--enable-named-pipe", socket_param, NULL);
if (mysqld_process == INVALID_HANDLE_VALUE)
{
die("Cannot start mysqld.exe process, errno=%d", errno);
}
log("Phase 4/8: Waiting for startup to complete");
DWORD start_duration_ms= 0;
for(;;)
{
if (WaitForSingleObject(mysqld_process, 0) != WAIT_TIMEOUT)
die("mysqld.exe did not start");
if (run_tool(P_WAIT, mysqladmin_path, "--protocol=pipe",
socket_param, "ping", NULL) == 0)
{
break;
}
if (start_duration_ms > startup_timeout*1000)
die("Server did not come up in %d seconds",startup_timeout);
Sleep(500);
start_duration_ms+= 500;
}
log("Phase 5/8: Running mysql_upgrade");
int upgrade_err= (int) run_tool(P_WAIT, mysqlupgrade_path,
"--protocol=pipe", "--force", socket_param,
NULL);
if (upgrade_err)
die("mysql_upgrade failed with error code %d\n", upgrade_err);
log("Phase 6/8: Initiating server shutdown");
initiate_mysqld_shutdown();
log("Phase 7/8: Waiting for shutdown to complete");
if (WaitForSingleObject(mysqld_process, shutdown_timeout*1000)
!= WAIT_OBJECT_0)
{
/* Shutdown takes too long */
die("mysqld does not shutdown.");
}
CloseHandle(mysqld_process);
mysqld_process= NULL;
log("Phase 8/8: Starting service%s",
(initial_service_state == SERVICE_RUNNING)?"":" (skipped)");
if (initial_service_state == SERVICE_RUNNING)
{
StartService(service, NULL, NULL);
}
log("Service '%s' successfully upgraded.\nLog file is written to %s",
opt_service, logfile_path);
CloseServiceHandle(service);
CloseServiceHandle(scm);
if (logfile_handle)
CloseHandle(logfile_handle);
my_end(0);
exit(0);
}
\ No newline at end of file
# Copyright (c) 2006, 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
SET (dirs
danish
german
slovak
dutch
greek
norwegian
spanish
english
hungarian
norwegian-ny
swedish
italian
polish
ukrainian
japanese
portuguese
romanian
estonian
korean
russian
czech
french
serbian
)
SET(files
errmsg.txt
)
FOREACH (dir ${dirs})
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${dir}
DESTINATION share COMPONENT Server)
ENDFOREACH()
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/charsets DESTINATION share COMPONENT Server
PATTERN "languages.html" EXCLUDE
)
INSTALL(FILES ${files} DESTINATION share COMPONENT Server)
......@@ -15,7 +15,7 @@
## Process this file with automake to create Makefile.in
EXTRA_DIST= errmsg.txt
EXTRA_DIST= errmsg.txt CMakeLists.txt
dist-hook:
for dir in charsets @AVAILABLE_LANGUAGES@; do \
......
/*
Get Properties of an existing mysqld Windows service
*/
#include <windows.h>
#include <winsvc.h>
#include "winservice.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
/*
Get version from an executable file
*/
void get_file_version(const char *path, int *major, int *minor, int *patch)
{
DWORD version_handle;
char *ver= 0;
VS_FIXEDFILEINFO info;
UINT len;
DWORD size;
void *p;
*major= *minor= *patch= 0;
size= GetFileVersionInfoSize(path, &version_handle);
if (size == 0)
return;
ver= (char *)malloc(size);
if(!GetFileVersionInfo(path, version_handle, size, ver))
goto end;
if(!VerQueryValue(ver,"\\",&p,&len))
goto end;
memcpy(&info,p ,sizeof(VS_FIXEDFILEINFO));
*major= (info.dwFileVersionMS & 0xFFFF0000) >> 16;
*minor= (info.dwFileVersionMS & 0x0000FFFF);
*patch= (info.dwFileVersionLS & 0xFFFF0000) >> 16;
end:
free(ver);
}
void normalize_path(char *path, size_t size)
{
char buf[MAX_PATH];
if (*path== '"')
{
char *p;
strcpy_s(buf, MAX_PATH, path+1);
p= strchr(buf, '"');
if (p)
*p=0;
}
else
strcpy_s(buf, MAX_PATH, path);
GetFullPathName(buf, MAX_PATH, buf, NULL);
strcpy_s(path, size, buf);
}
/*
Retrieve some properties from windows mysqld service binary path.
We're interested in ini file location and datadir, and also in version of
the data. We tolerate missing mysqld.exe.
Note that this function carefully avoids using mysql libraries (e.g dbug),
since it is used in unusual environments (windows installer, MFC), where we
do not have much control over how threads are created and destroyed, so we
cannot assume MySQL thread initilization here.
*/
int get_mysql_service_properties(const wchar_t *bin_path,
mysqld_service_properties *props)
{
int numargs;
wchar_t mysqld_path[MAX_PATH + 4];
wchar_t *file_part;
wchar_t **args= NULL;
int retval= 1;
BOOL have_inifile;
props->datadir[0]= 0;
props->inifile[0]= 0;
props->mysqld_exe[0]= 0;
props->version_major= 0;
props->version_minor= 0;
props->version_patch= 0;
args= CommandLineToArgvW(bin_path, &numargs);
if(numargs == 2)
{
/*
There are rare cases where service config does not have
--defaults-filein the binary parth . There services were registered with
plain mysqld --install, the data directory is next to "bin" in this case.
Service name (second parameter) must be MySQL.
*/
if(wcscmp(args[1], L"MySQL") != 0)
goto end;
have_inifile= FALSE;
}
else if(numargs == 3)
{
have_inifile= TRUE;
}
else
{
goto end;
}
if(have_inifile && wcsncmp(args[1], L"--defaults-file=", 16) != 0)
goto end;
GetFullPathNameW(args[0], MAX_PATH, mysqld_path, &file_part);
if(wcsstr(mysqld_path, L".exe") == NULL)
wcscat(mysqld_path, L".exe");
if(wcsicmp(file_part, L"mysqld.exe") != 0 &&
wcsicmp(file_part, L"mysqld.exe") != 0 &&
wcsicmp(file_part, L"mysqld-nt.exe") != 0)
{
/* The service executable is not mysqld. */
goto end;
}
wcstombs(props->mysqld_exe, mysqld_path, MAX_PATH);
/* If mysqld.exe exists, try to get its version from executable */
if (GetFileAttributes(props->mysqld_exe) != INVALID_FILE_ATTRIBUTES)
{
get_file_version(props->mysqld_exe, &props->version_major,
&props->version_minor, &props->version_patch);
}
if (have_inifile)
{
/* We have --defaults-file in service definition. */
wcstombs(props->inifile, args[1]+16, MAX_PATH);
normalize_path(props->inifile, MAX_PATH);
if (GetFileAttributes(props->inifile) != INVALID_FILE_ATTRIBUTES)
{
GetPrivateProfileString("mysqld", "datadir", NULL, props->datadir, MAX_PATH,
props->inifile);
}
else
{
/*
Service will start even with invalid .ini file, using lookup for
datadir relative to mysqld.exe. This is equivalent to the case no ini
file used.
*/
props->inifile[0]= 0;
have_inifile= FALSE;
}
}
if(!have_inifile)
{
/*
Hard, although a rare case, we're guessing datadir and defaults-file.
On Windows, defaults-file is traditionally install-root\my.ini
and datadir is install-root\data
*/
char install_root[MAX_PATH];
int i;
char *p;
/*
Get the install root(parent of bin directory where mysqld.exe)
is located.
*/
strcpy_s(install_root, MAX_PATH, props->mysqld_exe);
for (i=0; i< 2; i++)
{
p= strrchr(install_root, '\\');
if(!p)
goto end;
*p= 0;
}
/* Look for my.ini, my.cnf in the install root */
sprintf_s(props->inifile, MAX_PATH, "%s\\my.ini", install_root);
if (GetFileAttributes(props->inifile) == INVALID_FILE_ATTRIBUTES)
{
sprintf_s(props->inifile, MAX_PATH, "%s\\my.cnf", install_root);
}
if (GetFileAttributes(props->inifile) != INVALID_FILE_ATTRIBUTES)
{
/* Ini file found, get datadir from there */
GetPrivateProfileString("mysqld", "datadir", NULL, props->datadir,
MAX_PATH, props->inifile);
}
else
{
/* No ini file */
props->inifile[0]= 0;
}
/* Try datadir in install directory.*/
if (props->datadir[0] == 0)
{
sprintf_s(props->datadir, MAX_PATH, "%s\\data", install_root);
}
}
if (props->datadir[0])
{
normalize_path(props->datadir, MAX_PATH);
/* Check if datadir really exists */
if (GetFileAttributes(props->datadir) == INVALID_FILE_ATTRIBUTES)
goto end;
}
else
{
/* There is no datadir in ini file, bail out.*/
goto end;
}
/*
If version could not be determined so far, try mysql_upgrade_info in
database directory.
*/
if(props->version_major == 0)
{
char buf[MAX_PATH];
FILE *mysql_upgrade_info;
sprintf_s(buf, MAX_PATH, "%s\\mysql_upgrade_info", props->datadir);
mysql_upgrade_info= fopen(buf, "r");
if(mysql_upgrade_info)
{
if (fgets(buf, MAX_PATH, mysql_upgrade_info))
{
int major,minor,patch;
if (sscanf(buf, "%d.%d.%d", &major, &minor, &patch) == 3)
{
props->version_major= major;
props->version_minor= minor;
props->version_patch= patch;
}
}
}
}
retval = 0;
end:
LocalFree((HLOCAL)args);
return retval;
}
\ No newline at end of file
/*
Extract properties of a windows service binary path
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <windows.h>
typedef struct mysqld_service_properties_st
{
char mysqld_exe[MAX_PATH];
char inifile[MAX_PATH];
char datadir[MAX_PATH];
int version_major;
int version_minor;
int version_patch;
} mysqld_service_properties;
extern int get_mysql_service_properties(const wchar_t *bin_path,
mysqld_service_properties *props);
#ifdef __cplusplus
}
#endif
......@@ -49,23 +49,25 @@ SET(ARIA_SOURCES ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c
MYSQL_STORAGE_ENGINE(ARIA)
IF(NOT SOURCE_SUBLIBS)
ADD_DEPENDENCIES(aria GenError)
ADD_EXECUTABLE(aria_ftdump maria_ftdump.c)
MYSQL_ADD_EXECUTABLE(aria_ftdump maria_ftdump.c)
TARGET_LINK_LIBRARIES(aria_ftdump aria myisam mysys dbug strings zlib wsock32)
ADD_EXECUTABLE(aria_chk maria_chk.c)
MYSQL_ADD_EXECUTABLE(aria_chk maria_chk.c)
TARGET_LINK_LIBRARIES(aria_chk aria myisam mysys dbug strings zlib wsock32)
ADD_EXECUTABLE(aria_read_log maria_read_log.c)
MYSQL_ADD_EXECUTABLE(aria_read_log maria_read_log.c)
TARGET_LINK_LIBRARIES(aria_read_log aria myisam mysys dbug strings zlib wsock32)
ADD_EXECUTABLE(aria_pack maria_pack.c)
MYSQL_ADD_EXECUTABLE(aria_pack maria_pack.c)
TARGET_LINK_LIBRARIES(aria_pack aria myisam mysys dbug strings zlib wsock32)
ADD_EXECUTABLE(aria_dump_log maria_dump_log.c unittest/ma_loghandler_examples.c)
MYSQL_ADD_EXECUTABLE(aria_dump_log maria_dump_log.c unittest/ma_loghandler_examples.c)
TARGET_LINK_LIBRARIES(aria_dump_log aria myisam mysys dbug strings zlib wsock32)
ADD_EXECUTABLE(ma_test1 ma_test1.c)
TARGET_LINK_LIBRARIES(ma_test1 aria myisam mysys dbug strings zlib wsock32)
......@@ -80,15 +82,4 @@ TARGET_LINK_LIBRARIES(ma_rt_test aria myisam mysys dbug strings zlib wsock32)
ADD_EXECUTABLE(ma_sp_test ma_sp_test.c)
TARGET_LINK_LIBRARIES(ma_sp_test aria myisam mysys dbug strings zlib wsock32)
IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("aria_ftdump" "asInvoker")
MYSQL_EMBED_MANIFEST("aria_chk" "asInvoker")
MYSQL_EMBED_MANIFEST("aria_read_log" "asInvoker")
MYSQL_EMBED_MANIFEST("aria_pack" "asInvoker")
ENDIF(EMBED_MANIFESTS)
INSTALL(TARGETS aria_ftdump aria_chk aria_read_log aria_pack aria_dump_log
DESTINATION bin COMPONENT runtime)
ENDIF(NOT SOURCE_SUBLIBS)
......@@ -31,16 +31,16 @@ SET(MYISAM_SOURCES ft_boolean_search.c ft_nlq_search.c ft_parser.c ft_static.c
MYSQL_STORAGE_ENGINE(MYISAM)
IF(NOT SOURCE_SUBLIBS)
ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c)
MYSQL_ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c DESTINATION bin)
TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys debug dbug strings zlib wsock32)
ADD_EXECUTABLE(myisamchk myisamchk.c)
MYSQL_ADD_EXECUTABLE(myisamchk myisamchk.c DESTINATION bin)
TARGET_LINK_LIBRARIES(myisamchk myisam mysys debug dbug strings zlib wsock32)
ADD_EXECUTABLE(myisamlog myisamlog.c)
MYSQL_ADD_EXECUTABLE(myisamlog myisamlog.c DESTINATION bin)
TARGET_LINK_LIBRARIES(myisamlog myisam mysys debug dbug strings zlib wsock32)
ADD_EXECUTABLE(myisampack myisampack.c)
MYSQL_ADD_EXECUTABLE(myisampack myisampack.c DESTINATION bin)
TARGET_LINK_LIBRARIES(myisampack myisam mysys debug dbug strings zlib wsock32)
ADD_EXECUTABLE(mi_test1 mi_test1.c)
......@@ -60,13 +60,4 @@ IF(NOT SOURCE_SUBLIBS)
SET_TARGET_PROPERTIES(myisamchk myisampack PROPERTIES LINK_FLAGS "setargv.obj")
IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("myisam_ftdump" "asInvoker")
MYSQL_EMBED_MANIFEST("myisamchk" "asInvoker")
MYSQL_EMBED_MANIFEST("myisamlog" "asInvoker")
MYSQL_EMBED_MANIFEST("myisampack" "asInvoker")
ENDIF(EMBED_MANIFESTS)
INSTALL(TARGETS myisam_ftdump myisamchk myisamlog myisampack DESTINATION bin COMPONENT runtime)
ENDIF(NOT SOURCE_SUBLIBS)
......@@ -16,7 +16,10 @@ IF(NOT SOURCE_SUBLIBS)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/regex
${CMAKE_SOURCE_DIR}/extra/yassl/include)
${CMAKE_SOURCE_DIR}/extra/yassl/include
${CMAKE_BINARY_DIR}/include
${CMAKE_BINARY_DIR}/sql
)
STRING(TOUPPER ${engine} engine)
STRING(TOLOWER ${engine} libname)
IF(${ENGINE_BUILD_TYPE} STREQUAL "STATIC")
......@@ -33,13 +36,13 @@ IF(NOT SOURCE_SUBLIBS)
#Create a DLL.The name of the dll is ha_<storage_engine>.dll
#The dll is linked to the mysqld executable
SET(dyn_libname ha_${libname})
ADD_LIBRARY(${dyn_libname} SHARED ${${engine}_SOURCES})
TARGET_LINK_LIBRARIES (${dyn_libname} mysqlservices mysqld)
ADD_LIBRARY(${dyn_libname} MODULE ${${engine}_SOURCES})
TARGET_LINK_LIBRARIES (${dyn_libname} mysqlservices mysqld)
IF(${engine}_LIBS)
TARGET_LINK_LIBRARIES(${dyn_libname} ${${engine}_LIBS})
ENDIF(${engine}_LIBS)
# Install the plugin
INSTALL(TARGETS ${dyn_libname} DESTINATION lib/plugin COMPONENT runtime)
MYSQL_INSTALL_TARGETS(${dyn_libname} DESTINATION lib/plugin COMPONENT Server)
MESSAGE("build ${engine} as DLL")
ENDIF(${ENGINE_BUILD_TYPE} STREQUAL "STATIC")
ENDIF(NOT SOURCE_SUBLIBS)
......
......@@ -28,6 +28,4 @@ SET(STRINGS_SOURCES bchange.c bfill.c bmove512.c bmove_upp.c ctype-big5.c ctype-
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(strings ${STRINGS_SOURCES})
INSTALL(TARGETS strings DESTINATION lib/opt COMPONENT runtime) # TODO: Component
ENDIF(NOT SOURCE_SUBLIBS)
......@@ -25,4 +25,4 @@ TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient_notls wsock32)
ADD_EXECUTABLE(bug25714 bug25714.c)
TARGET_LINK_LIBRARIES(bug25714 mysqlclient_notls wsock32)
INSTALL(TARGETS mysql_client_test bug25714 DESTINATION bin COMPONENT runtime)
INSTALL(TARGETS mysql_client_test DESTINATION bin COMPONENT Test)
......@@ -18,5 +18,39 @@ EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat build-vs9.bat \
build-vs9_x64.bat configure.js README mysql_manifest.cmake \
create_manifest.js create_def_file.js build-nmake.bat \
build-nmake-x64.bat configure-mariadb.sh make_mariadb_win_dist \
build-vs10.bat build-vs10_x64.bat
build-vs10.bat build-vs10_x64.bat \
cmake/cmake_parse_arguments.cmake \
cmake/cpack_source_ignore_files.cmake \
cmake/create_initial_db.cmake.in \
cmake/install_layout.cmake \
cmake/install_macros.cmake \
cmake/mysql_add_executable.cmake \
cmake/mysql_version.cmake \
cmake/package_name.cmake \
cmake/versioninfo.rc.in \
cmake/dummy.in \
packaging/CMakeLists.txt \
packaging/CPackWixConfig.cmake \
packaging/create_msi.cmake.in \
packaging/custom_ui.wxs \
packaging/extra.wxs.in \
packaging/COPYING.rtf \
packaging/mysql_server.wxs.in \
packaging/ca/CMakeLists.txt \
packaging/ca/CustomAction.cpp \
packaging/ca/CustomAction.def \
packaging/ca/CustomAction.rc \
packaging/WixUIBannerBmp.jpg \
packaging/WixUIDialogBmp.jpg \
upgrade_wizard/resource.h \
upgrade_wizard/stdafx.h \
upgrade_wizard/targetver.h \
upgrade_wizard/upgrade.cpp \
upgrade_wizard/upgrade.h \
upgrade_wizard/upgrade.rc \
upgrade_wizard/upgradeDlg.cpp \
upgrade_wizard/upgradeDlg.h \
upgrade_wizard/upgrade_wizard.exe.manifest \
upgrade_wizard/CMakeLists.txt \
upgrade_wizard/res/upgrade.ico \
upgrade_wizard/res/upgrade.rc2
set build_64_bit=
set build_msi=
set generator=
set scriptdir=%~dp0
:: Process all the arguments from the command line
::
:process_arguments
if "%~1"=="" goto :do_work
if "%~1"=="-h" goto :help
if "%~1"=="-msi" set build_msi=1
if "%~1"=="-G" set generator=-G "%~2"
shift
goto :process_arguments
:help
echo "build_maria_release [-h] [-msi] [-G <Generator>]"
:die
echo error occured.
popd
exit /b 1
:do_work
:: We're doing out-of-source build to ensure nobody has broken it:)
pushd %scriptdir%
cd ..
rd /s /q xxx
mkdir xxx
cd xxx
cmake .. -DWITH_EMBEDDED_SERVER=1 %generator%
if %ERRORLEVEL% NEQ 0 goto :die
cmake --build . --config Debug
if %ERRORLEVEL% NEQ 0 goto :die
cmake --build . --config RelWithDebInfo --target package
if %ERRORLEVEL% NEQ 0 goto :die
if "%build_msi%"=="1" (
cmake --build . --config RelWithDebInfo --target win\packaging\msi
if %ERRORLEVEL% NEQ 0 goto :die
)
xcopy /y *.zip ..
xcopy /y *.msi ..
popd
\ No newline at end of file
# Copyright (C) 2007 MySQL AB, 2009 Sun Microsystems,Inc
#
# 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
# Handy macro to parse macro arguments
MACRO(MYSQL_PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
SET(larg_names ${arg_names})
LIST(FIND larg_names "${arg}" is_arg_name)
IF (is_arg_name GREATER -1)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name GREATER -1)
SET(loption_names ${option_names})
LIST(FIND loption_names "${arg}" is_option)
IF (is_option GREATER -1)
SET(${prefix}_${arg} TRUE)
ELSE (is_option GREATER -1)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option GREATER -1)
ENDIF (is_arg_name GREATER -1)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO()
\ No newline at end of file
SET(CPACK_SOURCE_IGNORE_FILES
\\\\.bzr/
\\\\.bzr-mysql
\\\\.bzrignore
CMakeCache\\\\.txt
cmake_dist\\\\.cmake
CPackSourceConfig\\\\.cmake
CPackConfig.cmake
/cmake_install\\\\.cmake
/CTestTestfile\\\\.cmake
/CMakeFiles/
/version_resources/
/_CPack_Packages/
$\\\\.gz
$\\\\.zip
/CMakeFiles/
/version_resources/
/_CPack_Packages/
scripts/make_binary_distribution$
scripts/msql2mysql$
scripts/mysql_config$
scripts/mysql_convert_table_format$
scripts/mysql_find_rows$
scripts/mysql_fix_extensions$
scripts/mysql_install_db$
scripts/mysql_secure_installation$
scripts/mysql_setpermission$
scripts/mysql_zap$
scripts/mysqlaccess$
scripts/mysqld_multi$
scripts/mysqld_safe$
scripts/mysqldumpslow$
scripts/mysqlhotcopy$
Makefile$
include/config\\\\.h$
include/my_config\\\\.h$
/autom4te\\\\.cache/
errmsg\\\\.sys$
#
)
# Copyright (C) 2009 Sun Microsystems, Inc
#
# 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
# This script creates initial database for packaging on Windows
SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@")
SET(CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@")
SET(MYSQLD_EXECUTABLE "@MYSQLD_EXECUTABLE@")
SET(CMAKE_CFG_INTDIR "@CMAKE_CFG_INTDIR@")
SET(WIN32 "@WIN32@")
# Force Visual Studio to output to stdout
IF(ENV{VS_UNICODE_OUTPUT})
SET ($ENV{VS_UNICODE_OUTPUT})
ENDIF()
IF(CMAKE_CFG_INTDIR AND CONFIG)
#Resolve build configuration variables
STRING(REPLACE "${CMAKE_CFG_INTDIR}" ${CONFIG} MYSQLD_EXECUTABLE
"${MYSQLD_EXECUTABLE}")
ENDIF()
# Create bootstrapper SQL script
FILE(WRITE bootstrap.sql "use mysql;\n" )
FOREACH(FILENAME mysql_system_tables.sql mysql_system_tables_data.sql)
FILE(STRINGS ${CMAKE_SOURCE_DIR}/scripts/${FILENAME} CONTENTS)
FOREACH(STR ${CONTENTS})
IF(NOT STR MATCHES "@current_hostname")
FILE(APPEND bootstrap.sql "${STR}\n")
ENDIF()
ENDFOREACH()
ENDFOREACH()
FILE(READ ${CMAKE_SOURCE_DIR}/scripts/fill_help_tables.sql CONTENTS)
FILE(APPEND bootstrap.sql ${CONTENTS})
FILE(REMOVE_RECURSE mysql)
MAKE_DIRECTORY(mysql)
IF(WIN32)
SET(CONSOLE --console)
ENDIF()
SET(BOOTSTRAP_COMMAND
${MYSQLD_EXECUTABLE}
--no-defaults
${CONSOLE}
--bootstrap
--language=${CMAKE_CURRENT_BINARY_DIR}/share/english
--basedir=.
--datadir=.
--default-storage-engine=MyISAM
--loose-skip-innodb
--loose-skip-pbxt
--loose-skip-ndbcluster
--max_allowed_packet=8M
--net_buffer_length=16K
)
GET_FILENAME_COMPONENT(CWD . ABSOLUTE)
EXECUTE_PROCESS(
COMMAND "@CMAKE_COMMAND@" -E echo Executing ${BOOTSTRAP_COMMAND}
)
EXECUTE_PROCESS (
COMMAND "@CMAKE_COMMAND@" -E echo input file bootstrap.sql, current directory ${CWD}
)
EXECUTE_PROCESS (
COMMAND ${BOOTSTRAP_COMMAND} INPUT_FILE bootstrap.sql OUTPUT_VARIABLE OUT
ERROR_VARIABLE ERR
RESULT_VARIABLE RESULT
)
IF(NOT RESULT EQUAL 0)
MESSAGE(FATAL_ERROR "Could not create initial database \n ${OUT} \n ${ERR}")
ENDIF()
# Copyright (C) 2010 Sun Microsystems, Inc
#
# 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
# The purpose of this file is to set the default installation layout.
#
# The current choices of installation layout are:
#
# STANDALONE
# Build with prefix=/usr/local/mysql, create tarball with install prefix="."
# and relative links. Windows zip uses the same tarball layout but without
# the build prefix.
#
# RPM
# Build as per default RPM layout, with prefix=/usr
#
# DEB
# Build as per STANDALONE, prefix=/opt/mysql/server-$major.$minor
#
# SVR4
# Solaris package layout suitable for pkg* tools, prefix=/opt/mysql/mysql
#
# To force a directory layout, use -DINSTALL_LAYOUT=<layout>.
#
# The default is STANDALONE.
#
# There is the possibility to further fine-tune installation directories.
# Several variables can be overwritten:
#
# - INSTALL_BINDIR (directory with client executables and scripts)
# - INSTALL_SBINDIR (directory with mysqld)
# - INSTALL_SCRIPTDIR (several scripts, rarely used)
#
# - INSTALL_LIBDIR (directory with client end embedded libraries)
# - INSTALL_PLUGINDIR (directory for plugins)
#
# - INSTALL_INCLUDEDIR (directory for MySQL headers)
#
# - INSTALL_DOCDIR (documentation)
# - INSTALL_DOCREADMEDIR (readme and similar)
# - INSTALL_MANDIR (man pages)
# - INSTALL_INFODIR (info pages)
#
# - INSTALL_SHAREDIR (location of aclocal/mysql.m4)
# - INSTALL_MYSQLSHAREDIR (MySQL character sets and localized error messages)
# - INSTALL_MYSQLTESTDIR (mysql-test)
# - INSTALL_SQLBENCHDIR (sql-bench)
# - INSTALL_SUPPORTFILESDIR (various extra support files)
#
# - INSTALL_MYSQLDATADIR (data directory)
#
# When changing this page, _please_ do not forget to update public Wiki
# http://forge.mysql.com/wiki/CMake#Fine-tuning_installation_paths
IF(NOT INSTALL_LAYOUT)
SET(DEFAULT_INSTALL_LAYOUT "STANDALONE")
ENDIF()
SET(INSTALL_LAYOUT "${DEFAULT_INSTALL_LAYOUT}"
CACHE STRING "Installation directory layout. Options are: STANDALONE (as in zip or tar.gz installer), RPM, DEB, SVR4")
IF(UNIX)
IF(INSTALL_LAYOUT MATCHES "RPM")
SET(default_prefix "/usr")
ELSEIF(INSTALL_LAYOUT MATCHES "DEB")
SET(default_prefix "/opt/mysql/server-${MYSQL_BASE_VERSION}")
# This is required to avoid "cpack -GDEB" default of prefix=/usr
SET(CPACK_SET_DESTDIR ON)
ELSEIF(INSTALL_LAYOUT MATCHES "SVR4")
SET(default_prefix "/opt/mysql/mysql")
ELSE()
SET(default_prefix "/usr/local/mysql")
ENDIF()
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX ${default_prefix}
CACHE PATH "install prefix" FORCE)
ENDIF()
SET(VALID_INSTALL_LAYOUTS "RPM" "STANDALONE" "DEB" "SVR4")
LIST(FIND VALID_INSTALL_LAYOUTS "${INSTALL_LAYOUT}" ind)
IF(ind EQUAL -1)
MESSAGE(FATAL_ERROR "Invalid INSTALL_LAYOUT parameter:${INSTALL_LAYOUT}."
" Choose between ${VALID_INSTALL_LAYOUTS}" )
ENDIF()
SET(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc"
CACHE PATH "config directory (for my.cnf)")
MARK_AS_ADVANCED(SYSCONFDIR)
ENDIF()
#
# STANDALONE layout
#
SET(INSTALL_BINDIR_STANDALONE "bin")
SET(INSTALL_SBINDIR_STANDALONE "bin")
SET(INSTALL_SCRIPTDIR_STANDALONE "scripts")
#
SET(INSTALL_LIBDIR_STANDALONE "lib")
SET(INSTALL_PLUGINDIR_STANDALONE "lib/plugin")
#
SET(INSTALL_INCLUDEDIR_STANDALONE "include")
#
SET(INSTALL_DOCDIR_STANDALONE "docs")
SET(INSTALL_DOCREADMEDIR_STANDALONE ".")
SET(INSTALL_MANDIR_STANDALONE "man")
SET(INSTALL_INFODIR_STANDALONE "docs")
#
SET(INSTALL_SHAREDIR_STANDALONE "share")
SET(INSTALL_MYSQLSHAREDIR_STANDALONE "share")
SET(INSTALL_MYSQLTESTDIR_STANDALONE "mysql-test")
SET(INSTALL_SQLBENCHDIR_STANDALONE ".")
SET(INSTALL_SUPPORTFILESDIR_STANDALONE "support-files")
#
SET(INSTALL_MYSQLDATADIR_STANDALONE "data")
#
# RPM layout
#
SET(INSTALL_BINDIR_RPM "bin")
SET(INSTALL_SBINDIR_RPM "sbin")
SET(INSTALL_SCRIPTDIR_RPM "bin")
#
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
SET(INSTALL_LIBDIR_RPM "lib64")
SET(INSTALL_PLUGINDIR_RPM "lib64/mysql/plugin")
ELSE()
SET(INSTALL_LIBDIR_RPM "lib")
SET(INSTALL_PLUGINDIR_RPM "lib/mysql/plugin")
ENDIF()
#
SET(INSTALL_INCLUDEDIR_RPM "include/mysql")
#
#SET(INSTALL_DOCDIR_RPM unset - installed directly by RPM)
#SET(INSTALL_DOCREADMEDIR_RPM unset - installed directly by RPM)
SET(INSTALL_INFODIR_RPM "share/info")
SET(INSTALL_MANDIR_RPM "share/man")
#
SET(INSTALL_SHAREDIR_RPM "share")
SET(INSTALL_MYSQLSHAREDIR_RPM "share/mysql")
SET(INSTALL_MYSQLTESTDIR_RPM "share/mysql-test")
SET(INSTALL_SQLBENCHDIR_RPM "")
SET(INSTALL_SUPPORTFILESDIR_RPM "share/mysql")
#
SET(INSTALL_MYSQLDATADIR_RPM "/var/lib/mysql")
#
# DEB layout
#
SET(INSTALL_BINDIR_DEB "bin")
SET(INSTALL_SBINDIR_DEB "bin")
SET(INSTALL_SCRIPTDIR_DEB "scripts")
#
SET(INSTALL_LIBDIR_DEB "lib")
SET(INSTALL_PLUGINDIR_DEB "lib/plugin")
#
SET(INSTALL_INCLUDEDIR_DEB "include")
#
SET(INSTALL_DOCDIR_DEB "docs")
SET(INSTALL_DOCREADMEDIR_DEB ".")
SET(INSTALL_MANDIR_DEB "man")
SET(INSTALL_INFODIR_DEB "docs")
#
SET(INSTALL_SHAREDIR_DEB "share")
SET(INSTALL_MYSQLSHAREDIR_DEB "share")
SET(INSTALL_MYSQLTESTDIR_DEB "mysql-test")
SET(INSTALL_SQLBENCHDIR_DEB ".")
SET(INSTALL_SUPPORTFILESDIR_DEB "support-files")
#
SET(INSTALL_MYSQLDATADIR_DEB "data")
#
# SVR4 layout
#
SET(INSTALL_BINDIR_SVR4 "bin")
SET(INSTALL_SBINDIR_SVR4 "bin")
SET(INSTALL_SCRIPTDIR_SVR4 "scripts")
#
SET(INSTALL_LIBDIR_SVR4 "lib")
SET(INSTALL_PLUGINDIR_SVR4 "lib/plugin")
#
SET(INSTALL_INCLUDEDIR_SVR4 "include")
#
SET(INSTALL_DOCDIR_SVR4 "docs")
SET(INSTALL_DOCREADMEDIR_SVR4 ".")
SET(INSTALL_MANDIR_SVR4 "man")
SET(INSTALL_INFODIR_SVR4 "docs")
#
SET(INSTALL_SHAREDIR_SVR4 "share")
SET(INSTALL_MYSQLSHAREDIR_SVR4 "share")
SET(INSTALL_MYSQLTESTDIR_SVR4 "mysql-test")
SET(INSTALL_SQLBENCHDIR_SVR4 ".")
SET(INSTALL_SUPPORTFILESDIR_SVR4 "support-files")
#
SET(INSTALL_MYSQLDATADIR_SVR4 "/var/lib/mysql")
# Clear cached variables if install layout was changed
IF(OLD_INSTALL_LAYOUT)
IF(NOT OLD_INSTALL_LAYOUT STREQUAL INSTALL_LAYOUT)
SET(FORCE FORCE)
ENDIF()
ENDIF()
SET(OLD_INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE INTERNAL "")
# Set INSTALL_FOODIR variables for chosen layout (for example, INSTALL_BINDIR
# will be defined as ${INSTALL_BINDIR_STANDALONE} by default if STANDALONE
# layout is chosen)
FOREACH(var BIN SBIN LIB MYSQLSHARE SHARE PLUGIN INCLUDE SCRIPT DOC MAN
INFO MYSQLTEST SQLBENCH DOCREADME SUPPORTFILES MYSQLDATA)
SET(INSTALL_${var}DIR ${INSTALL_${var}DIR_${INSTALL_LAYOUT}}
CACHE STRING "${var} installation directory" ${FORCE})
MARK_AS_ADVANCED(INSTALL_${var}DIR)
ENDFOREACH()
# Copyright (C) 2009 Sun Microsystems, Inc
#
# 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
GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
MACRO (INSTALL_DEBUG_SYMBOLS targets)
IF(MSVC)
FOREACH(target ${targets})
GET_TARGET_PROPERTY(location ${target} LOCATION)
GET_TARGET_PROPERTY(type ${target} TYPE)
IF(NOT INSTALL_LOCATION)
IF(type MATCHES "STATIC_LIBRARY" OR type MATCHES "MODULE_LIBRARY" OR type MATCHES "SHARED_LIBRARY")
SET(INSTALL_LOCATION "lib")
ELSEIF(type MATCHES "EXECUTABLE")
SET(INSTALL_LOCATION "bin")
ELSE()
MESSAGE(FATAL_ERROR "cannot determine type of ${target}. Don't now where to install")
ENDIF()
ENDIF()
STRING(REPLACE ".exe" ".pdb" pdb_location ${location})
STRING(REPLACE ".dll" ".pdb" pdb_location ${pdb_location})
STRING(REPLACE ".lib" ".pdb" pdb_location ${pdb_location})
IF(CMAKE_GENERATOR MATCHES "Visual Studio")
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" pdb_location ${pdb_location})
ENDIF()
IF(target STREQUAL "mysqld")
SET(comp Server)
ELSEIF(pdb_location MATCHES "mysql-test")
SET(comp Tests)
ELSE()
SET(comp Debuginfo)
ENDIF()
INSTALL(FILES ${pdb_location} DESTINATION ${INSTALL_LOCATION} COMPONENT ${comp})
ENDFOREACH()
ENDIF()
ENDMACRO()
# Installs manpage for given file (either script or executable)
#
FUNCTION(INSTALL_MANPAGE file)
IF(NOT UNIX)
RETURN()
ENDIF()
GET_FILENAME_COMPONENT(file_name "${file}" NAME)
SET(GLOB_EXPR
${CMAKE_SOURCE_DIR}/man/*${file}man.1*
${CMAKE_SOURCE_DIR}/man/*${file}man.8*
${CMAKE_BINARY_DIR}/man/*${file}man.1*
${CMAKE_BINARY_DIR}/man/*${file}man.8*
)
IF(MYSQL_DOC_DIR)
SET(GLOB_EXPR
${MYSQL_DOC_DIR}/man/*${file}man.1*
${MYSQL_DOC_DIR}/man/*${file}man.8*
${MYSQL_DOC_DIR}/man/*${file}.1*
${MYSQL_DOC_DIR}/man/*${file}.8*
${GLOB_EXPR}
)
ENDIF()
FILE(GLOB_RECURSE MANPAGES ${GLOB_EXPR})
IF(MANPAGES)
LIST(GET MANPAGES 0 MANPAGE)
STRING(REPLACE "${file}man.1" "${file}.1" MANPAGE "${MANPAGE}")
STRING(REPLACE "${file}man.8" "${file}.8" MANPAGE "${MANPAGE}")
IF(MANPAGE MATCHES "${file}.1")
SET(SECTION man1)
ELSE()
SET(SECTION man8)
ENDIF()
INSTALL(FILES "${MANPAGE}" DESTINATION "${INSTALL_MANDIR}/${SECTION}"
COMPONENT ManPages)
ENDIF()
ENDFUNCTION()
FUNCTION(INSTALL_SCRIPT)
MYSQL_PARSE_ARGUMENTS(ARG
"DESTINATION;COMPONENT"
""
${ARGN}
)
SET(script ${ARG_DEFAULT_ARGS})
IF(NOT ARG_DESTINATION)
SET(ARG_DESTINATION ${INSTALL_BINDIR})
ENDIF()
IF(ARG_COMPONENT)
SET(COMP COMPONENT ${ARG_COMPONENT})
ELSE()
SET(COMP)
ENDIF()
INSTALL(FILES
${script}
DESTINATION ${ARG_DESTINATION}
PERMISSIONS OWNER_READ OWNER_WRITE
OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE ${COMP}
)
INSTALL_MANPAGE(${script})
ENDFUNCTION()
# Install symbolic link to CMake target.
# the link is created in the same directory as target
# and extension will be the same as for target file.
MACRO(INSTALL_SYMLINK linkname target destination component)
IF(UNIX)
GET_TARGET_PROPERTY(location ${target} LOCATION)
GET_FILENAME_COMPONENT(path ${location} PATH)
GET_FILENAME_COMPONENT(name ${location} NAME)
SET(output ${path}/${linkname})
ADD_CUSTOM_COMMAND(
OUTPUT ${output}
COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${output}
COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink
${name}
${linkname}
WORKING_DIRECTORY ${path}
DEPENDS ${target}
)
ADD_CUSTOM_TARGET(symlink_${linkname}
ALL
DEPENDS ${output})
SET_TARGET_PROPERTIES(symlink_${linkname} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
IF(CMAKE_GENERATOR MATCHES "Xcode")
# For Xcode, replace project config with install config
STRING(REPLACE "${CMAKE_CFG_INTDIR}"
"\${CMAKE_INSTALL_CONFIG_NAME}" output ${output})
ENDIF()
INSTALL(FILES ${output} DESTINATION ${destination} COMPONENT ${component})
ENDIF()
ENDMACRO()
IF(WIN32)
OPTION(SIGNCODE "Sign executables and dlls with digital certificate" OFF)
MARK_AS_ADVANCED(SIGNCODE)
IF(SIGNCODE)
SET(SIGNTOOL_PARAMETERS
/a /t http://timestamp.verisign.com/scripts/timstamp.dll
CACHE STRING "parameters for signtool (list)")
FIND_PROGRAM(SIGNTOOL_EXECUTABLE signtool)
IF(NOT SIGNTOOL_EXECUTABLE)
MESSAGE(FATAL_ERROR
"signtool is not found. Signing executables not possible")
ENDIF()
IF(NOT DEFINED SIGNCODE_ENABLED)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/testsign.c "int main(){return 0;}")
MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/testsign)
TRY_COMPILE(RESULT ${CMAKE_CURRENT_BINARY_DIR}/testsign ${CMAKE_CURRENT_BINARY_DIR}/testsign.c
COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/testsign.exe
)
EXECUTE_PROCESS(COMMAND
${SIGNTOOL_EXECUTABLE} sign ${SIGNTOOL_PARAMETERS} ${CMAKE_CURRENT_BINARY_DIR}/testsign.exe
RESULT_VARIABLE ERR ERROR_QUIET OUTPUT_QUIET
)
IF(ERR EQUAL 0)
SET(SIGNCODE_ENABLED 1 CACHE INTERNAL "Can sign executables")
ELSE()
MESSAGE(STATUS "Disable authenticode signing for executables")
SET(SIGNCODE_ENABLED 0 CACHE INTERNAL "Invalid or missing certificate")
ENDIF()
ENDIF()
MARK_AS_ADVANCED(SIGNTOOL_EXECUTABLE SIGNTOOL_PARAMETERS)
ENDIF()
ENDIF()
MACRO(SIGN_TARGET)
MYSQL_PARSE_ARGUMENTS(ARG "COMPONENT" "" ${ARGN})
SET(target ${ARG_DEFAULT_ARGS})
IF(ARG_COMPONENT)
SET(comp COMPONENT ${ARG_COMPONENT})
ELSE()
SET(comp)
ENDIF()
GET_TARGET_PROPERTY(target_type ${target} TYPE)
IF(target_type AND NOT target_type MATCHES "STATIC")
GET_TARGET_PROPERTY(target_location ${target} LOCATION)
IF(CMAKE_GENERATOR MATCHES "Visual Studio")
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}"
target_location ${target_location})
ENDIF()
INSTALL(CODE
"EXECUTE_PROCESS(COMMAND
\"${SIGNTOOL_EXECUTABLE}\" sign ${SIGNTOOL_PARAMETERS} \"${target_location}\"
RESULT_VARIABLE ERR)
IF(NOT \${ERR} EQUAL 0)
MESSAGE(FATAL_ERROR \"Error signing ${target_location}\")
ENDIF()
" ${comp})
ENDIF()
ENDMACRO()
# Installs targets, also installs pdbs on Windows.
#
#
FUNCTION(MYSQL_INSTALL_TARGETS)
MYSQL_PARSE_ARGUMENTS(ARG
"DESTINATION;COMPONENT"
""
${ARGN}
)
IF(ARG_COMPONENT)
SET(COMP COMPONENT ${ARG_COMPONENT})
ENDIF()
SET(TARGETS ${ARG_DEFAULT_ARGS})
IF(NOT TARGETS)
MESSAGE(FATAL_ERROR "Need target list for MYSQL_INSTALL_TARGETS")
ENDIF()
IF(NOT ARG_DESTINATION)
MESSAGE(FATAL_ERROR "Need DESTINATION parameter for MYSQL_INSTALL_TARGETS")
ENDIF()
FOREACH(target ${TARGETS})
# If signing is required, sign executables before installing
IF(SIGNCODE AND SIGNCODE_ENABLED)
SIGN_TARGET(${target} ${COMP})
ENDIF()
# Install man pages on Unix
IF(UNIX)
GET_TARGET_PROPERTY(target_location ${target} LOCATION)
INSTALL_MANPAGE(${target_location})
ENDIF()
ENDFOREACH()
INSTALL(TARGETS ${TARGETS} DESTINATION ${ARG_DESTINATION} ${COMP})
SET(INSTALL_LOCATION ${ARG_DESTINATION} )
INSTALL_DEBUG_SYMBOLS("${TARGETS}")
SET(INSTALL_LOCATION)
ENDFUNCTION()
# Optionally install mysqld/client/embedded from debug build run. outside of the current build dir
# (unless multi-config generator is used like Visual Studio or Xcode).
# For Makefile generators we default Debug build directory to ${buildroot}/../debug.
GET_FILENAME_COMPONENT(BINARY_PARENTDIR ${CMAKE_BINARY_DIR} PATH)
SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug build")
FUNCTION(INSTALL_DEBUG_TARGET target)
MYSQL_PARSE_ARGUMENTS(ARG
"DESTINATION;RENAME;PDB_DESTINATION;COMPONENT"
""
${ARGN}
)
GET_TARGET_PROPERTY(target_type ${target} TYPE)
IF(ARG_RENAME)
SET(RENAME_PARAM RENAME ${ARG_RENAME}${CMAKE_${target_type}_SUFFIX})
ELSE()
SET(RENAME_PARAM)
ENDIF()
IF(NOT ARG_DESTINATION)
MESSAGE(FATAL_ERROR "Need DESTINATION parameter for INSTALL_DEBUG_TARGET")
ENDIF()
GET_TARGET_PROPERTY(target_location ${target} LOCATION)
IF(CMAKE_GENERATOR MATCHES "Makefiles")
STRING(REPLACE "${CMAKE_BINARY_DIR}" "${DEBUGBUILDDIR}" debug_target_location "${target_location}")
ELSE()
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "Debug" debug_target_location "${target_location}" )
ENDIF()
IF(NOT ARG_COMPONENT)
SET(ARG_COMPONENT DebugBinaries)
ENDIF()
# Define permissions
# For executable files
SET(PERMISSIONS_EXECUTABLE
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
# Permissions for shared library (honors CMAKE_INSTALL_NO_EXE which is
# typically set on Debian)
IF(CMAKE_INSTALL_SO_NO_EXE)
SET(PERMISSIONS_SHARED_LIBRARY
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ)
ELSE()
SET(PERMISSIONS_SHARED_LIBRARY ${PERMISSIONS_EXECUTABLE})
ENDIF()
# Shared modules get the same permissions as shared libraries
SET(PERMISSIONS_MODULE_LIBRARY ${PERMISSIONS_SHARED_LIBRARY})
# Define permissions for static library
SET(PERMISSIONS_STATIC_LIBRARY
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ)
INSTALL(FILES ${debug_target_location}
DESTINATION ${ARG_DESTINATION}
${RENAME_PARAM}
${PERMISSIONS_${target_type}}
CONFIGURATIONS Release RelWithDebInfo
COMPONENT ${ARG_COMPONENT}
OPTIONAL)
IF(MSVC)
GET_FILENAME_COMPONENT(ext ${debug_target_location} EXT)
STRING(REPLACE "${ext}" ".pdb" debug_pdb_target_location "${debug_target_location}" )
IF (RENAME_PARAM)
IF(NOT ARG_PDB_DESTINATION)
STRING(REPLACE "${ext}" ".pdb" "${ARG_RENAME}" pdb_rename)
SET(PDB_RENAME_PARAM RENAME "${pdb_rename}")
ENDIF()
ENDIF()
IF(NOT ARG_PDB_DESTINATION)
SET(ARG_PDB_DESTINATION "${ARG_DESTINATION}")
ENDIF()
INSTALL(FILES ${debug_pdb_target_location}
DESTINATION ${ARG_PDB_DESTINATION}
${PDB_RENAME_PARAM}
CONFIGURATIONS Release RelWithDebInfo
COMPONENT ${ARG_COMPONENT}
OPTIONAL)
ENDIF()
ENDFUNCTION()
# Copyright (C) 2009 Sun Microsystems, Inc
#
# 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
# Add executable plus some additional MySQL specific stuff
# Usage (same as for standard CMake's ADD_EXECUTABLE)
#
# MYSQL_ADD_EXECUTABLE(target source1...sourceN)
#
# MySQL specifics:
# - instruct CPack to install executable under ${CMAKE_INSTALL_PREFIX}/bin directory
# On Windows :
# - add version resource
# - instruct CPack to do autenticode signing if SIGNCODE is set
INCLUDE(cmake_parse_arguments)
FUNCTION (MYSQL_ADD_EXECUTABLE)
# Pass-through arguments for ADD_EXECUTABLE
MYSQL_PARSE_ARGUMENTS(ARG
"WIN32;MACOSX_BUNDLE;EXCLUDE_FROM_ALL;DESTINATION;COMPONENT"
""
${ARGN}
)
LIST(GET ARG_DEFAULT_ARGS 0 target)
LIST(REMOVE_AT ARG_DEFAULT_ARGS 0)
SET(sources ${ARG_DEFAULT_ARGS})
ADD_VERSION_INFO(${target} EXECUTABLE sources)
ADD_EXECUTABLE(${target} ${ARG_WIN32} ${ARG_MACOSX_BUNDLE} ${ARG_EXCLUDE_FROM_ALL} ${sources})
# tell CPack where to install
IF(NOT ARG_EXCLUDE_FROM_ALL)
IF(NOT ARG_DESTINATION)
SET(ARG_DESTINATION ${INSTALL_BINDIR})
ENDIF()
IF(ARG_COMPONENT)
SET(COMP COMPONENT ${ARG_COMPONENT})
ELSEIF(MYSQL_INSTALL_COMPONENT)
SET(COMP COMPONENT ${MYSQL_INSTALL_COMPONENT})
ELSE()
SET(COMP COMPONENT Client)
ENDIF()
MYSQL_INSTALL_TARGETS(${target} DESTINATION ${ARG_DESTINATION} ${COMP})
ENDIF()
ENDFUNCTION()
MACRO(MYSQL_GET_CONFIG_VALUE keyword var)
IF(NOT ${var})
IF (EXISTS ${CMAKE_SOURCE_DIR}/configure.in)
FILE (STRINGS ${CMAKE_SOURCE_DIR}/configure.in str REGEX "^[ ]*${keyword}=")
IF(str)
STRING(REPLACE "${keyword}=" "" str ${str})
STRING(REGEX REPLACE "[ ].*" "" str ${str})
SET(${var} ${str} CACHE INTERNAL "Config variable")
ENDIF()
ENDIF()
ENDIF()
ENDMACRO()
# Read mysql version for configure script
MACRO(GET_MYSQL_VERSION)
IF(NOT VERSION_STRING)
IF(EXISTS ${CMAKE_SOURCE_DIR}/configure.in)
FILE(STRINGS ${CMAKE_SOURCE_DIR}/configure.in str REGEX "AM_INIT_AUTOMAKE")
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][^ \\)]+" VERSION_STRING "${str}")
IF(NOT VERSION_STRING)
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION_STRING "${str}")
IF(NOT VERSION_STRING)
FILE(STRINGS configure.in str REGEX "AC_INIT\\(")
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][a-zA-Z0-9]+" VERSION_STRING "${str}")
IF(NOT VERSION_STRING)
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION_STRING "${str}")
ENDIF()
ENDIF()
ENDIF()
ENDIF()
ENDIF()
IF(NOT VERSION_STRING)
MESSAGE(FATAL_ERROR
"VERSION_STRING cannot be parsed, please specify -DVERSION_STRING=major.minor.patch-extra"
"when calling cmake")
ENDIF()
SET(VERSION ${VERSION_STRING})
STRING(REPLACE "-" "_" MYSQL_U_SCORE_VERSION "${VERSION_STRING}")
# Remove trailing (non-numeric) part of the version string
STRING(REGEX REPLACE "[^\\.0-9].*" "" VERSION_STRING ${VERSION_STRING})
STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" MAJOR_VERSION "${VERSION_STRING}")
STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" MINOR_VERSION "${VERSION_STRING}")
STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" PATCH "${VERSION_STRING}")
SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version")
SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH}")
MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH}")
MARK_AS_ADVANCED(VERSION MYSQL_VERSION_ID MYSQL_BASE_VERSION)
SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
SET(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
SET(CPACK_PACKAGE_VERSION_PATCH ${PATCH})
ENDMACRO()
# Get mysql version and other interesting variables
GET_MYSQL_VERSION()
MYSQL_GET_CONFIG_VALUE("PROTOCOL_VERSION" PROTOCOL_VERSION)
MYSQL_GET_CONFIG_VALUE("DOT_FRM_VERSION" DOT_FRM_VERSION)
MYSQL_GET_CONFIG_VALUE("MYSQL_TCP_PORT_DEFAULT" MYSQL_TCP_PORT_DEFAULT)
MYSQL_GET_CONFIG_VALUE("MYSQL_UNIX_ADDR_DEFAULT" MYSQL_UNIX_ADDR_DEFAULT)
MYSQL_GET_CONFIG_VALUE("SHARED_LIB_MAJOR_VERSION" SHARED_LIB_MAJOR_VERSION)
IF(NOT MYSQL_TCP_PORT_DEFAULT)
SET(MYSQL_TCP_PORT_DEFAULT "3306")
ENDIF()
IF(NOT MYSQL_TCP_PORT)
SET(MYSQL_TCP_PORT ${MYSQL_TCP_PORT_DEFAULT})
SET(MYSQL_TCP_PORT_DEFAULT "0")
ELSEIF(MYSQL_TCP_PORT EQUAL MYSQL_TCP_PORT_DEFAULT)
SET(MYSQL_TCP_PORT_DEFAULT "0")
ENDIF()
IF(NOT MYSQL_UNIX_ADDR)
SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
ENDIF()
IF(NOT COMPILATION_COMMENT)
SET(COMPILATION_COMMENT "Source distribution")
ENDIF()
INCLUDE(package_name)
IF(NOT CPACK_PACKAGE_FILE_NAME)
GET_PACKAGE_FILE_NAME(CPACK_PACKAGE_FILE_NAME)
ENDIF()
IF(NOT CPACK_SOURCE_PACKAGE_FILE_NAME)
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-${VERSION}")
ENDIF()
SET(CPACK_PACKAGE_CONTACT "MariaDB team <build@mysql.com>")
SET(CPACK_PACKAGE_VENDOR "Monty Program AB")
SET(CPACK_SOURCE_GENERATOR "TGZ")
INCLUDE(cpack_source_ignore_files)
# Defintions for windows version resources
SET(PRODUCTNAME "MariaDB Server")
SET(COMPANYNAME ${CPACK_PACKAGE_VENDOR})
# Windows 'date' command has unpredictable output, so cannot rely on it to
# set MYSQL_COPYRIGHT_YEAR - if someone finds a portable way to do so then
# it might be useful
#IF (WIN32)
# EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE TMP_DATE)
# STRING(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" MYSQL_COPYRIGHT_YEAR ${TMP_DATE})
IF(UNIX)
EXECUTE_PROCESS(COMMAND "date" "+%Y" OUTPUT_VARIABLE MYSQL_COPYRIGHT_YEAR OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF()
# Add version information to the exe and dll files
# Refer to http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx
# for more info.
IF(MSVC)
GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
SET(FILETYPE VFT_APP)
CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
${CMAKE_BINARY_DIR}/versioninfo_exe.rc)
SET(FILETYPE VFT_DLL)
CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
${CMAKE_BINARY_DIR}/versioninfo_dll.rc)
FUNCTION(ADD_VERSION_INFO target target_type sources_var)
IF("${target_type}" MATCHES "SHARED" OR "${target_type}" MATCHES "MODULE")
SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)
ELSEIF("${target_type}" MATCHES "EXE")
SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_exe.rc)
ENDIF()
SET(${sources_var} ${${sources_var}} ${rcfile} PARENT_SCOPE)
ENDFUNCTION()
ELSE()
FUNCTION(ADD_VERSION_INFO)
ENDFUNCTION()
ENDIF()
# Copyright (C) 2010 Sun Microsystems, Inc
#
# 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
# Produce meaningful package name for the binary package
# The logic is rather involved with special cases for different OSes
INCLUDE(CheckTypeSize)
CHECK_TYPE_SIZE("void *" SIZEOF_VOIDP)
MACRO(GET_PACKAGE_FILE_NAME Var)
IF(NOT VERSION)
MESSAGE(FATAL_ERROR
"Variable VERSION needs to be set prior to calling GET_PACKAGE_FILE_NAME")
ENDIF()
IF(NOT SYSTEM_NAME_AND_PROCESSOR)
SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 1)
SET(DEFAULT_PLATFORM ${CMAKE_SYSTEM_NAME})
SET(DEFAULT_MACHINE ${CMAKE_SYSTEM_PROCESSOR})
IF(SIZEOF_VOIDP EQUAL 8)
SET(64BIT 1)
ENDIF()
IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 0)
SET(DEFAULT_PLATFORM "win")
IF(64BIT)
SET(DEFAULT_MACHINE "x64")
ELSE()
SET(DEFAULT_MACHINE "32")
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
IF(NOT 64BIT AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
SET(DEFAULT_MACHINE "i686")
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
# SunOS 5.10=> solaris10
STRING(REPLACE "5." "" VER "${CMAKE_SYSTEM_VERSION}")
SET(DEFAULT_PLATFORM "solaris${VER}")
IF(64BIT)
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386")
SET(DEFAULT_MACHINE "x86_64")
ELSE()
SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit")
ENDIF()
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
STRING(REPLACE "B." "" VER "${CMAKE_SYSTEM_VERSION}")
SET(DEFAULT_PLATFORM "hpux${VER}")
IF(64BIT)
SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit")
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "AIX")
SET(DEFAULT_PLATFORM "${CMAKE_SYSTEM_NAME}5.${CMAKE_SYSTEM_VERSION}")
IF(64BIT)
SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit")
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
STRING(REGEX MATCH "[0-9]+\\.[0-9]+" VER "${CMAKE_SYSTEM_VERSION}")
SET(DEFAULT_PLATFORM "${CMAKE_SYSTEM_NAME}${VER}")
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64")
SET(DEFAULT_MACHINE "x86_64")
IF(NOT 64BIT)
SET(DEFAULT_MACHINE "i386")
ENDIF()
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
IF(CMAKE_OSX_DEPLOYMENT_TARGET)
SET(DEFAULT_PLATFORM "osx${CMAKE_OSX_DEPLOYMENT_TARGET}")
ELSE()
SET(VER "${CMAKE_SYSTEM_VERSION}")
STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" VER "${VER}")
# Subtract 4 from Darwin version to get correct osx10.X
MATH(EXPR VER "${VER} -4")
SET(DEFAULT_PLATFORM "osx10.${VER}")
ENDIF()
LIST(LENGTH CMAKE_OSX_ARCHITECTURES LEN)
IF(LEN GREATER 1)
SET(DEFAULT_MACHINE "universal")
ELSE()
SET(DEFAULT_MACHINE "${CMAKE_OSX_ARCHITECTURES}")
IF(NOT DEFAULT_MACHINE)
IF(CMAKE_SIZEOF_VOIPD EQUAL 4)
SET(DEFAULT_MACHINE "i386")
ELSE()
SET(DEFAULT_MACHINE "x86_64")
ENDIF()
ENDIF()
ENDIF()
IF(DEFAULT_MACHINE MATCHES "i386")
SET(DEFAULT_MACHINE "x86")
ENDIF()
ENDIF()
IF(NOT PLATFORM)
SET(PLATFORM ${DEFAULT_PLATFORM})
ENDIF()
IF(NOT MACHINE)
SET(MACHINE ${DEFAULT_MACHINE})
ENDIF()
IF(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE)
SET(SYSTEM_NAME_AND_PROCESSOR "${PLATFORM}-${MACHINE}")
ELSE()
SET(SYSTEM_NAME_AND_PROCESSOR "${PLATFORM}${MACHINE}")
ENDIF()
ENDIF()
IF(SHORT_PRODUCT_TAG)
SET(PRODUCT_TAG "-${SHORT_PRODUCT_TAG}")
ELSEIF(MYSQL_SERVER_SUFFIX)
SET(PRODUCT_TAG "${MYSQL_SERVER_SUFFIX}") # Already has a leading dash
ELSE()
SET(PRODUCT_TAG)
ENDIF()
SET(package_name "mariadb${PRODUCT_TAG}-${MYSQL_NO_DASH_VERSION}-${SYSTEM_NAME_AND_PROCESSOR}")
# Sometimes package suffix is added (something like "-icc-glibc23")
IF(PACKAGE_SUFFIX)
SET(package_name "${package_name}${PACKAGE_SUFFIX}")
ENDIF()
STRING(TOLOWER ${package_name} package_name)
SET(${Var} ${package_name})
ENDMACRO()
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH@,0
PRODUCTVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH@,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS__WINDOWS32
FILETYPE @FILETYPE@
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@.0\0"
VALUE "ProductVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@.0\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
......@@ -19,6 +19,13 @@ The default is to the builds and create 32 bit packages.
EOF
}
if test -f win/build_maria_release.bat
then
cmd /c win\\build_maria_release.bat "$@"
exit $?
fi
# The default settings
CMAKE_GENERATOR="Visual Studio 9 2008"
ARCH="win32"
......
# 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"
"$ENV{ProgramFiles}/Windows Installer XML v3.6/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")
IF(BUILD_RELEASE)
MESSAGE(FATAL_ERROR
"Can't find Wix. It is necessary for producing official package"
)
ENDIF()
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 mysql_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)
{\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
}
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'
/>
"
)
# 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)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql)
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 winservice)
/* 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>
#include <winservice.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 kept.
*/
void CheckServiceConfig(
wchar_t *my_servicename, /* SERVICENAME property in this installation*/
wchar_t *datadir, /* DATADIR property in this installation*/
wchar_t *bindir, /* INSTALLDIR\bin */
wchar_t *other_servicename, /* Service to check against */
QUERY_SERVICE_CONFIGW * config /* Other service's config */
)
{
bool same_bindir = false;
wchar_t * commandline= config->lpBinaryPathName;
int numargs;
wchar_t **argv= CommandLineToArgvW(commandline, &numargs);
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 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. "
L"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. "
L"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);
}
/*
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];
char 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 (MsiGetPropertyA(hInstall,"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)
{
mysqld_service_properties props;
if (get_mysql_service_properties(config->lpBinaryPathName, &props))
continue;
/*
Only look for services that have mysqld.exe outside of the current
installation directory.
*/
if(strstr(props.mysqld_exe,installDir) == 0)
{
WcaLog(LOGMSG_STANDARD, "found service %S, major=%d, minor=%d",
info[i].lpServiceName, props.version_major, props.version_minor);
if(props.version_major < installerMajorVersion
|| (props.version_major == installerMajorVersion &&
props.version_minor <= installerMinorVersion))
{
upgradableServiceFound= true;
break;
}
}
}
}
if(!upgradableServiceFound)
{
/* Disable optional checkbox at the end of installation */
MsiSetPropertyW(hInstall, L"WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT", L"");
MsiSetPropertyW(hInstall, L"WIXUI_EXITDIALOGOPTIONALCHECKBOX",L"");
}
else
{
MsiSetPropertyW(hInstall, L"UpgradableServiceFound", L"1");
MsiSetPropertyW(hInstall, L"WIXUI_EXITDIALOGOPTIONALCHECKBOX",L"1");
}
LExit:
if(scm)
CloseServiceHandle(scm);
return WcaFinalize(er);
}
/* DllMain - Initialize and cleanup WiX custom action utils */
extern "C" BOOL WINAPI DllMain(
__in HINSTANCE hInst,
__in ULONG ulReason,
__in LPVOID
)
{
switch(ulReason)
{
case DLL_PROCESS_ATTACH:
WcaGlobalInitialize(hInst);
break;
case DLL_PROCESS_DETACH:
WcaGlobalFinalize();
break;
}
return TRUE;
}
LIBRARY "wixca"
VERSION 1.0
EXPORTS
RemoveDataDirectory
CreateDatabaseRollback
CheckDatabaseProperties
CheckDataDirectoryEmpty
CheckDBInUse
CheckServiceUpgrades
#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
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
)
<?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
<?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"/>
<!-- Force per machine installation -->
<Property Id="ALLUSERS" Secure="yes" Value="1"/>
<!--
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?>
<!--
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>
<!-- Dialog new or upgrade instance -->
<Property Id="CreateOrUpgradeChoice" Value="Create"/>
<Dialog Id="NewOrUpgradeInstanceDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
<Control Id="Text" Type="Text" X="40" Y="65" Width="270" Height="30">
<Text>Setup found existing database instances that can be upgraded to [ProductName].You can create a new instance and/or upgrade existing one.
</Text>
</Control>
<Control Id="CreateOrUpgradeButton"
Type="RadioButtonGroup" X="40" Y="100" Width="300" Height="70"
Property="CreateOrUpgradeChoice" Text="Specify what to do">
<RadioButtonGroup Property="CreateOrUpgradeChoice">
<RadioButton Value="Create" X="0" Y="0" Width="300" Height="25"
Text="{\Font1}Create new database instance."/>
<RadioButton Value="Upgrade" X="0" Y="30" Width="300" Height="25"
Text="{\Font1}Do not create a new database. Optionally upgrade existing instances." />
</RadioButtonGroup>
</Control>
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
<Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
</Control>
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Text="&amp;Next">
<Publish Event="Remove" Value="DBInstance">CreateOrUpgradeChoice = "Upgrade" </Publish>
<Publish Event="AddLocal" Value="DBInstance">CreateOrUpgradeChoice = "Create"</Publish>
<Publish Event="NewDialog" Value="CustomizeDlg">1</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
<Text>Create or upgrade database instance</Text>
</Control>
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}[ProductName] setup</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
</Dialog>
<!-- Error popup dialog -->
<Dialog Id="WarningDlg" Width="320" Height="85" Title="[ProductName] Setup" NoMinimize="yes">
<Control Id="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="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="NewOrUpgradeInstanceDlg" Order="999">
NOT Installed AND UpgradableServiceFound
</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ServicePortDlg" Order="3" ><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3"> <![CDATA[OLDERVERSIONBEINGUPGRADED <>""]]></Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="1" ><![CDATA[(&DBInstance=2) AND (!DBInstance=3)]]></Publish>
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="NewOrUpgradeInstanceDlg" Order="999">
NOT Installed AND UpgradableServiceFound
</Publish>
<Publish Dialog="CustomizeDlg" Control="Next" Event="DoAction" Value="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>
<?if $(var.HaveUpgradeWizard) != "0" ?>
<ComponentRef Id='C.bin.mysql_upgrade_wizard.exe'/>
<Component Id="c.shortcuts.upgrade_wizard" Guid="*" Directory="ShortcutFolder" Transitive="yes">
<RegistryValue
Root="HKCU" Key="Software\@CPACK_WIX_PACKAGE_NAME@\Uninstall"
Name="shortcuts.upgrade_wizard"
Value="1" Type="string" KeyPath="yes" />
<Shortcut Id="shortcut.upgrade_wizard"
Name="Upgrade Wizard (@CPACK_WIX_PACKAGE_NAME@)"
Target="[INSTALLDIR]bin\mysql_upgrade_wizard.exe"
Directory="ShortcutFolder"
Description="Upgrades older instances of MariaDB/MySQL services to version @MAJOR_VERSION@.@MINOR_VERSION@" />
</Component>
<?endif?>
</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.
-->
<?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.mysql_upgrade_wizard.exe]" />
<CustomAction Id="LaunchApplication"
BinaryKey="WixCA"
DllEntry="WixShellExec"
Impersonate="yes" />
<CustomAction
Id="CheckServiceUpgrades" Return="ignore" BinaryKey="wixca.dll"
DllEntry="CheckServiceUpgrades"
Execute="immediate" />
<InstallUISequence>
<Custom Action="CheckServiceUpgrades" After="CostFinalize">
$C.bin.mysql_upgrade_wizard.exe = 3 AND NOT Installed
</Custom>
</InstallUISequence>
<SetProperty Before="ExecuteAction" Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT"
Sequence="ui" Value="[NonExistentProperty]">
<![CDATA[($C.bin.mysql_upgrade_wizard.exe <> 3) AND NOT Installed]]>
</SetProperty>
<SetProperty Before="ExecuteAction" Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX"
Sequence="ui" Value="[NonExistentProperty]">
<![CDATA[($C.bin.mysql_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.'
>
<![CDATA[ NOT(NSISINSTALLKEY << "MariaDB @MAJOR_VERSION@.@MINOR_VERSION@.") OR Installed]]>
</Condition>
<Condition Message=
'Setting the ALLUSERS property is not allowed because [ProductName] is a per-machine application. Setup will now exit.'>
<![CDATA[ALLUSERS = "1"]]>
</Condition>
</Fragment>
</Wix>
<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>
IF(NOT MSVC)
RETURN()
ENDIF()
IF(CMAKE_USING_VC_FREE_TOOLS)
# No MFC, so it cannot be built
RETURN()
ENDIF()
# We need MFC
FIND_PACKAGE(MFC)
IF(NOT MFC_FOUND)
IF(BUILD_RELEASE)
MESSAGE(FATAL_ERROR
"Can't find MFC. It is necessary for producing official package"
)
ENDIF()
RETURN()
ENDIF()
# MFC should be statically linked
SET(CMAKE_MFC_FLAG 1)
# Enable exception handling (avoids warnings)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql)
MYSQL_ADD_EXECUTABLE(mysql_upgrade_wizard
upgrade.cpp upgradeDlg.cpp upgrade.rc
COMPONENT Server)
TARGET_LINK_LIBRARIES(mysql_upgrade_wizard winservice)
# upgrade_wizard is Windows executable, set WIN32_EXECUTABLE so it does not
# create a console.
SET_TARGET_PROPERTIES(mysql_upgrade_wizard PROPERTIES WIN32_EXECUTABLE 1)
# Embed Vista "admin" manifest, since upgrade_wizard needs admin privileges
# to change service configuration. Due to a CMake bug http://www.vtk.org/Bug/view.php?id=11171
# it is not possible currenly to do it with linker flags. Work around is to use
# manifest tool mt.exe and embed the manifest post-build.
GET_TARGET_PROPERTY(upgrade_wizard_location mysql_upgrade_wizard LOCATION)
ADD_CUSTOM_COMMAND(
TARGET mysql_upgrade_wizard POST_BUILD
COMMAND mt.exe -manifest ${CMAKE_CURRENT_SOURCE_DIR}/upgrade_wizard.exe.manifest
"-outputresource:${upgrade_wizard_location};#1"
)
//
// zzz.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by upgrade.rc
//
#define IDD_UPGRADE_DIALOG 102
#define IDR_MAINFRAME 128
#define IDC_LIST1 1000
#define IDC_PROGRESS1 1004
#define IDC_EDIT1 1005
#define IDC_EDIT2 1006
#define IDC_EDIT3 1007
#define IDC_EDIT7 1011
#define IDC_EDIT8 1012
#define IDC_EDIT9 1013
#define IDC_BUTTON1 1014
#define IDC_BUTTON2 1015
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1016
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef _SECURE_ATL
#define _SECURE_ATL 1
#endif
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
// upgrade.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "upgrade.h"
#include "upgradeDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CUpgradeApp
BEGIN_MESSAGE_MAP(CUpgradeApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CUpgradeApp construction
CUpgradeApp::CUpgradeApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CUpgradeApp object
CUpgradeApp theApp;
// CUpgradeApp initialization
BOOL CUpgradeApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
CUpgradeDlg dlg;
m_pMainWnd = &dlg;
dlg.DoModal();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
// zzz.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// CzzzApp:
// See zzz.cpp for the implementation of this class
//
class CUpgradeApp : public CWinApp
{
public:
CUpgradeApp();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
};
extern CUpgradeApp theApp;
\ No newline at end of file
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// German (Germany) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#ifndef APSTUDIO_INVOKED\r\n"
"#include ""targetver.h""\r\n"
"#endif\r\n"
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"LANGUAGE 9, 1\r\n"
"#include ""res\\upgrade.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON "res\\upgrade.ico"
#endif // German (Germany) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_UPGRADE_DIALOG DIALOGEX 0, 0, 320, 200
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "MariaDB Upgrade Wizard"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "OK",IDOK,113,169,50,14
PUSHBUTTON "Cancel",IDCANCEL,191,169,50,14
LISTBOX IDC_LIST1,24,39,216,80,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_EDIT1,97,124,193,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
EDITTEXT IDC_EDIT2,98,138,181,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
CONTROL "",IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH | WS_BORDER,26,153,243,14
EDITTEXT IDC_EDIT3,98,151,40,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
EDITTEXT IDC_EDIT7,27,124,65,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
EDITTEXT IDC_EDIT8,27,137,62,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
EDITTEXT IDC_EDIT9,27,151,62,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
PUSHBUTTON "Select all",IDC_BUTTON1,245,61,50,14
PUSHBUTTON "Clear all",IDC_BUTTON2,246,88,50,14
LTEXT "Select services you want to upgrade and click on the [Upgrade] button.\nMake sure to backup data directories prior to upgrade.",IDC_STATIC,25,14,215,26
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_UPGRADE_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 313
TOPMARGIN, 7
BOTTOMMARGIN, 193
END
END
#endif // APSTUDIO_INVOKED
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#include "res\upgrade.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
// upgradeDlg.cpp : implementation file
//
#include "stdafx.h"
#include "upgrade.h"
#include "upgradeDlg.h"
#include "windows.h"
#include "winsvc.h"
#include <msi.h>
#pragma comment(lib, "msi")
#pragma comment(lib, "version")
#include <map>
#include <string>
#include <vector>
#include <winservice.h>
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define PRODUCT_NAME "MariaDB"
// CUpgradeDlg dialog
CUpgradeDlg::CUpgradeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CUpgradeDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CUpgradeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_Services);
DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
DDX_Control(pDX, IDOK, m_Ok);
DDX_Control(pDX, IDCANCEL, m_Cancel);
DDX_Control(pDX, IDC_EDIT1, m_IniFilePath);
DDX_Control(pDX, IDC_EDIT2, m_DataDir);
DDX_Control(pDX, IDC_EDIT3, m_Version);
DDX_Control(pDX, IDC_EDIT7, m_IniFileLabel);
DDX_Control(pDX, IDC_EDIT8, m_DataDirLabel);
DDX_Control(pDX, IDC_EDIT9, m_VersionLabel);
DDX_Control(pDX, IDC_BUTTON1, m_SelectAll);
DDX_Control(pDX, IDC_BUTTON2, m_ClearAll);
}
BEGIN_MESSAGE_MAP(CUpgradeDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_LBN_SELCHANGE(IDC_LIST1, &CUpgradeDlg::OnLbnSelchangeList1)
ON_CONTROL(CLBN_CHKCHANGE, IDC_LIST1, OnChkChange)
ON_BN_CLICKED(IDOK, &CUpgradeDlg::OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, &CUpgradeDlg::OnBnClickedCancel)
ON_BN_CLICKED(IDC_BUTTON1,&CUpgradeDlg::OnBnSelectAll)
ON_BN_CLICKED(IDC_BUTTON2,&CUpgradeDlg::OnBnClearAll)
END_MESSAGE_MAP()
struct ServiceProperties
{
string servicename;
string myini;
string datadir;
string version;
};
vector<ServiceProperties> services;
/*
Get version from an executable.
Returned version is either major.minor.patch or
<unknown> , of executable does not have any version
info embedded (like MySQL 5.1 for example)
*/
void GetExeVersion(const string& filename, int *major, int *minor, int *patch)
{
DWORD handle;
*major= *minor= *patch= 0;
DWORD size = GetFileVersionInfoSize(filename.c_str(), &handle);
BYTE* versionInfo = new BYTE[size];
if (!GetFileVersionInfo(filename.c_str(), handle, size, versionInfo))
{
delete[] versionInfo;
return;
}
// we have version information
UINT len = 0;
VS_FIXEDFILEINFO* vsfi = NULL;
VerQueryValue(versionInfo, "\\", (void**)&vsfi, &len);
*major= (int)HIWORD(vsfi->dwFileVersionMS);
*minor= (int)LOWORD(vsfi->dwFileVersionMS);
*patch= (int)HIWORD(vsfi->dwFileVersionLS);
delete[] versionInfo;
}
void GetMyVersion(int *major, int *minor, int *patch)
{
char path[MAX_PATH];
*major= *minor= *patch =0;
if (GetModuleFileName(NULL, path, MAX_PATH))
{
GetExeVersion(path, major, minor, patch);
}
}
// CUpgradeDlg message handlers
/* Handle selection changes in services list */
void CUpgradeDlg::SelectService(int index)
{
m_IniFilePath.SetWindowText(services[index].myini.c_str());
m_DataDir.SetWindowText(services[index].datadir.c_str());
m_Version.SetWindowText(services[index].version.c_str());
}
/*
Iterate over services, lookup for mysqld.exe ones.
Compare mysqld.exe version with current version, and display
service if corresponding mysqld.exe has lower version.
The version check is not strict, i.e we allow to "upgrade"
for the same major.minor combination. This can be useful for
"upgrading" from 32 to 64 bit, or for MySQL=>Maria conversion.
*/
void CUpgradeDlg::PopulateServicesList()
{
SC_HANDLE scm = OpenSCManager(NULL, NULL,
SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_CONNECT);
if (scm == NULL)
{
ErrorExit("OpenSCManager failed");
}
static BYTE buf[64*1024];
static BYTE configBuffer[8*1024];
DWORD bufsize= sizeof(buf);
DWORD bufneed;
DWORD num_services;
BOOL ok= EnumServicesStatusEx(scm, SC_ENUM_PROCESS_INFO, SERVICE_WIN32,
SERVICE_STATE_ALL, buf, bufsize, &bufneed, &num_services, NULL, NULL);
if(!ok)
ErrorExit("EnumServicesStatusEx failed");
LPENUM_SERVICE_STATUS_PROCESS info =
(LPENUM_SERVICE_STATUS_PROCESS)buf;
int index=-1;
for (ULONG i=0; i < num_services; i++)
{
SC_HANDLE service= OpenService(scm, info[i].lpServiceName,
SERVICE_QUERY_CONFIG);
if (!service)
continue;
QUERY_SERVICE_CONFIGW *config=
(QUERY_SERVICE_CONFIGW*)(void *)configBuffer;
DWORD needed;
BOOL ok= QueryServiceConfigW(service, config,sizeof(configBuffer), &needed);
CloseServiceHandle(service);
if (ok)
{
mysqld_service_properties service_props;
if (get_mysql_service_properties(config->lpBinaryPathName,
&service_props))
continue;
/* Check if service uses mysqld in installation directory */
if (_strnicmp(service_props.mysqld_exe, m_InstallDir.c_str(),
m_InstallDir.size()) == 0)
continue;
if(m_MajorVersion > service_props.version_major ||
(m_MajorVersion == service_props.version_major && m_MinorVersion >=
service_props.version_minor))
{
ServiceProperties props;
props.myini= service_props.inifile;
props.datadir= service_props.datadir;
props.servicename = info[i].lpServiceName;
if (service_props.version_major)
{
char ver[64];
sprintf(ver, "%d.%d.%d", service_props.version_major,
service_props.version_minor, service_props.version_patch);
props.version= ver;
}
else
props.version= "<unknown>";
index = m_Services.AddString(info[i].lpServiceName);
services.resize(index+1);
services[index] = props;
}
}
if (index != -1)
{
m_Services.SetCurSel(0);
SelectService(m_Services.GetCurSel());
}
}
if (services.size())
{
SelectService(0);
}
else
{
char message[128];
sprintf(message,
"There is no service that can be upgraded to " PRODUCT_NAME " %d.%d.%d",
m_MajorVersion, m_MinorVersion, m_PatchVersion);
MessageBox(message, PRODUCT_NAME " Upgrade Wizard", MB_ICONINFORMATION);
exit(0);
}
if(scm)
CloseServiceHandle(scm);
}
BOOL CUpgradeDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_UpgradeRunning= FALSE;
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_Ok.SetWindowText("Upgrade");
m_DataDirLabel.SetWindowText("Data directory:");
m_IniFileLabel.SetWindowText("Configuration file:");
m_VersionLabel.SetWindowText("Version:");
char myFilename[MAX_PATH];
GetModuleFileName(NULL, myFilename, MAX_PATH);
char *p= strrchr(myFilename,'\\');
if(p)
p[1]=0;
m_InstallDir= myFilename;
GetMyVersion(&m_MajorVersion, &m_MinorVersion, &m_PatchVersion);
char windowTitle[64];
sprintf(windowTitle, PRODUCT_NAME " %d.%d.%d Upgrade Wizard",
m_MajorVersion, m_MinorVersion, m_PatchVersion);
SetWindowText(windowTitle);
m_JobObject= CreateJobObject(NULL, NULL);
/*
Make all processes associated with the job terminate when the
last handle to the job is closed or job is teminated.
*/
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = {0};
jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
SetInformationJobObject(m_JobObject, JobObjectExtendedLimitInformation,
&jeli, sizeof(jeli));
m_Progress.ShowWindow(SW_HIDE);
m_Ok.EnableWindow(FALSE);
PopulateServicesList();
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CUpgradeDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND,
reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user
// drags the minimized window.
HCURSOR CUpgradeDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CUpgradeDlg::OnLbnSelchangeList1()
{
SelectService(m_Services.GetCurSel());
}
void CUpgradeDlg::OnChkChange()
{
if(m_Services.GetCheck( m_Services.GetCurSel()))
{
GetDlgItem(IDOK)->EnableWindow();
}
else
{
for(int i=0; i< m_Services.GetCount(); i++)
{
if(m_Services.GetCheck(i))
return;
}
// all items unchecked, disable OK button
GetDlgItem(IDOK)->EnableWindow(FALSE);
}
}
void CUpgradeDlg::ErrorExit(LPCSTR str)
{
MessageBox(str, "Fatal Error", MB_ICONERROR);
exit(1);
}
const int MAX_MESSAGES=512;
/* Main thread of the child process */
static HANDLE hChildThread;
void CUpgradeDlg::UpgradeOneService(const string& servicename)
{
static string allMessages[MAX_MESSAGES];
static char npname[MAX_PATH];
static char pipeReadBuf[1];
SECURITY_ATTRIBUTES saAttr;
STARTUPINFO si={0};
PROCESS_INFORMATION pi;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
HANDLE hPipeRead, hPipeWrite;
if(!CreatePipe(&hPipeRead, &hPipeWrite, &saAttr, 1))
ErrorExit("CreateNamedPipe failed");
/* Make sure read end of the pipe is not inherited */
if (!SetHandleInformation(hPipeRead, HANDLE_FLAG_INHERIT, 0) )
ErrorExit("Stdout SetHandleInformation");
string commandline("mysql_upgrade_service.exe --service=");
commandline += servicename;
si.cb = sizeof(si);
si.hStdInput= GetStdHandle(STD_INPUT_HANDLE);
si.hStdOutput= hPipeWrite;
si.hStdError= hPipeWrite;
si.wShowWindow= SW_HIDE;
si.dwFlags= STARTF_USESTDHANDLES |STARTF_USESHOWWINDOW;
/*
We will try to assign child process to a job, to be able to
terminate the process and all of its children. It might fail,
in case current process is already part of the job which does
not allows breakaways.
*/
if (CreateProcess(NULL, (LPSTR)commandline.c_str(), NULL, NULL, TRUE,
CREATE_BREAKAWAY_FROM_JOB|CREATE_SUSPENDED, NULL, NULL, &si, &pi))
{
if(!AssignProcessToJobObject(m_JobObject, pi.hProcess))
{
char errmsg[128];
sprintf(errmsg, "AssignProcessToJobObject failed, error %d",
GetLastError());
ErrorExit(errmsg);
}
ResumeThread(pi.hThread);
}
else
{
/*
Creating a process with CREATE_BREAKAWAY_FROM_JOB, reset this flag
and retry.
*/
if (!CreateProcess(NULL, (LPSTR)commandline.c_str(), NULL, NULL, TRUE,
0, NULL, NULL, &si, &pi))
{
string errmsg("Create Process ");
errmsg+= commandline;
errmsg+= " failed";
ErrorExit(errmsg.c_str());
}
}
hChildThread = pi.hThread;
DWORD nbytes;
int lines=0;
CloseHandle(hPipeWrite);
string output_line;
while(ReadFile(hPipeRead, pipeReadBuf, 1, &nbytes, NULL))
{
if(pipeReadBuf[0] == '\n')
{
allMessages[lines%MAX_MESSAGES] = output_line;
m_DataDir.SetWindowText(allMessages[lines%MAX_MESSAGES].c_str());
output_line.clear();
lines++;
/*
Updating progress dialog.There are currently 9 messages from
mysql_upgrade_service (actually it also writes Phase N/M but
we do not parse the output right now).
*/
#define EXPRECTED_MYSQL_UPGRADE_MESSAGES 9
int stepsTotal= m_ProgressTotal*EXPRECTED_MYSQL_UPGRADE_MESSAGES;
int stepsCurrent= m_ProgressCurrent*EXPRECTED_MYSQL_UPGRADE_MESSAGES
+ lines;
int percentDone= stepsCurrent*100/stepsTotal;
m_Progress.SetPos(percentDone);
}
else
{
if(pipeReadBuf[0] != '\r')
output_line.push_back(pipeReadBuf[0]);
}
}
CloseHandle(hPipeWrite);
if(WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_OBJECT_0)
ErrorExit("WaitForSingleObject failed");
DWORD exitcode;
if (!GetExitCodeProcess(pi.hProcess, &exitcode))
ErrorExit("GetExitCodeProcess failed");
if (exitcode != 0)
{
string errmsg= "mysql_upgrade_service returned error for service ";
errmsg += servicename;
errmsg += ":\r\n";
errmsg+= output_line;
ErrorExit(errmsg.c_str());
}
CloseHandle(pi.hProcess);
hChildThread= 0;
CloseHandle(pi.hThread);
}
void CUpgradeDlg::UpgradeServices()
{
/*
Disable some dialog items during upgrade (OK button,
services list)
*/
m_Ok.EnableWindow(FALSE);
m_Services.EnableWindow(FALSE);
m_SelectAll.EnableWindow(FALSE);
m_ClearAll.EnableWindow(FALSE);
/*
Temporarily repurpose IniFileLabel/IniFilePath and
DatDirLabel/DataDir controls to show progress messages.
*/
m_VersionLabel.ShowWindow(FALSE);
m_Version.ShowWindow(FALSE);
m_Progress.ShowWindow(TRUE);
m_IniFileLabel.SetWindowText("Converting service:");
m_IniFilePath.SetWindowText("");
m_DataDirLabel.SetWindowText("Progress message:");
m_DataDir.SetWindowText("");
m_ProgressTotal=0;
for(int i=0; i< m_Services.GetCount(); i++)
{
if(m_Services.GetCheck(i))
m_ProgressTotal++;
}
m_ProgressCurrent=0;
for(int i=0; i< m_Services.GetCount(); i++)
{
if(m_Services.GetCheck(i))
{
m_IniFilePath.SetWindowText(services[i].servicename.c_str());
m_Services.SelectString(0, services[i].servicename.c_str());
UpgradeOneService(services[i].servicename);
m_ProgressCurrent++;
}
}
MessageBox("Service(s) successfully upgraded", "Success",
MB_ICONINFORMATION);
/* Rebuild services list */
vector<ServiceProperties> new_instances;
for(int i=0; i< m_Services.GetCount(); i++)
{
if(!m_Services.GetCheck(i))
new_instances.push_back(services[i]);
}
services= new_instances;
m_Services.ResetContent();
for(size_t i=0; i< services.size();i++)
m_Services.AddString(services[i].servicename.c_str());
if(services.size())
{
m_Services.SelectString(0,services[0].servicename.c_str());
SelectService(0);
}
else
{
/* Nothing to do, there are no upgradable services */
exit(0);
}
/*
Restore controls that were temporarily repurposed for
progress info to their normal state
*/
m_IniFileLabel.SetWindowText("Configuration file:");
m_DataDirLabel.SetWindowText("Data Directory:");
m_VersionLabel.ShowWindow(TRUE);
m_Version.ShowWindow(TRUE);
m_Progress.SetPos(0);
m_Progress.ShowWindow(FALSE);
/* Re-enable controls */
m_Ok.EnableWindow(TRUE);
m_Services.EnableWindow(TRUE);
m_SelectAll.EnableWindow(TRUE);
m_ClearAll.EnableWindow(TRUE);
m_UpgradeRunning= FALSE;
}
/* Thread procedure for upgrade services operation */
static UINT UpgradeServicesThread(void *param)
{
CUpgradeDlg *dlg= (CUpgradeDlg *)param;
dlg->UpgradeServices();
return 0;
}
/*
Do upgrade for all services currently selected
in the list. Since it is a potentially lengthy operation that
might block it has to be done in a background thread.
*/
void CUpgradeDlg::OnBnClickedOk()
{
if(m_UpgradeRunning)
return;
m_UpgradeRunning= TRUE;
AfxBeginThread(UpgradeServicesThread, this);
}
/*
Cancel button clicked.
If upgrade is running, suspend mysql_upgrade_service,
and ask user whether he really wants to stop.Terminate
upgrade wizard and all subprocesses if users wants it.
If upgrade is not running, terminate the Wizard
*/
void CUpgradeDlg::OnBnClickedCancel()
{
if(m_UpgradeRunning)
{
bool suspended = (SuspendThread(hChildThread) != (DWORD)-1);
int ret = MessageBox(
"Upgrade is in progress. Are you sure you want to terminate?",
0, MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION);
if(ret != IDYES)
{
if(suspended)
ResumeThread(hChildThread);
return;
}
}
TerminateJobObject(m_JobObject, 1);
exit(1);
}
/*
Select all services from the list
*/
void CUpgradeDlg::OnBnSelectAll()
{
for(int i=0; i < m_Services.GetCount(); i++)
m_Services.SetCheck(i, 1);
m_Ok.EnableWindow(TRUE);
}
/*
Clear all services in the list
*/
void CUpgradeDlg::OnBnClearAll()
{
for(int i=0; i < m_Services.GetCount(); i++)
m_Services.SetCheck(i, 0);
m_Ok.EnableWindow(FALSE);
}
// upgradeDlg.h : header file
//
#pragma once
#include "afxcmn.h"
#include "afxwin.h"
#include <string>
// CUpgradeDlg dialog
class CUpgradeDlg : public CDialog
{
// Construction
public:
CUpgradeDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_UPGRADE_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// job object for current process and children
HANDLE m_JobObject;
// Services are being upgraded
BOOL m_UpgradeRunning;
// ProgressBar related: number of services to upgrade
int m_ProgressTotal;
//ProgressBar related: current service being upgraded
int m_ProgressCurrent;
protected:
HICON m_hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
void PopulateServicesList();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
void SelectService(int index);
void UpgradeServices();
void UpgradeOneService(const std::string& name);
void ErrorExit(const char *);
std::string m_InstallDir;
CCheckListBox m_Services;
CProgressCtrl m_Progress;
CButton m_Ok;
CButton m_Cancel;
CButton m_SelectAll;
CButton m_ClearAll;
int m_MajorVersion;
int m_MinorVersion;
int m_PatchVersion;
CEdit m_IniFilePath;
afx_msg void OnLbnSelchangeList1();
afx_msg void OnChkChange();
CEdit m_DataDir;
CEdit m_Version;
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedCancel();
afx_msg void OnBnSelectAll();
afx_msg void OnBnClearAll();
CEdit m_IniFileLabel;
CEdit m_DataDirLabel;
CEdit m_VersionLabel;
};
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>
\ No newline at end of file
......@@ -27,6 +27,4 @@ SET(ZLIB_SOURCES adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.
zutil.c zutil.h)
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(zlib ${ZLIB_SOURCES})
INSTALL(TARGETS zlib DESTINATION lib/opt COMPONENT runtime) # TODO: Component
ENDIF(NOT SOURCE_SUBLIBS)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment