summaryrefslogtreecommitdiffstats
path: root/Modules/CPackRPM.cmake
diff options
context:
space:
mode:
authorDomen Vrankar <domen.vrankar@gmail.com>2017-12-06 19:35:21 (GMT)
committerDomen Vrankar <domen.vrankar@gmail.com>2017-12-06 20:04:20 (GMT)
commita2031d3a3a6ff26640f5c8cc0d76a0076c6e74cc (patch)
treea10b31cfef1bb39c4c19858d1a69fa96c3075deb /Modules/CPackRPM.cmake
parent92910e282adedff8c2dba488db84fb917318bb5b (diff)
downloadCMake-a2031d3a3a6ff26640f5c8cc0d76a0076c6e74cc.zip
CMake-a2031d3a3a6ff26640f5c8cc0d76a0076c6e74cc.tar.gz
CMake-a2031d3a3a6ff26640f5c8cc0d76a0076c6e74cc.tar.bz2
CPack/RPM: check executable flags for debuginfo packages
Debuginfo packages can not be created from programs and shared libraries that do not have execute permissions.
Diffstat (limited to 'Modules/CPackRPM.cmake')
-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()