Merge branch 'cpack_rpm_mulit_prefix_fixup' into release

This commit is contained in:
Brad King 2015-02-27 08:48:45 -05:00
commit 4932f59b4c
3 changed files with 62 additions and 20 deletions

View File

@ -481,6 +481,7 @@ function(cpack_rpm_prepare_relocation_paths)
endif() endif()
endforeach() endforeach()
set(RPM_USED_PACKAGE_PREFIXES "${RPM_USED_PACKAGE_PREFIXES}" PARENT_SCOPE)
set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}" PARENT_SCOPE) set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}" PARENT_SCOPE)
endfunction() endfunction()
@ -945,24 +946,31 @@ set(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
# CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list" # CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list"
# which is passed to the find command that generates the content-list # which is passed to the find command that generates the content-list
if(CPACK_RPM_PACKAGE_RELOCATABLE) if(CPACK_RPM_PACKAGE_RELOCATABLE)
# get a list of the elements in CPACK_RPM_PACKAGE_PREFIX and remove # get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are
# the final element (so the install-prefix dir itself is not omitted # destinct parent paths of other relocation paths and remove the
# final element (so the install-prefix dir itself is not omitted
# from the RPM's content-list) # from the RPM's content-list)
foreach(CPACK_RPM_PACKAGE_PREFIX ${RPM_PACKAGE_PREFIXES}) list(SORT RPM_USED_PACKAGE_PREFIXES)
string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS ".${CPACK_RPM_PACKAGE_PREFIX}") set(_DISTINCT_PATH "NOT_SET")
list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1) foreach(_RPM_RELOCATION_PREFIX ${RPM_USED_PACKAGE_PREFIXES})
unset(_TMP_LIST) if(NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*")
# Now generate all of the parent dirs of CPACK_RPM_PACKAGE_PREFIX set(_DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}")
foreach(_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS})
list(APPEND _TMP_LIST "${_ELEM}") string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS ".${_RPM_RELOCATION_PREFIX}")
string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}") list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1)
list(FIND _RPM_DIRS_TO_OMIT "${_OMIT_DIR}" _DUPLICATE_FOUND) unset(_TMP_LIST)
if(_DUPLICATE_FOUND EQUAL -1) # Now generate all of the parent dirs of the relocation path
set(_OMIT_DIR "-o -path ${_OMIT_DIR}") foreach(_PREFIX_PATH_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS})
separate_arguments(_OMIT_DIR) list(APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}")
list(APPEND _RPM_DIRS_TO_OMIT ${_OMIT_DIR}) string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}")
endif() list(FIND _RPM_DIRS_TO_OMIT "${_OMIT_DIR}" _DUPLICATE_FOUND)
endforeach() if(_DUPLICATE_FOUND EQUAL -1)
set(_OMIT_DIR "-o -path ${_OMIT_DIR}")
separate_arguments(_OMIT_DIR)
list(APPEND _RPM_DIRS_TO_OMIT ${_OMIT_DIR})
endif()
endforeach()
endif()
endforeach() endforeach()
endif() endif()

View File

@ -6,9 +6,14 @@ if(CPACK_GENERATOR MATCHES "ZIP")
endif() endif()
if(CPACK_GENERATOR MATCHES "RPM") if(CPACK_GENERATOR MATCHES "RPM")
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
set(CPACK_RPM_COMPONENT_INSTALL "ON") set(CPACK_RPM_COMPONENT_INSTALL "ON")
# test that /usr and /usr/foo get omitted in relocatable
# rpms as shortest relocation path is treated as base of
# package (/usr/foo/bar is relocatable and must exist)
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/foo/bar")
# test requires
set(CPACK_RPM_applications_PACKAGE_REQUIRES "mylib-libraries") set(CPACK_RPM_applications_PACKAGE_REQUIRES "mylib-libraries")
# test package summary override # test package summary override

View File

@ -144,7 +144,7 @@ if(CPackGen MATCHES "RPM")
# CMAKE_SIZEOF_VOID_P is not set here but lib is prefix of lib64 so # CMAKE_SIZEOF_VOID_P is not set here but lib is prefix of lib64 so
# relocation path test won't fail on OSes with lib64 library location # relocation path test won't fail on OSes with lib64 library location
include(GNUInstallDirs) include(GNUInstallDirs)
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr") set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/foo/bar")
foreach(check_file ${expected_file}) foreach(check_file ${expected_file})
string(REGEX MATCH ".*libraries.*" check_file_libraries_match ${check_file}) string(REGEX MATCH ".*libraries.*" check_file_libraries_match ${check_file})
@ -157,30 +157,44 @@ if(CPackGen MATCHES "RPM")
ERROR_QUIET ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${RPM_EXECUTABLE} -pql ${check_file}
OUTPUT_VARIABLE check_package_content
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(check_file_libraries_match) if(check_file_libraries_match)
set(check_file_match_expected_summary ".*${CPACK_RPM_libraries_PACKAGE_SUMMARY}.*") set(check_file_match_expected_summary ".*${CPACK_RPM_libraries_PACKAGE_SUMMARY}.*")
set(check_file_match_expected_description ".*${CPACK_RPM_libraries_PACKAGE_DESCRIPTION}.*") set(check_file_match_expected_description ".*${CPACK_RPM_libraries_PACKAGE_DESCRIPTION}.*")
set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(spec_regex "*libraries*") set(spec_regex "*libraries*")
set(check_content_list "^/usr/foo/bar\n/usr/foo/bar/lib.*\n/usr/foo/bar/lib.*/libmylib.a$")
elseif(check_file_headers_match) elseif(check_file_headers_match)
set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*") set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
set(check_file_match_expected_description ".*${CPACK_COMPONENT_HEADERS_DESCRIPTION}.*") set(check_file_match_expected_description ".*${CPACK_COMPONENT_HEADERS_DESCRIPTION}.*")
set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
set(spec_regex "*headers*") set(spec_regex "*headers*")
set(check_content_list "^/usr/foo/bar\n/usr/foo/bar/include\n/usr/foo/bar/include/mylib.h$")
elseif(check_file_applications_match) elseif(check_file_applications_match)
set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*") set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
set(check_file_match_expected_description ".*${CPACK_COMPONENT_APPLICATIONS_DESCRIPTION}.*") set(check_file_match_expected_description ".*${CPACK_COMPONENT_APPLICATIONS_DESCRIPTION}.*")
set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
set(spec_regex "*applications*") set(spec_regex "*applications*")
set(check_content_list "^/usr/foo/bar\n/usr/foo/bar/bin\n/usr/foo/bar/bin/mylibapp$")
elseif(check_file_Unspecified_match) elseif(check_file_Unspecified_match)
set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*") set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
set(check_file_match_expected_description ".*DESCRIPTION.*") set(check_file_match_expected_description ".*DESCRIPTION.*")
set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
set(spec_regex "*Unspecified*") set(spec_regex "*Unspecified*")
set(check_content_list "^/usr/foo/bar
/usr/foo/bar/bin
/usr/foo/bar/bin/mylibapp2$")
else() else()
message(FATAL_ERROR "error: unexpected rpm package '${check_file}'") message(FATAL_ERROR "error: unexpected rpm package '${check_file}'")
endif() endif()
#######################
# test package info
#######################
string(REGEX MATCH ${check_file_match_expected_summary} check_file_match_summary ${check_file_content}) string(REGEX MATCH ${check_file_match_expected_summary} check_file_match_summary ${check_file_content})
if(NOT check_file_match_summary) if(NOT check_file_match_summary)
@ -204,6 +218,21 @@ if(CPackGen MATCHES "RPM")
message(FATAL_ERROR "error: '${check_file}' rpm package relocation path does not match expected value - regex '${check_file_match_expected_relocation_path}'; RPM output: '${check_file_content}'; generated spec file: '${spec_file_content}'") message(FATAL_ERROR "error: '${check_file}' rpm package relocation path does not match expected value - regex '${check_file_match_expected_relocation_path}'; RPM output: '${check_file_content}'; generated spec file: '${spec_file_content}'")
endif() endif()
#######################
# test package content
#######################
string(REGEX MATCH "${check_content_list}" expected_content_list "${check_package_content}")
if(NOT expected_content_list)
file(GLOB_RECURSE spec_file "${CPackComponentsForAll_BINARY_DIR}/${spec_regex}.spec")
if(spec_file)
file(READ ${spec_file} spec_file_content)
endif()
message(FATAL_ERROR "error: '${check_file}' rpm package content does not match expected value - regex '${check_content_list}'; RPM output: '${check_package_content}'; generated spec file: '${spec_file_content}'")
endif()
endforeach() endforeach()
elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
endif() endif()