summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/release/dev/cpack-rpm-refactored-file-listing.rst6
-rw-r--r--Modules/CPackRPM.cmake199
-rw-r--r--Tests/CPackComponentsForAll/CMakeLists.txt7
-rw-r--r--Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake9
-rw-r--r--Tests/CPackComponentsForAll/mylib17
5 files changed, 167 insertions, 71 deletions
diff --git a/Help/release/dev/cpack-rpm-refactored-file-listing.rst b/Help/release/dev/cpack-rpm-refactored-file-listing.rst
new file mode 100644
index 0000000..b4a5025
--- /dev/null
+++ b/Help/release/dev/cpack-rpm-refactored-file-listing.rst
@@ -0,0 +1,6 @@
+cpack-rpm-refactored-file-listing
+---------------------------------
+
+* The :module:`CPackRPM` module learned a new
+ :variable:`CPACK_RPM_ADDITIONAL_MAN_DIRS` variable to specify
+ directories containing man pages for the brp-compress RPM macro.
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index b8d518c..fdba90e 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -419,6 +419,33 @@
# May be used to remove CPACK_PACKAGING_INSTALL_PREFIX and CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
# from relocatable RPM prefix paths.
#
+# .. variable:: CPACK_RPM_ADDITIONAL_MAN_DIRS
+#
+# * Mandatory : NO
+# * Default : -
+#
+# May be used to set additional man dirs that could potentially be compressed
+# by brp-compress RPM macro. Variable content must be a list of regular
+# expressions that point to directories containing man files or to man files
+# directly. Note that in order to compress man pages a path must also be
+# present in brp-compress RPM script and that brp-compress script must be
+# added to RPM configuration by the operating system.
+#
+# Regular expressions that are added by default were taken from brp-compress
+# RPM macro:
+#
+# - /usr/man/man.*
+# - /usr/man/.*/man.*
+# - /usr/info.*
+# - /usr/share/man/man.*
+# - /usr/share/man/.*/man.*
+# - /usr/share/info.*
+# - /usr/kerberos/man.*
+# - /usr/X11R6/man/man.*
+# - /usr/lib/perl5/man/man.*
+# - /usr/share/doc/.*/man/man.*
+# - /usr/lib/.*/man/man.*
+#
# Packaging of Symbolic Links
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
@@ -538,6 +565,107 @@ function(cpack_rpm_prepare_relocation_paths)
set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}" PARENT_SCOPE)
endfunction()
+function(cpack_rpm_prepare_content_list)
+ # get files list
+ cmake_policy(PUSH)
+ cmake_policy(SET CMP0009 NEW)
+ file(GLOB_RECURSE CPACK_RPM_INSTALL_FILES LIST_DIRECTORIES true RELATIVE "${WDIR}" "${WDIR}/*")
+ cmake_policy(POP)
+ set(CPACK_RPM_INSTALL_FILES "/${CPACK_RPM_INSTALL_FILES}")
+ string(REPLACE ";" ";/" CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}")
+
+ # if we are creating a relocatable package, omit parent directories of
+ # CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list"
+ # which is passed to the find command that generates the content-list
+ if(CPACK_RPM_PACKAGE_RELOCATABLE)
+ # get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are
+ # 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)
+ list(SORT RPM_USED_PACKAGE_PREFIXES)
+ set(_DISTINCT_PATH "NOT_SET")
+ foreach(_RPM_RELOCATION_PREFIX ${RPM_USED_PACKAGE_PREFIXES})
+ if(NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*")
+ set(_DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}")
+
+ string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS " ${_RPM_RELOCATION_PREFIX}")
+ list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1)
+ unset(_TMP_LIST)
+ # Now generate all of the parent dirs of the relocation path
+ foreach(_PREFIX_PATH_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS})
+ list(APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}")
+ string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}")
+ separate_arguments(_OMIT_DIR)
+ list(APPEND _RPM_DIRS_TO_OMIT ${_OMIT_DIR})
+ endforeach()
+ endif()
+ endforeach()
+ endif()
+
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}")
+ endif()
+
+ if(NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
+ set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/include)
+ if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION)
+ message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.")
+ list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}")
+ endif()
+ endif()
+
+ if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}")
+ endif()
+ list(APPEND _RPM_DIRS_TO_OMIT ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST})
+ endif()
+
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}")
+ endif()
+
+ list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES ${_RPM_DIRS_TO_OMIT})
+
+ # add man paths that will be compressed
+ # (copied from /usr/lib/rpm/brp-compress - script that does the actual
+ # compressing)
+ list(APPEND MAN_LOCATIONS "/usr/man/man.*" "/usr/man/.*/man.*" "/usr/info.*"
+ "/usr/share/man/man.*" "/usr/share/man/.*/man.*" "/usr/share/info.*"
+ "/usr/kerberos/man.*" "/usr/X11R6/man/man.*" "/usr/lib/perl5/man/man.*"
+ "/usr/share/doc/.*/man/man.*" "/usr/lib/.*/man/man.*")
+
+ if(CPACK_RPM_ADDITIONAL_MAN_DIRS)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: CPACK_RPM_ADDITIONAL_MAN_DIRS= ${CPACK_RPM_ADDITIONAL_MAN_DIRS}")
+ endif()
+ list(APPEND MAN_LOCATIONS ${CPACK_RPM_ADDITIONAL_MAN_DIRS})
+ endif()
+
+ foreach(PACK_LOCATION IN LISTS CPACK_RPM_INSTALL_FILES)
+ foreach(MAN_LOCATION IN LISTS MAN_LOCATIONS)
+ # man pages are files inside a certain location
+ if(PACK_LOCATION MATCHES "${MAN_LOCATION}/"
+ AND NOT IS_DIRECTORY "${WDIR}${PACK_LOCATION}"
+ AND NOT IS_SYMLINK "${WDIR}${PACK_LOCATION}")
+ list(FIND CPACK_RPM_INSTALL_FILES "${PACK_LOCATION}" INDEX)
+ # insert file location that covers compressed man pages
+ # even if using a wildcard causes duplicates as those are
+ # handled by RPM and we still keep the same file list
+ # in spec file - wildcard only represents file type (e.g. .gz)
+ list(INSERT CPACK_RPM_INSTALL_FILES ${INDEX} "${PACK_LOCATION}*")
+ # remove file location that doesn't cover compressed man pages
+ math(EXPR INDEX ${INDEX}+1)
+ list(REMOVE_AT CPACK_RPM_INSTALL_FILES ${INDEX})
+
+ break()
+ endif()
+ endforeach()
+ endforeach()
+
+ set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}" PARENT_SCOPE)
+endfunction()
+
function(cpack_rpm_symlink_get_relocation_prefixes LOCATION PACKAGE_PREFIXES RETURN_VARIABLE)
foreach(PKG_PREFIX IN LISTS PACKAGE_PREFIXES)
string(REGEX MATCH "^${PKG_PREFIX}/.*" FOUND_ "${LOCATION}")
@@ -1285,76 +1413,7 @@ function(cpack_rpm_generate_package)
#string(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
set(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
- # if we are creating a relocatable package, omit parent directories of
- # CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list"
- # which is passed to the find command that generates the content-list
- if(CPACK_RPM_PACKAGE_RELOCATABLE)
- # get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are
- # 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)
- set(SORTED_RPM_USED_PACKAGE_PREFIXES "${RPM_USED_PACKAGE_PREFIXES}")
- list(SORT SORTED_RPM_USED_PACKAGE_PREFIXES)
- set(_DISTINCT_PATH "NOT_SET")
- foreach(_RPM_RELOCATION_PREFIX ${SORTED_RPM_USED_PACKAGE_PREFIXES})
- if(NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*")
- set(_DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}")
-
- string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS ".${_RPM_RELOCATION_PREFIX}")
- list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1)
- unset(_TMP_LIST)
- # Now generate all of the parent dirs of the relocation path
- foreach(_PREFIX_PATH_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS})
- list(APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}")
- string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}")
- list(FIND _RPM_DIRS_TO_OMIT "${_OMIT_DIR}" _DUPLICATE_FOUND)
- 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()
- endif()
-
- if (CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}")
- endif()
-
- if (NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
- set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/include)
- if (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION)
- message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.")
- list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}")
- endif()
- endif()
-
- if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
- if (CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}")
- endif()
- foreach(_DIR ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST})
- list(APPEND _RPM_DIRS_TO_OMIT "-o;-path;.${_DIR}")
- endforeach()
- endif()
- if (CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}")
- endif()
-
- # Use files tree to construct files command (spec file)
- # We should not forget to include symlinks (thus -o -type l)
- # We should include directory as well (thus -type d)
- # but not the main local dir "." (thus -a -not -name ".")
- # We must remove the './' due to the local search and escape the
- # file name by enclosing it between double quotes (thus the sed)
- # Then we must authorize any man pages extension (adding * at the end)
- # because rpmbuild may automatically compress those files
- execute_process(COMMAND find . -type f -o -type l -o (-type d -a -not ( -name "." ${_RPM_DIRS_TO_OMIT} ) )
- COMMAND sed s:.*/man.*/.*:&*:
- COMMAND sed s/\\.\\\(.*\\\)/\"\\1\"/
- WORKING_DIRECTORY "${WDIR}"
- OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES)
+ cpack_rpm_prepare_content_list()
# In component case, put CPACK_ABSOLUTE_DESTINATION_FILES_<COMPONENT>
# into CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt
index 1cc34b0..823f6db 100644
--- a/Tests/CPackComponentsForAll/CMakeLists.txt
+++ b/Tests/CPackComponentsForAll/CMakeLists.txt
@@ -50,6 +50,13 @@ install(FILES mylib.h
COMPONENT headers)
if("${CPACK_GENERATOR}" MATCHES "RPM")
+ ############## test man pages
+ install(FILES mylib
+ DESTINATION share/man/mylib/man3/mylib.1)
+ install(FILES mylib
+ DESTINATION share/man/mylib/man3/mylib.1 RENAME mylib2)
+
+ ############## test symlinks
# Package symbolic links
install(DIRECTORY DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two/depth_three COMPONENT libraries)
install(DIRECTORY DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_two/depth_two/different_relocatable/bar COMPONENT libraries)
diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
index e747052..d94a477 100644
--- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
+++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
@@ -233,7 +233,14 @@ if(CPackGen MATCHES "RPM")
/usr/foo/bar/bin/@in@_@path@@with/@and
/usr/foo/bar/bin/@in@_@path@@with/@and/@
/usr/foo/bar/bin/@in@_@path@@with/@and/@/@in_path@
-/usr/foo/bar/bin/@in@_@path@@with/@and/@/@in_path@/mylibapp2$")
+/usr/foo/bar/bin/@in@_@path@@with/@and/@/@in_path@/mylibapp2
+/usr/foo/bar/share
+/usr/foo/bar/share/man
+/usr/foo/bar/share/man/mylib
+/usr/foo/bar/share/man/mylib/man3
+/usr/foo/bar/share/man/mylib/man3/mylib.1
+/usr/foo/bar/share/man/mylib/man3/mylib.1/mylib
+/usr/foo/bar/share/man/mylib/man3/mylib.1/mylib2$")
else()
message(FATAL_ERROR "error: unexpected rpm package '${check_file}'")
endif()
diff --git a/Tests/CPackComponentsForAll/mylib b/Tests/CPackComponentsForAll/mylib
new file mode 100644
index 0000000..e3bd05c
--- /dev/null
+++ b/Tests/CPackComponentsForAll/mylib
@@ -0,0 +1,17 @@
+.\" Manpage for mylib.
+.\" Contact bugs@mylib_author.net.in to correct errors or typos.
+.TH mylib 3 "01 May 2015" "1.0" "mylib.so man page"
+.SH NAME
+mylib \- cpack testing lib
+.SH SYNOPSIS
+mylib.so
+.SH DESCRIPTION
+mylib.so test man page.
+.SH OPTIONS
+Lib does not take any options.
+.SH SEE ALSO
+mylib(3)
+.SH BUGS
+No known bugs.
+.SH AUTHOR
+Someone (author@lib_author.net.in)