Commit e353bc80 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MWL#55 : implement MSI installer

The  general technique to generate MSI using CMake is taken from MySQL 5.5

Additional features not present in 5.5 installer : 
-optionally creating a new database
(as Windows service), using new mysql_install_db.exe to do the job
 
- optional upgrade of existing services from old MySQL or Maria installation.
This work is actually done by the upgrade wizard that is launched at the 
end of installation.
parent e15f9148
# Copyright 2010, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
IF(NOT WIN32)
RETURN()
ENDIF()
SET(MANUFACTURER "Monty Program AB")
FIND_PATH(WIX_DIR heat.exe
$ENV{WIX_DIR}/bin
$ENV{ProgramFiles}/wix/bin
"$ENV{ProgramFiles}/Windows Installer XML v3/bin"
"$ENV{ProgramFiles}/Windows Installer XML v3.5/bin"
)
SET(CPACK_WIX_PACKAGE_BASE_NAME "MariaDB")
IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
SET(CPACK_WIX_UPGRADE_CODE "49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3")
SET(CPACK_WIX_PACKAGE_NAME "MariaDB @MAJOR_VERSION@.@MINOR_VERSION@")
ELSE()
SET(CPACK_WIX_UPGRADE_CODE "2331E7BD-EE58-431B-9E18-B2B918BCEB1B")
SET(CPACK_WIX_PACKAGE_NAME "MariaDB @MAJOR_VERSION@.@MINOR_VERSION@ (x64)")
ENDIF()
IF(NOT WIX_DIR)
IF(NOT _WIX_DIR_CHECKED)
SET(_WIX_DIR_CHECKED 1 CACHE INTERNAL "")
MESSAGE(STATUS "Cannot find wix 3, installer project will not be generated")
ENDIF()
RETURN()
ENDIF()
ADD_SUBDIRECTORY(ca)
# extra.wxs.in needs DATADIR_MYSQL_FILES and DATADIR_PERFORMANCE_SCHEMA_FILES, i.e
# Wix-compatible file lists for ${builddir}\sql\data\{mysql,performance_schema}
FOREACH(dir mysql performance_schema)
FILE(GLOB files ${CMAKE_BINARY_DIR}/sql/data/${dir}/*)
SET(filelist)
FOREACH(f ${files})
IF(NOT f MATCHES ".rule")
FILE(TO_NATIVE_PATH "${f}" file_native_path)
GET_FILENAME_COMPONENT(file_name "${f}" NAME)
SET(filelist
"${filelist}
<File Id='${file_name}' Source='${file_native_path}'/>")
ENDIF()
ENDFOREACH()
STRING(TOUPPER ${dir} DIR_UPPER)
SET(DATADIR_${DIR_UPPER}_FILES "${filelist}")
ENDFOREACH()
FIND_PROGRAM(CANDLE_EXECUTABLE candle ${WIX_DIR})
FIND_PROGRAM(LIGHT_EXECUTABLE light ${WIX_DIR})
# WiX wants the license text as rtf; if there is no rtf license,
# we create a fake one from the plain text COPYING file.
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf")
SET(COPYING_RTF "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf")
ELSE()
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../LICENSE.mysql")
SET(LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../LICENSE.mysql")
ELSE()
SET(LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../COPYING")
ENDIF()
FILE(READ ${LICENSE_FILE} CONTENTS)
STRING(REGEX REPLACE "\n" "\\\\par\n" CONTENTS "${CONTENTS}")
STRING(REGEX REPLACE "\t" "\\\\tab" CONTENTS "${CONTENTS}")
FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Courier New;}}\\viewkind4\\uc1\\pard\\lang1031\\f0\\fs15")
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "${CONTENTS}")
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "\n}\n")
SET(COPYING_RTF "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf")
ENDIF()
GET_TARGET_PROPERTY(WIXCA_LOCATION wixca LOCATION)
SET(CPACK_WIX_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/CPackWixConfig.cmake)
GET_TARGET_PROPERTY(upgrade_wizard_location upgrade_wizard LOCATION)
IF(NOT upgrade_wizard_location)
SET(EXTRA_WIX_PREPROCESSOR_FLAGS "-dHaveUpgradeWizard=0")
ENDIF()
IF(NOT CPACK_WIX_UI)
SET(CPACK_WIX_UI "MyWixUI_Mondo")
ENDIF()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/create_msi.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake
@ONLY)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(WixWin64 " Win64='yes'")
ELSE()
SET(WixWin64)
ENDIF()
IF(CMAKE_GENERATOR MATCHES "Visual Studio")
SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}")
ENDIF()
ADD_CUSTOM_TARGET(
MSI
COMMAND set VS_UNICODE_OUTPUT=
COMMAND ${CMAKE_COMMAND}
${CONFIG_PARAM}
-P ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake
)
ADD_DEPENDENCIES(MSI wixca)
ADD_CUSTOM_TARGET(
MSI_ESSENTIALS
COMMAND set VS_UNICODE_OUTPUT=
COMMAND ${CMAKE_COMMAND} -DESSENTIALS=1
${CONFIG_PARAM}
-P ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake
)
ADD_DEPENDENCIES(MSI_ESSENTIALS wixca)
This diff is collapsed.
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)
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)
This diff is collapsed.
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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<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>
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