diff options
author | Eric Noulard <eric.noulard@gmail.com> | 2009-11-09 21:17:22 (GMT) |
---|---|---|
committer | Eric Noulard <eric.noulard@gmail.com> | 2009-11-09 21:17:22 (GMT) |
commit | 28f54d0b85508ce46b337411a142546283171d39 (patch) | |
tree | e76f049f07d6a18ffbb4d49ed1f57206c8c39b29 /Modules | |
parent | f7899c7445121594d2e9324e4a3de815e1066255 (diff) | |
download | CMake-28f54d0b85508ce46b337411a142546283171d39.zip CMake-28f54d0b85508ce46b337411a142546283171d39.tar.gz CMake-28f54d0b85508ce46b337411a142546283171d39.tar.bz2 |
CPackRPM:: Support USER supplied spec files (bug 9679)
Eric
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CPackRPM.cmake | 124 |
1 files changed, 79 insertions, 45 deletions
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 5167fa7..6aa867a 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -69,6 +69,20 @@ # May be set when invoking cpack in order to trace debug informations # during CPack RPM run. For example you may launch CPack like this # cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM +# CPACK_RPM_USER_BINARY_SPECFILE +# Mandatory : NO +# Default : - +# May be set by the user in order to specify a USER binary spec file +# to be used by CPackRPM instead of generating the file. +# The specified file will be processed by CONFIGURE_FILE( @ONLY). +# CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE +# Mandatory : NO +# Default : - +# If set CPack will generate a template for USER specified binary +# spec file and stop with an error. For example launch CPack like this +# cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM +# The user may then use this file in order to hand-craft is own +# binary spec file which may be used with CPACK_RPM_USER_BINARY_SPECFILE. #============================================================================= # Copyright 2007-2009 Kitware, Inc. @@ -255,10 +269,6 @@ IF(CPACK_RPM_SPEC_MORE_DEFINE) ENDIF(CPACK_RPM_PACKAGE_DEBUG) ENDIF(CPACK_RPM_SPEC_MORE_DEFINE) -# CPACK_RPM_USER_BINARY_SPECFILE -# FIXME when this is set then CPack should us the -# user provided file. - # Now we may create the RPM build tree structure SET(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}") MESSAGE(STATUS "CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}") @@ -283,49 +293,52 @@ EXECUTE_PROCESS(COMMAND find -type f COMMAND sed {s/\\.//} WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) - + +# The name of the final spec file to be used by rpmbuild SET(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}.spec") -IF(CPACK_RPM_USER_BINARY_SPECFILE) - # User may have specified SPECFILE just use it - MESSAGE("CPackRPM: Will use user specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}") - # Note that user provided file is processed for @var replacement - CONFIGURE_FILE(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY) -ELSE(CPACK_RPM_USER_BINARY_SPECFILE) - # No User specified spec file generate a valid one using var values - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") - MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") - MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}") - MESSAGE("CPackRPM:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") - MESSAGE("CPackRPM:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") - MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") - MESSAGE("CPackRPM:Debug: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}") - MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") - MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) - FILE(WRITE ${CPACK_RPM_BINARY_SPECFILE} - "# -*- rpm-spec -*- -Buildroot: ${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME} -Summary: ${CPACK_RPM_PACKAGE_SUMMARY} -Name: ${CPACK_RPM_PACKAGE_NAME} -Version: ${CPACK_RPM_PACKAGE_VERSION} -Release: ${CPACK_RPM_PACKAGE_RELEASE} -License: ${CPACK_RPM_PACKAGE_LICENSE} -Group: ${CPACK_RPM_PACKAGE_GROUP} -Vendor: ${CPACK_RPM_PACKAGE_VENDOR} -${TMP_RPM_REQUIRES} -${TMP_RPM_BUILDARCH} - -#p define prefix ${CMAKE_INSTALL_PREFIX} -%define _rpmdir ${CPACK_RPM_DIRECTORY} -%define _rpmfilename ${CPACK_RPM_FILE_NAME} + +# Print out some debug information if we were asked for that +IF(CPACK_RPM_PACKAGE_DEBUG) + MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") + MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") + MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}") + MESSAGE("CPackRPM:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") + MESSAGE("CPackRPM:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") + MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") + MESSAGE("CPackRPM:Debug: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}") + MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") + MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") +ENDIF(CPACK_RPM_PACKAGE_DEBUG) + +# USER generated spec file handling. +# We should generate a spec file template: +# - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE +# - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE +# +IF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) + FILE(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in + "# -*- rpm-spec -*- +Buildroot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@ +Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ +Name: \@CPACK_RPM_PACKAGE_NAME\@ +Version: \@CPACK_RPM_PACKAGE_VERSION\@ +Release: \@CPACK_RPM_PACKAGE_RELEASE\@ +License: \@CPACK_RPM_PACKAGE_LICENSE\@ +Group: \@CPACK_RPM_PACKAGE_GROUP\@ +Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ +\@TMP_RPM_REQUIRES\@ +\@TMP_RPM_BUILDARCH\@ + +#p define prefix \@CMAKE_INSTALL_PREFIX\@ +%define _rpmdir \@CPACK_RPM_DIRECTORY\@ +%define _rpmfilename \@CPACK_RPM_FILE_NAME\@ %define _unpackaged_files_terminate_build 0 -%define _topdir ${CPACK_RPM_DIRECTORY} -${TMP_RPM_SPEC_INSTALL_POST} -${CPACK_RPM_SPEC_MORE_DEFINE} - +%define _topdir \@CPACK_RPM_DIRECTORY\@ +\@TMP_RPM_SPEC_INSTALL_POST\@ +\@CPACK_RPM_SPEC_MORE_DEFINE\@ + %description -${CPACK_RPM_PACKAGE_DESCRIPTION} +\@CPACK_RPM_PACKAGE_DESCRIPTION\@ # This is a shortcutted spec file # generated by CMake RPM generator @@ -348,6 +361,8 @@ ${CPACK_RPM_PACKAGE_DESCRIPTION} ${CPACK_RPM_INSTALL_FILES} %changelog +* Wed Oct 07 2009 Erk <eric.noulard@gmail.com> + Add user custom spec file support * Sat Oct 03 2009 Kami <cmoidavid@gmail.com> Update to handle more precisely the files section * Mon Oct 03 2008 Erk <eric.noulard@gmail.com> @@ -358,9 +373,28 @@ ${CPACK_RPM_INSTALL_FILES} * Tue Aug 16 2007 Erk <eric.noulard@gmail.com> Generated by CPack RPM Generator and associated macros ") + # Stop here if we were asked to only generate a template USER spec file + # The generated file may then be used as a template by user who wants + # to customize their own spec file. + IF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE) + MESSAGE(FATAL_ERROR "CPackRPM: STOP here Generated USER binary spec file templare is: ${CPACK_RPM_BINARY_SPECFILE}.in") + ENDIF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE) +ENDIF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) + +# After that we may either use a user provided spec file +# or generate one using appropriate variables value. +IF(CPACK_RPM_USER_BINARY_SPECFILE) + # User may have specified SPECFILE just use it + MESSAGE("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}") + # The user provided file is processed for @var replacement + CONFIGURE_FILE(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY) +ELSE(CPACK_RPM_USER_BINARY_SPECFILE) + # No User specified spec file, will use the generated spec file + MESSAGE("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}") + # Note the just created file is processed for @var replacement + CONFIGURE_FILE(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY) ENDIF(CPACK_RPM_USER_BINARY_SPECFILE) - IF(RPMBUILD_EXECUTABLE) # Now call rpmbuild using the SPECFILE EXECUTE_PROCESS( |