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