summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-12-07 13:28:26 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-12-07 13:28:31 (GMT)
commite016d6d255f36cc17e85e27761fd01ef048a1b93 (patch)
tree315da80cb744befb438de5b12de1c57864963cc2 /Modules
parente1a09cfbd1d1802b5fc4ae9b4918bb00ce468dcc (diff)
parenta2031d3a3a6ff26640f5c8cc0d76a0076c6e74cc (diff)
downloadCMake-e016d6d255f36cc17e85e27761fd01ef048a1b93.zip
CMake-e016d6d255f36cc17e85e27761fd01ef048a1b93.tar.gz
CMake-e016d6d255f36cc17e85e27761fd01ef048a1b93.tar.bz2
Merge topic 'cpack-rpm-check-executable-flags'
a2031d3a CPack/RPM: check executable flags for debuginfo packages Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1565
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CPackRPM.cmake75
1 files changed, 73 insertions, 2 deletions
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index c5a27f9..faa2df8 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -691,6 +691,22 @@
# are the same as for :variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`.
# Note that <compName> must be in upper-case.
#
+# .. variable:: CPACK_RPM_INSTALL_WITH_EXEC
+#
+# force execute permissions on programs and shared libraries
+#
+# * Mandatory : NO
+# * Default : - (system default)
+#
+# Force set owner, group and world execute permissions on programs and shared
+# libraries. This can be used for creating valid rpm packages on systems such
+# as Debian where shared libraries do not have execute permissions set.
+#
+# .. note::
+#
+# Programs and shared libraries without execute permissions are ignored during
+# separation of debug symbols from the binary for debuginfo packages.
+#
# Packaging of Symbolic Links
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
@@ -751,7 +767,8 @@
# .. note::
#
# Packages generated from packages without binary files, with binary files but
-# without execute permissions or without debug symbols will be empty.
+# without execute permissions or without debug symbols will cause packaging
+# termination.
#
# .. variable:: CPACK_BUILD_SOURCE_DIRS
#
@@ -939,6 +956,35 @@
# Author: Eric Noulard with the help of Alexander Neundorf.
+function(get_file_permissions FILE RETURN_VAR)
+ execute_process(COMMAND ls -l ${FILE}
+ OUTPUT_VARIABLE permissions_
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ cmake_policy(SET CMP0007 NEW)
+ string(REPLACE " " ";" permissions_ "${permissions_}")
+ list(GET permissions_ 0 permissions_)
+
+ unset(text_notation_)
+ set(any_chars_ ".")
+ foreach(PERMISSION_TYPE "OWNER" "GROUP" "WORLD")
+ if(permissions_ MATCHES "${any_chars_}r.*")
+ list(APPEND text_notation_ "${PERMISSION_TYPE}_READ")
+ endif()
+ string(APPEND any_chars_ ".")
+ if(permissions_ MATCHES "${any_chars_}w.*")
+ list(APPEND text_notation_ "${PERMISSION_TYPE}_WRITE")
+ endif()
+ string(APPEND any_chars_ ".")
+ if(permissions_ MATCHES "${any_chars_}x.*")
+ list(APPEND text_notation_ "${PERMISSION_TYPE}_EXECUTE")
+ endif()
+ endforeach()
+
+ set(${RETURN_VAR} "${text_notation_}" PARENT_SCOPE)
+endfunction()
+
function(get_unix_permissions_octal_notation PERMISSIONS_VAR RETURN_VAR)
set(PERMISSIONS ${${PERMISSIONS_VAR}})
list(LENGTH PERMISSIONS PERM_LEN_PRE)
@@ -1515,7 +1561,7 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR)
RESULT_VARIABLE OBJDUMP_EXEC_RESULT
OUTPUT_VARIABLE OBJDUMP_OUT
ERROR_QUIET)
- # Check that if the given file was executable or not
+ # Check if the given file is an executable or not
if(NOT OBJDUMP_EXEC_RESULT)
string(FIND "${OBJDUMP_OUT}" "debug" FIND_RESULT)
if(FIND_RESULT GREATER -1)
@@ -1560,6 +1606,31 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR)
else()
message(WARNING "CPackRPM: File: ${F} does not contain debug symbols. They will possibly be missing from debuginfo package!")
endif()
+
+ get_file_permissions("${WORKING_DIR}/${F}" permissions_)
+ cmake_policy(SET CMP0057 NEW)
+ if(NOT "USER_EXECUTE" IN_LIST permissions_ AND
+ NOT "GROUP_EXECUTE" IN_LIST permissions_ AND
+ NOT "WORLD_EXECUTE" IN_LIST permissions_)
+ if(CPACK_RPM_INSTALL_WITH_EXEC)
+ execute_process(COMMAND chmod a+x ${WORKING_DIR}/${F}
+ RESULT_VARIABLE res_
+ ERROR_VARIABLE err_
+ OUTPUT_QUIET)
+
+ if(res_)
+ message(FATAL_ERROR "CPackRPM: could not apply execute permissions "
+ "requested by CPACK_RPM_INSTALL_WITH_EXEC variable on "
+ "'${WORKING_DIR}/${F}'! Reason: '${err_}'")
+ endif()
+ else()
+ message(AUTHOR_WARNING "CPackRPM: File: ${WORKING_DIR}/${F} does not "
+ "have execute permissions. Debuginfo symbols will not be extracted"
+ "! Missing debuginfo may cause packaging failure. Consider setting "
+ "execute permissions or setting 'CPACK_RPM_INSTALL_WITH_EXEC' "
+ "variable.")
+ endif()
+ endif()
endif()
endforeach()