Merge topic 'cpack-rpm-adding-dist-to-release-tag'

f5089cfc CPack/RPM adding dist to release tag test
f7003a60 CPack/RPM release dist tag support
This commit is contained in:
Brad King 2016-05-16 10:11:35 -04:00 committed by CMake Topic Stage
commit d3db070e9e
6 changed files with 52 additions and 3 deletions

View File

@ -0,0 +1,7 @@
cpack-rpm-adding-dist-to-release-tag
------------------------------------
* The :module:`CPackRPM` module learned how to set RPM ``dist`` tag as part of
RPM ``Release:`` tag when enabled (mandatory on some Linux distributions for
e.g. on Fedora).
See :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`.

View File

@ -104,10 +104,27 @@
#
# This is the numbering of the RPM package itself, i.e. the version of the
# packaging and not the version of the content (see
# CPACK_RPM_PACKAGE_VERSION). One may change the default value if the
# previous packaging was buggy and/or you want to put here a fancy Linux
# :variable:`CPACK_RPM_PACKAGE_VERSION`). One may change the default value if
# the previous packaging was buggy and/or you want to put here a fancy Linux
# distro specific numbering.
#
# .. note::
#
# This is the string that goes into the RPM ``Release:`` field. Some distros
# (e.g. Fedora, CentOS) require ``1%{?dist}`` format and not just a number.
# ``%{?dist}`` part can be added by setting :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`.
#
# .. variable:: CPACK_RPM_PACKAGE_RELEASE_DIST
#
# The dist tag that is added RPM ``Release:`` field.
#
# * Mandatory : NO
# * Default : OFF
#
# This is the reported ``%{dist}`` tag from the current distribution or empty
# ``%{dist}`` if RPM macro is not set. If this variable is set then RPM
# ``Release:`` field value is set to ``${CPACK_RPM_PACKAGE_RELEASE}%{?dist}``.
#
# .. variable:: CPACK_RPM_PACKAGE_LICENSE
#
# The RPM package license policy.
@ -1341,7 +1358,11 @@ function(cpack_rpm_generate_package)
# This is the case when the packaging is buggy (not) the software :=)
# If not set, 1 is a good candidate
if(NOT CPACK_RPM_PACKAGE_RELEASE)
set(CPACK_RPM_PACKAGE_RELEASE 1)
set(CPACK_RPM_PACKAGE_RELEASE "1")
endif()
if(CPACK_RPM_PACKAGE_RELEASE_DIST)
set(CPACK_RPM_PACKAGE_RELEASE "${CPACK_RPM_PACKAGE_RELEASE}%{?dist}")
endif()
# CPACK_RPM_PACKAGE_LICENSE

View File

@ -0,0 +1,5 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "rpm_dist*.rpm")
set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$")

View File

@ -0,0 +1,11 @@
execute_process(COMMAND ${RPMBUILD_EXECUTABLE} -E %{?dist}
OUTPUT_VARIABLE DIST_TAG
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(whitespaces_ "[\t\n\r ]*")
getPackageInfo("${FOUND_FILE_1}" "FILE_INFO_")
if(NOT FILE_INFO_ MATCHES ".*Release${whitespaces_}:${whitespaces_}1${DIST_TAG}")
message(FATAL_ERROR "Unexpected Release in '${FOUND_FILE_1}'; file info: '${FILE_INFO_}'")
endif()

View File

@ -0,0 +1,4 @@
install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
set(CPACK_PACKAGE_NAME "rpm_dist")

View File

@ -12,6 +12,7 @@ run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true)
run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB;TGZ" true)
run_cpack_test(RPM_CUSTOM_NAMES "RPM" true)
run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false)
run_cpack_test(RPM_DIST "RPM" false)
run_cpack_test(INSTALL_SCRIPTS "RPM" false)
run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true)
run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true)