Commit 22a8654a authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

CMake fixes for buildbot/MSI package building and signing:

- FIND_PROGRAM (signtool) will now get a hint about location of signtool.exe (Windows SDK)
- Targets "package" or "msi" will now fail, l if signing is requested but does not work
  (e.g invalid certificate)
- During install, do not re-sign binaries, if they are already signed.
- Preserve mysqld_error.h timestamp whenever possible. This helps avoiding situations 
where the whole server is rebuilt, whenever comp_err.exe changes (for example after code 
signing, or also after a minor fix in mysys)
- Fix Wix error in UpgradeVersion, if patch part of the version is 0.
parent eaed2605
...@@ -22,19 +22,25 @@ TARGET_LINK_LIBRARIES(comp_err debug dbug mysys strings zlib wsock32) ...@@ -22,19 +22,25 @@ TARGET_LINK_LIBRARIES(comp_err debug dbug mysys strings zlib wsock32)
GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION) GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION)
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/include/mysqld_error.h # Generate mysqld_error.h
# Try not to change its timestamp if not necessary(as touching
# mysqld_error.h results in rebuild of the almost whole server)
# To preserve timestamp, first generate a temp header file, then copy it
# to mysqld_error.h using cmake -E copy_if_different
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp
COMMAND ${COMP_ERR_EXE} COMMAND ${COMP_ERR_EXE}
--charset=${PROJECT_SOURCE_DIR}/sql/share/charsets --charset=${PROJECT_SOURCE_DIR}/sql/share/charsets
--out-dir=${CMAKE_BINARY_DIR}/sql/share/ --out-dir=${CMAKE_BINARY_DIR}/sql/share/
--header_file=${CMAKE_BINARY_DIR}/include/mysqld_error.h --header_file=${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp
--name_file=${CMAKE_BINARY_DIR}/include/mysqld_ername.h --name_file=${CMAKE_BINARY_DIR}/include/mysqld_ername.h
--state_file=${CMAKE_BINARY_DIR}/include/sql_state.h --state_file=${CMAKE_BINARY_DIR}/include/sql_state.h
--in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt --in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp ${CMAKE_BINARY_DIR}/include/mysqld_error.h
DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt) DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt)
ADD_CUSTOM_TARGET(GenError ADD_CUSTOM_TARGET(GenError
ALL ALL
DEPENDS ${CMAKE_BINARY_DIR}/include/mysqld_error.h) DEPENDS ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp)
ADD_EXECUTABLE(my_print_defaults my_print_defaults.c) ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
TARGET_LINK_LIBRARIES(my_print_defaults strings mysys debug dbug taocrypt wsock32) TARGET_LINK_LIBRARIES(my_print_defaults strings mysys debug dbug taocrypt wsock32)
......
...@@ -151,29 +151,13 @@ IF(WIN32) ...@@ -151,29 +151,13 @@ 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"
)
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()
...@@ -195,10 +179,15 @@ MACRO(SIGN_TARGET) ...@@ -195,10 +179,15 @@ MACRO(SIGN_TARGET)
ENDIF() ENDIF()
INSTALL(CODE INSTALL(CODE
"EXECUTE_PROCESS(COMMAND "EXECUTE_PROCESS(COMMAND
\"${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}\" \"${SIGNTOOL_EXECUTABLE}\" sign ${SIGNTOOL_PARAMETERS} \"${target_location}\"
RESULT_VARIABLE ERR) RESULT_VARIABLE ERR)
ENDIF()
IF(NOT \${ERR} EQUAL 0) IF(NOT \${ERR} EQUAL 0)
MESSAGE(FATAL_ERROR \"Error signing ${target_location}\") MESSAGE(FATAL_ERROR \"Error signing '${target_location}'\")
ENDIF() ENDIF()
" ${comp}) " ${comp})
ENDIF() ENDIF()
...@@ -229,7 +218,7 @@ FUNCTION(MYSQL_INSTALL_TARGETS) ...@@ -229,7 +218,7 @@ 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} ${COMP}) SIGN_TARGET(${target} ${COMP})
ENDIF() ENDIF()
# Install man pages on Unix # Install man pages on Unix
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<!-- Upgrade --> <!-- Upgrade -->
<Upgrade Id="@CPACK_WIX_UPGRADE_CODE@"> <Upgrade Id="@CPACK_WIX_UPGRADE_CODE@">
<?if "@PATCH_VERSION@" != "0"?>
<UpgradeVersion <UpgradeVersion
Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.0" Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.0"
IncludeMinimum="yes" IncludeMinimum="yes"
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
Property="OLDERVERSIONBEINGUPGRADED" Property="OLDERVERSIONBEINGUPGRADED"
MigrateFeatures="yes" MigrateFeatures="yes"
/> />
<?endif?>
<UpgradeVersion <UpgradeVersion
Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@" Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@"
Maximum="@MAJOR_VERSION@.@MINOR_VERSION@.999" Maximum="@MAJOR_VERSION@.@MINOR_VERSION@.999"
......
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