diff options
Diffstat (limited to 'Modules/CPackRPM.cmake')
-rw-r--r-- | Modules/CPackRPM.cmake | 398 |
1 files changed, 199 insertions, 199 deletions
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 0ac6e17..66237d8 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -162,7 +162,7 @@ # 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). +# The specified file will be processed by configure_file( @ONLY). ##end ##variable # CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE - Spec file template. @@ -239,22 +239,22 @@ # Author: Eric Noulard with the help of Alexander Neundorf. -IF(CMAKE_BINARY_DIR) - MESSAGE(FATAL_ERROR "CPackRPM.cmake may only be used by CPack internally.") -ENDIF(CMAKE_BINARY_DIR) +if(CMAKE_BINARY_DIR) + message(FATAL_ERROR "CPackRPM.cmake may only be used by CPack internally.") +endif(CMAKE_BINARY_DIR) -IF(NOT UNIX) - MESSAGE(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.") -ENDIF(NOT UNIX) +if(NOT UNIX) + message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.") +endif(NOT UNIX) # rpmbuild is the basic command for building RPM package # it may be a simple (symbolic) link to rpm command. -FIND_PROGRAM(RPMBUILD_EXECUTABLE rpmbuild) +find_program(RPMBUILD_EXECUTABLE rpmbuild) # Check version of the rpmbuild tool this would be easier to # track bugs with users and CPackRPM debug mode. # We may use RPM version in order to check for available version dependent features -IF(RPMBUILD_EXECUTABLE) +if(RPMBUILD_EXECUTABLE) execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --version OUTPUT_VARIABLE _TMP_VERSION ERROR_QUIET @@ -262,19 +262,19 @@ IF(RPMBUILD_EXECUTABLE) string(REGEX REPLACE "^.*\ " "" RPMBUILD_EXECUTABLE_VERSION ${_TMP_VERSION}) - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) -ENDIF(RPMBUILD_EXECUTABLE) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>") + endif(CPACK_RPM_PACKAGE_DEBUG) +endif(RPMBUILD_EXECUTABLE) -IF(NOT RPMBUILD_EXECUTABLE) - MESSAGE(FATAL_ERROR "RPM package requires rpmbuild executable") -ENDIF(NOT RPMBUILD_EXECUTABLE) +if(NOT RPMBUILD_EXECUTABLE) + message(FATAL_ERROR "RPM package requires rpmbuild executable") +endif(NOT RPMBUILD_EXECUTABLE) # Display lsb_release output if DEBUG mode enable # This will help to diagnose problem with CPackRPM # because we will know on which kind of Linux we are -IF(CPACK_RPM_PACKAGE_DEBUG) +if(CPACK_RPM_PACKAGE_DEBUG) find_program(LSB_RELEASE_EXECUTABLE lsb_release) if(LSB_RELEASE_EXECUTABLE) execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -a @@ -287,37 +287,37 @@ IF(CPACK_RPM_PACKAGE_DEBUG) else (LSB_RELEASE_EXECUTABLE) set(LSB_RELEASE_OUTPUT "lsb_release not installed/found!") endif(LSB_RELEASE_EXECUTABLE) - MESSAGE("CPackRPM:Debug: LSB_RELEASE = ${LSB_RELEASE_OUTPUT}") -ENDIF(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: LSB_RELEASE = ${LSB_RELEASE_OUTPUT}") +endif(CPACK_RPM_PACKAGE_DEBUG) # We may use RPM version in the future in order # to shut down warning about space in buildtree # some recent RPM version should support space in different places. # not checked [yet]. -IF(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") - MESSAGE(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.") -ENDIF(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") +if(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") + message(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.") +endif(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") # If rpmbuild is found # we try to discover alien since we may be on non RPM distro like Debian. # In this case we may try to to use more advanced features # like generating RPM directly from DEB using alien. # FIXME feature not finished (yet) -FIND_PROGRAM(ALIEN_EXECUTABLE alien) -IF(ALIEN_EXECUTABLE) - MESSAGE(STATUS "alien found, we may be on a Debian based distro.") -ENDIF(ALIEN_EXECUTABLE) +find_program(ALIEN_EXECUTABLE alien) +if(ALIEN_EXECUTABLE) + message(STATUS "alien found, we may be on a Debian based distro.") +endif(ALIEN_EXECUTABLE) # Are we packaging components ? -IF(CPACK_RPM_PACKAGE_COMPONENT) - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "/${CPACK_RPM_PACKAGE_COMPONENT}") - SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${CPACK_RPM_PACKAGE_COMPONENT}") -ELSE(CPACK_RPM_PACKAGE_COMPONENT) - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "") - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "") - SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") -ENDIF(CPACK_RPM_PACKAGE_COMPONENT) +if(CPACK_RPM_PACKAGE_COMPONENT) + set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") + set(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "/${CPACK_RPM_PACKAGE_COMPONENT}") + set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${CPACK_RPM_PACKAGE_COMPONENT}") +else(CPACK_RPM_PACKAGE_COMPONENT) + set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "") + set(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "") + set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") +endif(CPACK_RPM_PACKAGE_COMPONENT) # # Use user-defined RPM specific variables value @@ -329,42 +329,42 @@ ENDIF(CPACK_RPM_PACKAGE_COMPONENT) # # CPACK_RPM_PACKAGE_SUMMARY (mandatory) -IF(NOT CPACK_RPM_PACKAGE_SUMMARY) +if(NOT CPACK_RPM_PACKAGE_SUMMARY) # if neither var is defined lets use the name as summary - IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY) - ELSE(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - SET(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) - ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) -ENDIF(NOT CPACK_RPM_PACKAGE_SUMMARY) + if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) + string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY) + else(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) + set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + endif(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) +endif(NOT CPACK_RPM_PACKAGE_SUMMARY) # CPACK_RPM_PACKAGE_NAME (mandatory) -IF(NOT CPACK_RPM_PACKAGE_NAME) - STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME) -ENDIF(NOT CPACK_RPM_PACKAGE_NAME) +if(NOT CPACK_RPM_PACKAGE_NAME) + string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME) +endif(NOT CPACK_RPM_PACKAGE_NAME) # CPACK_RPM_PACKAGE_VERSION (mandatory) -IF(NOT CPACK_RPM_PACKAGE_VERSION) - IF(NOT CPACK_PACKAGE_VERSION) - MESSAGE(FATAL_ERROR "RPM package requires a package version") - ENDIF(NOT CPACK_PACKAGE_VERSION) - SET(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) -ENDIF(NOT CPACK_RPM_PACKAGE_VERSION) +if(NOT CPACK_RPM_PACKAGE_VERSION) + if(NOT CPACK_PACKAGE_VERSION) + message(FATAL_ERROR "RPM package requires a package version") + endif(NOT CPACK_PACKAGE_VERSION) + set(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) +endif(NOT CPACK_RPM_PACKAGE_VERSION) # Replace '-' in version with '_' # '-' character is an Illegal RPM version character # it is illegal because it is used to separate # RPM "Version" from RPM "Release" -STRING(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION}) +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}") - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) -ELSE(CPACK_RPM_PACKAGE_ARCHITECTURE) - SET(TMP_RPM_BUILDARCH "") -ENDIF(CPACK_RPM_PACKAGE_ARCHITECTURE) +if(CPACK_RPM_PACKAGE_ARCHITECTURE) + set(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}") + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}") + endif(CPACK_RPM_PACKAGE_DEBUG) +else(CPACK_RPM_PACKAGE_ARCHITECTURE) + set(TMP_RPM_BUILDARCH "") +endif(CPACK_RPM_PACKAGE_ARCHITECTURE) # CPACK_RPM_PACKAGE_RELEASE # The RPM release is the numbering of the RPM package ITSELF @@ -374,28 +374,28 @@ ENDIF(CPACK_RPM_PACKAGE_ARCHITECTURE) # without changing the version of the packaged software. # This is the case when the packaging is buggy (not) the software :=) # If not set, 1 is a good candidate -IF(NOT CPACK_RPM_PACKAGE_RELEASE) - SET(CPACK_RPM_PACKAGE_RELEASE 1) -ENDIF(NOT CPACK_RPM_PACKAGE_RELEASE) +if(NOT CPACK_RPM_PACKAGE_RELEASE) + set(CPACK_RPM_PACKAGE_RELEASE 1) +endif(NOT CPACK_RPM_PACKAGE_RELEASE) # CPACK_RPM_PACKAGE_LICENSE -IF(NOT CPACK_RPM_PACKAGE_LICENSE) - SET(CPACK_RPM_PACKAGE_LICENSE "unknown") -ENDIF(NOT CPACK_RPM_PACKAGE_LICENSE) +if(NOT CPACK_RPM_PACKAGE_LICENSE) + set(CPACK_RPM_PACKAGE_LICENSE "unknown") +endif(NOT CPACK_RPM_PACKAGE_LICENSE) # CPACK_RPM_PACKAGE_GROUP -IF(NOT CPACK_RPM_PACKAGE_GROUP) - SET(CPACK_RPM_PACKAGE_GROUP "unknown") -ENDIF(NOT CPACK_RPM_PACKAGE_GROUP) +if(NOT CPACK_RPM_PACKAGE_GROUP) + set(CPACK_RPM_PACKAGE_GROUP "unknown") +endif(NOT CPACK_RPM_PACKAGE_GROUP) # CPACK_RPM_PACKAGE_VENDOR -IF(NOT CPACK_RPM_PACKAGE_VENDOR) - IF(CPACK_PACKAGE_VENDOR) - SET(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}") - ELSE(CPACK_PACKAGE_VENDOR) - SET(CPACK_RPM_PACKAGE_VENDOR "unknown") - ENDIF(CPACK_PACKAGE_VENDOR) -ENDIF(NOT CPACK_RPM_PACKAGE_VENDOR) +if(NOT CPACK_RPM_PACKAGE_VENDOR) + if(CPACK_PACKAGE_VENDOR) + set(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}") + else(CPACK_PACKAGE_VENDOR) + set(CPACK_RPM_PACKAGE_VENDOR "unknown") + endif(CPACK_PACKAGE_VENDOR) +endif(NOT CPACK_RPM_PACKAGE_VENDOR) # CPACK_RPM_PACKAGE_SOURCE # The name of the source tarball in case we generate a source RPM @@ -407,35 +407,35 @@ ENDIF(NOT CPACK_RPM_PACKAGE_VENDOR) # if it is defined # - set to a default value # -IF (NOT CPACK_RPM_PACKAGE_DESCRIPTION) - IF (CPACK_PACKAGE_DESCRIPTION_FILE) - FILE(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION) - ELSE (CPACK_PACKAGE_DESCRIPTION_FILE) - SET(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available") - ENDIF (CPACK_PACKAGE_DESCRIPTION_FILE) -ENDIF (NOT CPACK_RPM_PACKAGE_DESCRIPTION) +if (NOT CPACK_RPM_PACKAGE_DESCRIPTION) + if (CPACK_PACKAGE_DESCRIPTION_FILE) + file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION) + else (CPACK_PACKAGE_DESCRIPTION_FILE) + set(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available") + endif (CPACK_PACKAGE_DESCRIPTION_FILE) +endif (NOT CPACK_RPM_PACKAGE_DESCRIPTION) # CPACK_RPM_COMPRESSION_TYPE # -IF (CPACK_RPM_COMPRESSION_TYPE) - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: User Specified RPM compression type: ${CPACK_RPM_COMPRESSION_TYPE}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) - IF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma") - SET(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio") - ENDIF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma") - IF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz") - SET(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7.xzdio") - ENDIF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz") - IF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2") - SET(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio") - ENDIF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2") - IF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip") - SET(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio") - ENDIF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip") -ELSE(CPACK_RPM_COMPRESSION_TYPE) - SET(CPACK_RPM_COMPRESSION_TYPE_TMP "") -ENDIF(CPACK_RPM_COMPRESSION_TYPE) +if (CPACK_RPM_COMPRESSION_TYPE) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: User Specified RPM compression type: ${CPACK_RPM_COMPRESSION_TYPE}") + endif(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio") + endif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma") + if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7.xzdio") + endif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz") + if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio") + endif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2") + if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio") + endif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip") +else(CPACK_RPM_COMPRESSION_TYPE) + set(CPACK_RPM_COMPRESSION_TYPE_TMP "") +endif(CPACK_RPM_COMPRESSION_TYPE) if(CPACK_PACKAGE_RELOCATABLE) set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE) @@ -453,57 +453,57 @@ endif(CPACK_RPM_PACKAGE_RELOCATABLE) # Check if additional fields for RPM spec header are given # There may be some COMPONENT specific variables as well -FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV) - IF(CPACK_RPM_PACKAGE_DEBUG) +foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV) + if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) + endif(CPACK_RPM_PACKAGE_DEBUG) if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}) - IF(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: using CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) + endif(CPACK_RPM_PACKAGE_DEBUG) set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}}) else() - IF(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER} not defined") message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) + endif(CPACK_RPM_PACKAGE_DEBUG) set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) endif() else() - IF(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) + endif(CPACK_RPM_PACKAGE_DEBUG) set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) endif() - IF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) - STRING(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH) - MATH(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - 1") - STRING(SUBSTRING ${_RPM_SPEC_HEADER} 1 ${_PACKAGE_HEADER_STRLENGTH} _PACKAGE_HEADER_TAIL) - STRING(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) - STRING(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) - SET(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) - SET(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") - ELSE(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) + if(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) + string(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH) + math(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - 1") + string(SUBSTRING ${_RPM_SPEC_HEADER} 1 ${_PACKAGE_HEADER_STRLENGTH} _PACKAGE_HEADER_TAIL) + string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) + string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) + set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") + endif(CPACK_RPM_PACKAGE_DEBUG) + set(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") + else(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) # Do not forget to unset previously set header (from previous component) - UNSET(TMP_RPM_${_RPM_SPEC_HEADER}) - ENDIF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) -ENDFOREACH(_RPM_SPEC_HEADER) + unset(TMP_RPM_${_RPM_SPEC_HEADER}) + endif(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) +endforeach(_RPM_SPEC_HEADER) # CPACK_RPM_SPEC_INSTALL_POST # May be used to define a RPM post intallation script # for example setting it to "/bin/true" may prevent # rpmbuild from stripping binaries. -IF(CPACK_RPM_SPEC_INSTALL_POST) - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: User defined CPACK_RPM_SPEC_INSTALL_POST = ${CPACK_RPM_SPEC_INSTALL_POST}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) - SET(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}") -ENDIF(CPACK_RPM_SPEC_INSTALL_POST) +if(CPACK_RPM_SPEC_INSTALL_POST) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: User defined CPACK_RPM_SPEC_INSTALL_POST = ${CPACK_RPM_SPEC_INSTALL_POST}") + endif(CPACK_RPM_PACKAGE_DEBUG) + set(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}") +endif(CPACK_RPM_SPEC_INSTALL_POST) # CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE) # CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE) @@ -614,30 +614,30 @@ endif(CPACK_RPM_CHANGELOG_FILE) # CPACK_RPM_SPEC_MORE_DEFINE # This is a generated spec rpm file spaceholder -IF(CPACK_RPM_SPEC_MORE_DEFINE) - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: User defined more define spec line specified:\n ${CPACK_RPM_SPEC_MORE_DEFINE}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) -ENDIF(CPACK_RPM_SPEC_MORE_DEFINE) +if(CPACK_RPM_SPEC_MORE_DEFINE) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: User defined more define spec line specified:\n ${CPACK_RPM_SPEC_MORE_DEFINE}") + endif(CPACK_RPM_PACKAGE_DEBUG) +endif(CPACK_RPM_SPEC_MORE_DEFINE) # 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}") +set(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}") +message(STATUS "CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}") # Prepare RPM build tree -FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}) -FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/tmp) -FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/BUILD) -FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/RPMS) -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_OUTPUT_FILE_NAME}") +file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}) +file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/tmp) +file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/BUILD) +file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/RPMS) +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_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 -#STRING(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") -SET(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") +#string(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") +set(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") # if we are creating a relocatable package, omit parent directories of # CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list" @@ -666,7 +666,7 @@ endif() # file name by enclosing it between double quotes (thus the sed) # Then we must authorize any man pages extension (adding * at the end) # because rpmbuild may automatically compress those files -EXECUTE_PROCESS(COMMAND find . -type f -o -type l -o (-type d -a -not ( -name "." ${_RPM_DIRS_TO_OMIT} ) ) +execute_process(COMMAND find . -type f -o -type l -o (-type d -a -not ( -name "." ${_RPM_DIRS_TO_OMIT} ) ) COMMAND sed s:.*/man.*/.*:&*: COMMAND sed s/\\.\\\(.*\\\)/\"\\1\"/ WORKING_DIRECTORY "${WDIR}" @@ -715,9 +715,9 @@ endif() # or CPACK_RPM_INSTALL_FILES, # hence it must be done before these auto-generated lists are processed. if(CPACK_RPM_USER_FILELIST_INTERNAL) - IF(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) + endif(CPACK_RPM_PACKAGE_DEBUG) # Create CMake list from CPACK_RPM_INSTALL_FILES string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) @@ -753,9 +753,9 @@ else() endif() if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) - IF(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) + endif(CPACK_RPM_PACKAGE_DEBUG) # Remove trailing space string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) # Transform endline separated - string into CMake List @@ -774,10 +774,10 @@ if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) foreach(F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "${CPACK_RPM_ABSOLUTE_INSTALL_FILES}%config \"${F}\"\n") endforeach(F) - IF(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: CPACK_RPM_ABSOLUTE_INSTALL_FILES=${CPACK_RPM_ABSOLUTE_INSTALL_FILES}") message("CPackRPM:Debug: CPACK_RPM_INSTALL_FILES=${CPACK_RPM_INSTALL_FILES}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) + endif(CPACK_RPM_PACKAGE_DEBUG) else() # reset vars in order to avoid leakage of value(s) from one component to another set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") @@ -803,28 +803,28 @@ endforeach(F) set(CPACK_RPM_INSTALL_FILES_LIST "") # 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}${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.spec") +set(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.spec") # 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) +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 +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\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@ Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ @@ -898,28 +898,28 @@ ${CPACK_RPM_USER_INSTALL_FILES} # 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) + 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) +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}") + 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) + 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}") + 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) + configure_file(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY) +endif(CPACK_RPM_USER_BINARY_SPECFILE) -IF(RPMBUILD_EXECUTABLE) +if(RPMBUILD_EXECUTABLE) # Now call rpmbuild using the SPECFILE - EXECUTE_PROCESS( + 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}" @@ -928,17 +928,17 @@ IF(RPMBUILD_EXECUTABLE) RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err" OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out") - IF(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT) - FILE(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err RPMBUILDERR) - FILE(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out RPMBUILDOUT) - MESSAGE("CPackRPM:Debug: You may consult rpmbuild logs in: ") - MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err") - MESSAGE("CPackRPM:Debug: *** ${RPMBUILDERR} ***") - MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out") - MESSAGE("CPackRPM:Debug: *** ${RPMBUILDERR} ***") - ENDIF(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT) -ELSE(RPMBUILD_EXECUTABLE) - IF(ALIEN_EXECUTABLE) - MESSAGE(FATAL_ERROR "RPM packaging through alien not done (yet)") - ENDIF(ALIEN_EXECUTABLE) -ENDIF(RPMBUILD_EXECUTABLE) + if(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT) + file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err RPMBUILDERR) + file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out RPMBUILDOUT) + message("CPackRPM:Debug: You may consult rpmbuild logs in: ") + message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err") + message("CPackRPM:Debug: *** ${RPMBUILDERR} ***") + message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out") + message("CPackRPM:Debug: *** ${RPMBUILDERR} ***") + endif(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT) +else(RPMBUILD_EXECUTABLE) + if(ALIEN_EXECUTABLE) + message(FATAL_ERROR "RPM packaging through alien not done (yet)") + endif(ALIEN_EXECUTABLE) +endif(RPMBUILD_EXECUTABLE) |