mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
d60efe5820
- Introduce MANUFACTURER setting to set package manufacturer via CMake. - Introduce COMMUNITY_BUILD setting to be passed on to packaging (not used here, but required for our own packages to determine what added files should be included in the package). - Create an RTF version of the COPYING text file and use that as the default license (can be overridden by providing a COPYING.rtf file). - Allow passing extra arguments to candle and light via environment. (Need -sval in pushbuild, but want validation elsewhere.) - Introduce a custom action that stops and uninstalls the service if the user installed one that points into the MySQL directory that is being removed. (Our own packages historically used the instance configuration wizard for this, but it wouldn't be very nice if MSIs created by our users couldn't remove it too.) - Make install location configurable again ("Browse" button in custom installation was greyed out before). - Remove registry keys that use "MySQL AB"; they should only be set in packages provided by us. Users can set their own registry keys if they want to.
311 lines
9.9 KiB
CMake
311 lines
9.9 KiB
CMake
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(MAJOR_VERSION "@MAJOR_VERSION@")
|
|
SET(MINOR_VERSION "@MINOR_VERSION@")
|
|
SET(PATCH "@PATCH@")
|
|
SET(CMAKE_SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@)
|
|
SET(MANUFACTURER "@MANUFACTURER@")
|
|
|
|
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
SET(Win64 " Win64='yes'")
|
|
SET(Platform x64)
|
|
SET(PlatformProgramFilesFolder ProgramFiles64Folder)
|
|
ELSE()
|
|
SET(Platform x86)
|
|
SET(PlatformProgramFilesFolder ProgramFilesFolder)
|
|
SET(Win64)
|
|
ENDIF()
|
|
|
|
SET(ENV{VS_UNICODE_OUTPUT})
|
|
|
|
INCLUDE(${CMAKE_BINARY_DIR}/CPackConfig.cmake)
|
|
|
|
IF(CPACK_WIX_CONFIG)
|
|
INCLUDE(${CPACK_WIX_CONFIG})
|
|
ENDIF()
|
|
|
|
IF(NOT CPACK_WIX_UI)
|
|
SET(CPACK_WIX_UI "WixUI_Mondo")
|
|
ENDIF()
|
|
|
|
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()
|
|
|
|
LIST(REMOVE_DUPLICATES WIX_FEATURES)
|
|
|
|
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'
|
|
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'
|
|
Level='${Level}'>
|
|
<ComponentGroupRef Id='componentgroup.${c}'/>
|
|
</Feature>")
|
|
ENDIF()
|
|
|
|
ENDFOREACH()
|
|
SET(CPACK_WIX_FEATURES
|
|
"${CPACK_WIX_FEATURES}
|
|
</Feature>
|
|
")
|
|
ENDFOREACH()
|
|
|
|
|
|
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_server.wxs.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/mysql_server.wxs)
|
|
|
|
|
|
IF(CMAKE_INSTALL_CONFIG_NAME)
|
|
SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_INSTALL_CONFIG_NAME}")
|
|
ENDIF()
|
|
|
|
FOREACH(comp ${CPACK_COMPONENTS_ALL})
|
|
SET(ENV{DESTDIR} testinstall/${comp})
|
|
SET(DIRS ${DIRS} 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
|
|
)
|
|
ENDFOREACH()
|
|
|
|
MACRO(GENERATE_GUID VarName)
|
|
EXECUTE_PROCESS(COMMAND uuidgen -c
|
|
OUTPUT_VARIABLE ${VarName}
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
ENDMACRO()
|
|
|
|
SET(INC_VAR 0)
|
|
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)
|
|
STRING(SUBSTRING "${${varname}}" 0 67 shortstr)
|
|
MATH(EXPR INC_VAR ${INC_VAR}+1)
|
|
SET(${varname} "${shortstr}${INC_VAR}")
|
|
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)
|
|
# According to MSDN each DLL or EXE should be in the own component
|
|
IF(f_ext MATCHES ".exe" OR f_ext MATCHES ".dll")
|
|
|
|
FILE(APPEND ${file} " <Component Id='C.${id}' Guid='*' ${Win64}>\n")
|
|
FILE(APPEND ${file} " <File Id='F.${id}' KeyPath='yes' Source='${f_native}'/>\n")
|
|
FILE(APPEND ${file} " </Component>\n")
|
|
FILE(APPEND ${file_comp} " <ComponentRef Id='C.${id}'/>\n")
|
|
ELSE()
|
|
SET(NONEXEFILES "${NONEXEFILES}\n<File Id='F.${id}' Source='${f_native}'/>" )
|
|
ENDIF()
|
|
ENDIF()
|
|
ENDFOREACH()
|
|
FILE(APPEND ${file} "</DirectoryRef>\n")
|
|
IF(NONEXEFILES)
|
|
GENERATE_GUID(guid)
|
|
SET(ComponentId "C._files_${COMP_NAME}.${DirectoryRefId}")
|
|
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>")
|
|
FILE(READ ${d_name}.wxs WIX_TMP)
|
|
SET(CPACK_WIX_COMPONENTS "${CPACK_WIX_COMPONENTS}\n${WIX_TMP}")
|
|
FILE(REMOVE ${d_name}.wxs)
|
|
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)
|
|
|
|
SET(EXTRA_CANDLE_ARGS)
|
|
IF("$ENV{EXTRA_CANDLE_ARGS}")
|
|
SET(EXTRA_CANDLE_ARGS "$ENV{EXTRA_CANDLE_ARGS}")
|
|
ENDIF()
|
|
|
|
SET(EXTRA_LIGHT_ARGS)
|
|
IF("$ENV{EXTRA_LIGHT_ARGS}")
|
|
SET(EXTRA_LIGHT_ARGS "$ENV{EXTRA_LIGHT_ARGS}")
|
|
ENDIF()
|
|
|
|
FILE(REMOVE mysql_server.wixobj)
|
|
EXECUTE_PROCESS(
|
|
COMMAND ${CANDLE_EXECUTABLE} -ext WixUtilExtension mysql_server.wxs ${EXTRA_CANDLE_ARGS}
|
|
)
|
|
EXECUTE_PROCESS(
|
|
COMMAND ${LIGHT_EXECUTABLE} -ext WixUIExtension -ext WixUtilExtension
|
|
mysql_server.wixobj -out ${CPACK_PACKAGE_FILE_NAME}.msi
|
|
${EXTRA_LIGHT_ARGS}
|
|
)
|
|
|