CPackRPM: Fix CPACK_RPM_PACKAGE_ARCHITECTURE

BuildArch must only be added to a spec file for a "noarch" package or
rpmbuild will fail.  For all others, the --target argument sets the
package architecture.  In the process of Fixing rpm architecture, we
make it mandatory, adding a default value of native architecture (the
same as if no --target argument is present).  Update the documentation
at the top of the file to make it mandatory.
This commit is contained in:
Joshua A Clayton 2015-02-19 00:01:14 -08:00 committed by Brad King
parent 8804c3e0e4
commit 761562fea6
1 changed files with 15 additions and 6 deletions

View File

@ -54,8 +54,8 @@
#
# 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.
#
@ -619,12 +619,20 @@ 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})
if(${_CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch")
set(TMP_RPM_BUILDARCH "Buildarch: ${_CPACK_RPM_PACKAGE_ARCHITECTURE}")
else()
set(TMP_RPM_BUILDARCH "")
endif()
@ -934,7 +942,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
@ -1282,6 +1290,7 @@ if(RPMBUILD_EXECUTABLE)
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