Commit 3bb552ea authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

fix signing and packaging

parent 213436c0
......@@ -36,7 +36,9 @@ MACRO (INSTALL_DEBUG_SYMBOLS targets)
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" pdb_location ${pdb_location})
ENDIF()
IF(target STREQUAL "mysqld")
SET(comp Server)
SET(comp Server)
ELSEIF(pdb_location MATCHES "mysql-test")
SET(comp Tests)
ELSE()
SET(comp Debuginfo)
ENDIF()
......@@ -78,7 +80,6 @@ FUNCTION(INSTALL_MANPAGE file)
ELSE()
SET(SECTION man8)
ENDIF()
MESSAGE("huj!")
INSTALL(FILES "${MANPAGE}" DESTINATION "${INSTALL_MANDIR}/${SECTION}"
COMPONENT ManPages)
ENDIF()
......@@ -150,34 +151,26 @@ IF(WIN32)
SET(SIGNTOOL_PARAMETERS
/a /t http://timestamp.verisign.com/scripts/timstamp.dll
CACHE STRING "parameters for signtool (list)")
FIND_PROGRAM(SIGNTOOL_EXECUTABLE signtool)
FIND_PROGRAM(SIGNTOOL_EXECUTABLE signtool
PATHS "$ENV{ProgramFiles}/Microsoft SDKs/Windows/v7.0A/bin"
"$ENV{ProgramFiles}/Windows Kits/8.0/bin/x86"
)
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 target)
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)
......@@ -187,12 +180,17 @@ MACRO(SIGN_TARGET target)
ENDIF()
INSTALL(CODE
"EXECUTE_PROCESS(COMMAND
${SIGNTOOL_EXECUTABLE} sign ${SIGNTOOL_PARAMETERS} ${target_location}
\"${SIGNTOOL_EXECUTABLE}\" verify /pa /q \"${target_location}\"
RESULT_VARIABLE ERR)
IF(NOT \${ERR} EQUAL 0)
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()
")
ENDIF()
IF(NOT \${ERR} EQUAL 0)
MESSAGE(FATAL_ERROR \"Error signing '${target_location}'\")
ENDIF()
" ${comp})
ENDIF()
ENDMACRO()
......@@ -207,6 +205,10 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
""
${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")
......@@ -218,8 +220,8 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
FOREACH(target ${TARGETS})
# If signing is required, sign executables before installing
IF(SIGNCODE AND SIGNCODE_ENABLED)
SIGN_TARGET(${target})
IF(SIGNCODE)
SIGN_TARGET(${target} ${COMP})
ENDIF()
# Install man pages on Unix
IF(UNIX)
......@@ -227,9 +229,7 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
INSTALL_MANPAGE(${target_location})
ENDIF()
ENDFOREACH()
IF(ARG_COMPONENT)
SET(COMP COMPONENT ${ARG_COMPONENT})
ENDIF()
INSTALL(TARGETS ${TARGETS} DESTINATION ${ARG_DESTINATION} ${COMP})
SET(INSTALL_LOCATION ${ARG_DESTINATION} )
INSTALL_DEBUG_SYMBOLS("${TARGETS}")
......
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