Make cpack fail if the current git commit id does not match the one at cmake time.

cpack would happily build a package with an incorrect version.
master
Rogier 2016-08-03 08:07:27 +02:00
parent 1ea50597a9
commit cbfb7e6979
3 changed files with 9 additions and 0 deletions

View File

@ -1,4 +1,10 @@
execute_process(COMMAND git describe --long "--match=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" --dirty=-WIP --abbrev=8
RESULT_VARIABLE VERSION_EXIT OUTPUT_VARIABLE CURRENT_GIT_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT CPACK_GIT_VERSION STREQUAL CURRENT_GIT_VERSION)
message(FATAL_ERROR "The current git commit number (${CURRENT_GIT_VERSION}) does not match the number at cmake time (${CPACK_GIT_VERSION}).\nPlease rebuild the project (cmake . && make)")
endif(NOT CPACK_GIT_VERSION STREQUAL CURRENT_GIT_VERSION)
if(CPACK_GENERATOR STREQUAL "TGZ")
if(CPACK_TGZ_PACKAGE_FILE_NAME)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_TGZ_PACKAGE_FILE_NAME}")

View File

@ -359,6 +359,7 @@ set(DUMPNODES_SCRIPTS
set(PACKAGING_VERSION "1" CACHE STRING "Version of the packaging - '1' by default; increment when building a new package from the same sources (i.e. from the same commit)")
#set(CPACK_SET_DESTDIR ON)
set(CPACK_GIT_VERSION ${GIT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Map generator for Minetest")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_HOME_DIRECTORY}/package-description.txt")
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})

View File

@ -14,6 +14,8 @@
- Workaround to allow compilation with clang when using leveldb.
This is broken due to libstdc++ ABI incompatibility
- Fixed compilation failure on FreeBSD (10.3) using gcc
- Detect when package version will not match current git commit id,
and refuse to build package with wrong version.
[31 May 2016]
Features:
- Support for postgresql backend added