summaryrefslogtreecommitdiffstats
path: root/Modules/CPackRPM.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/CPackRPM.cmake')
-rw-r--r--Modules/CPackRPM.cmake42
1 files changed, 26 insertions, 16 deletions
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index e3f74d8..fce8236 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -51,11 +51,12 @@
# * Default : CPACK_PACKAGE_VERSION
#
# .. variable:: CPACK_RPM_PACKAGE_ARCHITECTURE
+# CPACK_RPM_<component>_PACKAGE_ARCHITECTURE
#
# The RPM package architecture.
#
-# * Mandatory : NO
-# * Default : -
+# * Mandatory : YES
+# * Default : Native architecture output by "uname -m"
#
# This may be set to "noarch" if you know you are building a noarch package.
#
@@ -620,12 +621,30 @@ endif()
# RPM "Version" from RPM "Release"
string(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION})
-# CPACK_RPM_PACKAGE_ARCHITECTURE (optional)
-if(CPACK_RPM_PACKAGE_ARCHITECTURE)
- set(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
+# CPACK_RPM_PACKAGE_ARCHITECTURE (mandatory)
+if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
+ execute_process(COMMAND uname "-m"
+ OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+else()
if(CPACK_RPM_PACKAGE_DEBUG)
message("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
endif()
+endif()
+
+set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE})
+
+#prefer component architecture
+if(CPACK_RPM_PACKAGE_COMPONENT)
+ if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE)
+ set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE})
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: using component build arch = ${_CPACK_RPM_PACKAGE_ARCHITECTURE}")
+ endif()
+ endif()
+endif()
+if(${_CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch")
+ set(TMP_RPM_BUILDARCH "Buildarch: ${_CPACK_RPM_PACKAGE_ARCHITECTURE}")
else()
set(TMP_RPM_BUILDARCH "")
endif()
@@ -935,7 +954,7 @@ file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SOURCES)
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS)
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS)
-#set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
+#set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${_CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
# it seems rpmbuild can't handle spaces in the path
# neither escaping (as below) nor putting quotes around the path seem to help
@@ -1164,13 +1183,6 @@ if(CPACK_RPM_PACKAGE_DEBUG)
message("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}")
endif()
-# protect @ in pathname in order to avoid their
-# interpretation during the configure_file step
-set(CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES}")
-set(PROTECTED_AT "@")
-string(REPLACE "@" "\@PROTECTED_AT\@" CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES_LIST}")
-set(CPACK_RPM_INSTALL_FILES_LIST "")
-
#
# USER generated/provided spec file handling.
#
@@ -1281,15 +1293,13 @@ else()
configure_file(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY)
endif()
-# remove AT protection
-unset(PROTECTED_AT)
-
if(RPMBUILD_EXECUTABLE)
# Now call rpmbuild using the SPECFILE
execute_process(
COMMAND "${RPMBUILD_EXECUTABLE}" -bb
--define "_topdir ${CPACK_RPM_DIRECTORY}"
--buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
+ --target "${_CPACK_RPM_PACKAGE_ARCHITECTURE}"
"${CPACK_RPM_BINARY_SPECFILE}"
WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT