2009-05-14 23:31:18 +04:00
# - The builtin (binary) CPack RPM generator (Unix only)
# CPackRPM may be used to create RPM package using CPack.
# CPackRPM is a CPack generator thus it uses the CPACK_XXX variables
# used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration
2007-10-13 03:33:41 +04:00
#
2009-05-14 23:31:18 +04:00
# However CPackRPM has specific features which are controlled by
2011-06-12 14:12:24 +04:00
# the specifics CPACK_RPM_XXX variables.
# Usually those vars correspond to RPM spec file entities, one may find
# information about spec files here http://www.rpm.org/wiki/Docs.
# You'll find a detailed usage of CPackRPM on the wiki:
2009-05-14 23:31:18 +04:00
# http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29
# However as a handy reminder here comes the list of specific variables:
2007-10-13 03:33:41 +04:00
#
2010-05-20 17:09:46 +04:00
# CPACK_RPM_PACKAGE_SUMMARY
2009-05-14 23:31:18 +04:00
# Mandatory : YES
2010-05-20 17:09:46 +04:00
# Default : CPACK_PACKAGE_DESCRIPTION_SUMMARY
2009-05-14 23:31:18 +04:00
# The RPM package summary
# CPACK_RPM_PACKAGE_NAME
# Mandatory : YES
# Default : CPACK_PACKAGE_NAME
# The RPM package name
# CPACK_RPM_PACKAGE_VERSION
# Mandatory : YES
# Default : CPACK_PACKAGE_VERSION
# The RPM package version
# CPACK_RPM_PACKAGE_ARCHITECTURE
# Mandatory : NO
# Default : -
2010-05-20 17:09:46 +04:00
# The RPM package architecture. This may be set to "noarch" if you
2009-05-14 23:31:18 +04:00
# know you are building a noarch package.
# CPACK_RPM_PACKAGE_RELEASE
# Mandatory : YES
# Default : 1
2010-05-20 17:09:46 +04:00
# The RPM package release. This is the numbering of the RPM package
# itself, i.e. the version of the packaging and not the version of the
# content (see CPACK_RPM_PACKAGE_VERSION). One may change the default
2009-05-14 23:31:18 +04:00
# value if the previous packaging was buggy and/or you want to put here
# a fancy Linux distro specific numbering.
# CPACK_RPM_PACKAGE_LICENSE
# Mandatory : YES
# Default : "unknown"
# The RPM package license policy.
# CPACK_RPM_PACKAGE_GROUP
# Mandatory : YES
# Default : "unknown"
# The RPM package group.
2010-05-20 17:09:46 +04:00
# CPACK_RPM_PACKAGE_VENDOR
2009-05-14 23:31:18 +04:00
# Mandatory : YES
2009-11-11 23:55:44 +03:00
# Default : CPACK_PACKAGE_VENDOR if set or "unknown"
2010-05-20 17:09:46 +04:00
# The RPM package vendor.
# CPACK_RPM_PACKAGE_URL
# Mandatory : NO
# Default : -
# The projects URL.
2009-05-14 23:31:18 +04:00
# CPACK_RPM_PACKAGE_DESCRIPTION
# Mandatory : YES
# Default : CPACK_PACKAGE_DESCRIPTION_FILE if set or "no package description available"
2010-04-10 13:23:01 +04:00
# CPACK_RPM_COMPRESSION_TYPE
# Mandatory : NO
# Default : -
# May be used to override RPM compression type to be used
# to build the RPM. For example some Linux distribution now default
# to lzma or xz compression whereas older cannot use such RPM.
# Using this one can enforce compression type to be used.
# Possible value are: lzma, xz, bzip2 and gzip.
2009-05-14 23:31:18 +04:00
# CPACK_RPM_PACKAGE_REQUIRES
# Mandatory : NO
# Default : -
2009-11-11 23:27:44 +03:00
# May be used to set RPM dependencies (requires).
2010-05-20 17:09:46 +04:00
# Note that you must enclose the complete requires string between quotes,
2009-11-28 17:57:59 +03:00
# for example:
# set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8")
2011-06-12 14:12:24 +04:00
# The required package list of an RPM file could be printed with
# rpm -qp --requires file.rpm
2010-05-20 17:09:46 +04:00
# CPACK_RPM_PACKAGE_SUGGESTS
# Mandatory : NO
# Default : -
# May be used to set weak RPM dependencies (suggests).
# Note that you must enclose the complete requires string between quotes.
# CPACK_RPM_PACKAGE_PROVIDES
2009-11-11 23:27:44 +03:00
# Mandatory : NO
# Default : -
# May be used to set RPM dependencies (provides).
2011-06-12 14:12:24 +04:00
# The provided package list of an RPM file could be printed with
# rpm -qp --provides file.rpm
2010-05-20 17:09:46 +04:00
# CPACK_RPM_PACKAGE_OBSOLETES
# Mandatory : NO
# Default : -
# May be used to set RPM packages that are obsoleted by this one.
2010-07-09 22:01:57 +04:00
# CPACK_RPM_PACKAGE_RELOCATABLE
# Mandatory : NO
2010-08-23 19:38:33 +04:00
# Default : CPACK_PACKAGE_RELOCATABLE
2010-07-09 22:01:57 +04:00
# If this variable is set to TRUE or ON CPackRPM will try
# to build a relocatable RPM package. A relocatable RPM may
# be installed using rpm --prefix or --relocate in order to
# install it at an alternate place see rpm(8).
2010-08-23 19:38:33 +04:00
# Note that currently this may fail if CPACK_SET_DESTDIR is set to ON.
2010-07-09 22:01:57 +04:00
# If CPACK_SET_DESTDIR is set then you will get a warning message
# but if there is file installed with absolute path you'll get
# unexpected behavior.
2009-05-14 23:31:18 +04:00
# CPACK_RPM_SPEC_INSTALL_POST
# Mandatory : NO
# Default : -
2010-05-20 17:09:46 +04:00
# May be used to set an RPM post-install command inside the spec file.
# For example setting it to "/bin/true" may be used to prevent
2009-05-14 23:31:18 +04:00
# rpmbuild to strip binaries.
# CPACK_RPM_SPEC_MORE_DEFINE
# Mandatory : NO
# Default : -
# May be used to add any %define lines to the generated spec file.
# CPACK_RPM_PACKAGE_DEBUG
# Mandatory : NO
# Default : -
2010-07-02 18:58:00 +04:00
# May be set when invoking cpack in order to trace debug information
2010-05-20 17:09:46 +04:00
# during CPack RPM run. For example you may launch CPack like this
2009-05-14 23:31:18 +04:00
# cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM
2009-11-10 00:17:22 +03:00
# CPACK_RPM_USER_BINARY_SPECFILE
# Mandatory : NO
2010-05-20 17:09:46 +04:00
# Default : -
2009-11-10 00:17:22 +03:00
# 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 : -
2010-05-20 17:09:46 +04:00
# If set CPack will generate a template for USER specified binary
2009-11-10 00:17:22 +03:00
# 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.
2009-11-11 23:55:44 +03:00
# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
# Mandatory : NO
# Default : -
2011-09-20 22:21:01 +04:00
# May be used to embed a pre (un)installation script in the spec file.
2009-11-11 23:55:44 +03:00
# The refered script file(s) will be read and directly
# put after the %pre or %preun section
2011-09-20 22:21:01 +04:00
# If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for
# each component can be overriden with
# CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE and
# CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE
2009-11-11 23:55:44 +03:00
# One may verify which scriptlet has been included with
# rpm -qp --scripts package.rpm
# CPACK_RPM_POST_INSTALL_SCRIPT_FILE
# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
# Mandatory : NO
# Default : -
2011-09-20 22:21:01 +04:00
# May be used to embed a post (un)installation script in the spec file.
2009-11-11 23:55:44 +03:00
# The refered script file(s) will be read and directly
# put after the %post or %postun section
2011-09-20 22:21:01 +04:00
# If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for
# each component can be overriden with
# CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE and
# CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE
2009-11-11 23:55:44 +03:00
# One may verify which scriptlet has been included with
# rpm -qp --scripts package.rpm
2010-05-20 17:09:46 +04:00
# CPACK_RPM_CHANGELOG_FILE
# Mandatory : NO
# Default : -
2011-09-20 22:21:01 +04:00
# May be used to embed a changelog in the spec file.
2010-05-20 17:09:46 +04:00
# The refered file will be read and directly put after the %changelog
# section.
2009-05-14 23:31:18 +04:00
2009-09-28 19:46:51 +04:00
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
2010-08-07 04:48:47 +04:00
# (To distribute this file outside of CMake, substitute the full
2009-09-28 19:46:51 +04:00
# License text for the above reference.)
2009-05-14 23:31:18 +04:00
# Author: Eric Noulard with the help of Alexander Neundorf.
2007-08-17 17:13:15 +04:00
2007-08-08 19:33:42 +04:00
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 )
2007-08-17 17:13:15 +04:00
# rpmbuild is the basic command for building RPM package
2010-05-20 17:09:46 +04:00
# it may be a simple (symbolic) link to rpm command.
2007-08-08 19:33:42 +04:00
FIND_PROGRAM ( RPMBUILD_EXECUTABLE rpmbuild )
2010-05-20 17:09:46 +04:00
# Check version of the rpmbuild tool this would be easier to
2009-05-12 23:13:10 +04:00
# track bugs with users and CPackRPM debug mode.
2010-05-20 17:09:46 +04:00
# We may use RPM version in order to check for available version dependent features
2009-05-12 23:13:10 +04:00
IF ( RPMBUILD_EXECUTABLE )
execute_process ( COMMAND ${ RPMBUILD_EXECUTABLE } --version
O U T P U T _ V A R I A B L E _ T M P _ V E R S I O N
E R R O R _ Q U I E T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
2010-05-20 17:09:46 +04:00
string ( REGEX REPLACE "^.*\ " ""
2009-05-12 23:13:10 +04:00
R P M B U I L D _ E X E C U T A B L E _ V E R S I O N
2010-05-20 17:09:46 +04:00
$ { _ T M P _ V E R S I O N } )
2009-05-12 23:13:10 +04:00
IF ( CPACK_RPM_PACKAGE_DEBUG )
MESSAGE ( "CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>" )
2010-05-20 17:09:46 +04:00
ENDIF ( CPACK_RPM_PACKAGE_DEBUG )
2009-05-12 23:13:10 +04:00
ENDIF ( RPMBUILD_EXECUTABLE )
2007-08-08 19:33:42 +04:00
IF ( NOT RPMBUILD_EXECUTABLE )
MESSAGE ( FATAL_ERROR "RPM package requires rpmbuild executable" )
ENDIF ( NOT RPMBUILD_EXECUTABLE )
2011-03-10 11:48:46 +03:00
# 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 )
find_program ( LSB_RELEASE_EXECUTABLE lsb_release )
if ( LSB_RELEASE_EXECUTABLE )
execute_process ( COMMAND ${ LSB_RELEASE_EXECUTABLE } -a
O U T P U T _ V A R I A B L E _ T M P _ L S B _ R E L E A S E _ O U T P U T
E R R O R _ Q U I E T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
string ( REGEX REPLACE "\n" ", "
L S B _ R E L E A S E _ O U T P U T
$ { _ T M P _ L S B _ R E L E A S E _ O U T P U T } )
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 )
2009-05-12 23:13:10 +04:00
# We may use RPM version in the future in order
2010-05-20 17:09:46 +04:00
# to shut down warning about space in buildtree
2009-05-12 23:13:10 +04:00
# some recent RPM version should support space in different places.
# not checked [yet].
2007-08-30 00:31:46 +04:00
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 ".* .*" )
2010-05-20 17:09:46 +04:00
# If rpmbuild is found
2007-08-17 17:13:15 +04:00
# 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 )
2011-09-20 22:21:01 +04:00
# 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 )
2010-05-20 17:09:46 +04:00
#
2007-08-17 17:13:15 +04:00
# Use user-defined RPM specific variables value
# or generate reasonable default value from
# CPACK_xxx generic values.
# The variables comes from the needed (mandatory or not)
# values found in the RPM specification file aka ".spec" file.
# The variables which may/should be defined are:
#
2007-10-13 03:33:41 +04:00
# CPACK_RPM_PACKAGE_SUMMARY (mandatory)
IF ( NOT CPACK_RPM_PACKAGE_SUMMARY )
2007-08-17 17:13:15 +04:00
# if neither var is defined lets use the name as summary
IF ( NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY )
2007-10-13 03:33:41 +04:00
STRING ( TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY )
2007-08-17 17:13:15 +04:00
ELSE ( NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY )
2010-05-20 17:09:46 +04:00
SET ( CPACK_RPM_PACKAGE_SUMMARY ${ CPACK_PACKAGE_DESCRIPTION_SUMMARY } )
2007-08-17 17:13:15 +04:00
ENDIF ( NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY )
2007-10-13 03:33:41 +04:00
ENDIF ( NOT CPACK_RPM_PACKAGE_SUMMARY )
2010-05-20 17:09:46 +04:00
2007-10-13 03:33:41 +04:00
# 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 )
2007-08-17 17:13:15 +04:00
2007-10-13 03:33:41 +04:00
# CPACK_RPM_PACKAGE_VERSION (mandatory)
IF ( NOT CPACK_RPM_PACKAGE_VERSION )
2007-08-17 17:13:15 +04:00
IF ( NOT CPACK_PACKAGE_VERSION )
MESSAGE ( FATAL_ERROR "RPM package requires a package version" )
ENDIF ( NOT CPACK_PACKAGE_VERSION )
2007-10-13 03:33:41 +04:00
SET ( CPACK_RPM_PACKAGE_VERSION ${ CPACK_PACKAGE_VERSION } )
ENDIF ( NOT CPACK_RPM_PACKAGE_VERSION )
2010-07-04 13:43:33 +04:00
# 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 } )
2007-08-17 17:13:15 +04:00
2007-10-13 03:33:41 +04:00
# CPACK_RPM_PACKAGE_ARCHITECTURE (optional)
2008-09-20 01:45:37 +04:00
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 )
2007-08-17 17:13:15 +04:00
2007-10-13 03:33:41 +04:00
# CPACK_RPM_PACKAGE_RELEASE
2007-08-17 17:13:15 +04:00
# The RPM release is the numbering of the RPM package ITSELF
# this is the version of the PACKAGING and NOT the version
# of the CONTENT of the package.
# You may well need to generate a new RPM package release
# 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
2007-10-13 03:33:41 +04:00
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 )
# 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 )
2007-10-30 17:16:43 +03:00
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 )
2007-10-13 03:33:41 +04:00
ENDIF ( NOT CPACK_RPM_PACKAGE_VENDOR )
# CPACK_RPM_PACKAGE_SOURCE
2008-09-20 01:45:37 +04:00
# The name of the source tarball in case we generate a source RPM
2007-08-17 17:13:15 +04:00
2007-10-13 03:33:41 +04:00
# CPACK_RPM_PACKAGE_DESCRIPTION
2007-11-01 16:52:09 +03:00
# The variable content may be either
2010-07-02 18:58:00 +04:00
# - explicitly given by the user or
2007-11-01 16:52:09 +03:00
# - filled with the content of CPACK_PACKAGE_DESCRIPTION_FILE
# 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 )
2007-08-17 17:13:15 +04:00
2010-04-10 13:23:01 +04:00
# 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 )
2008-12-03 22:37:13 +03:00
2010-08-23 19:38:33 +04:00
if ( CPACK_PACKAGE_RELOCATABLE )
2010-11-13 19:56:36 +03:00
set ( CPACK_RPM_PACKAGE_RELOCATABLE TRUE )
2010-08-23 19:38:33 +04:00
endif ( CPACK_PACKAGE_RELOCATABLE )
2010-07-09 22:01:57 +04:00
if ( CPACK_RPM_PACKAGE_RELOCATABLE )
if ( CPACK_RPM_PACKAGE_DEBUG )
2010-08-23 19:38:33 +04:00
message ( "CPackRPM:Debug: Trying to build a relocatable package" )
2010-07-09 22:01:57 +04:00
endif ( CPACK_RPM_PACKAGE_DEBUG )
2010-08-23 19:38:33 +04:00
if ( CPACK_SET_DESTDIR AND ( NOT CPACK_SET_DESTDIR STREQUAL "I_ON" ) )
message ( "CPackRPM:Warning: CPACK_SET_DESTDIR is set (=${CPACK_SET_DESTDIR}) while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable." )
else ( CPACK_SET_DESTDIR AND ( NOT CPACK_SET_DESTDIR STREQUAL "I_ON" ) )
2010-07-09 22:01:57 +04:00
set ( CPACK_RPM_PACKAGE_PREFIX ${ CPACK_PACKAGING_INSTALL_PREFIX } )
2010-08-23 19:38:33 +04:00
endif ( CPACK_SET_DESTDIR AND ( NOT CPACK_SET_DESTDIR STREQUAL "I_ON" ) )
2010-07-09 22:01:57 +04:00
endif ( CPACK_RPM_PACKAGE_RELOCATABLE )
2010-05-20 17:09:46 +04:00
# check if additional fields for RPM spec header are given
2011-06-12 14:49:44 +04:00
FOREACH ( _RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV )
2010-05-20 17:09:46 +04:00
IF ( CPACK_RPM_PACKAGE_ ${ _RPM_SPEC_HEADER } )
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}}" )
ENDIF ( CPACK_RPM_PACKAGE_DEBUG )
SET ( TMP_RPM_ ${ _RPM_SPEC_HEADER } "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}" )
ENDIF ( CPACK_RPM_PACKAGE_ ${ _RPM_SPEC_HEADER } )
ENDFOREACH ( _RPM_SPEC_HEADER )
2009-11-11 23:27:44 +03:00
2008-09-20 01:45:37 +04:00
# 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 )
2008-12-03 22:37:13 +03:00
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 )
2008-09-20 01:45:37 +04:00
SET ( TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}" )
ENDIF ( CPACK_RPM_SPEC_INSTALL_POST )
2011-09-20 22:21:01 +04:00
# 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)
# May be used to embed a post (un)installation script in the spec file.
2009-11-11 23:55:44 +03:00
# The refered script file(s) will be read and directly
# put after the %post or %postun section
2011-09-20 22:21:01 +04:00
if ( CPACK_RPM_PACKAGE_COMPONENT )
if ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _POST_INSTALL_SCRIPT_FILE )
set ( CPACK_RPM_POST_INSTALL_READ_FILE ${ CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT } _POST_INSTALL_SCRIPT_FILE} )
else ( )
set ( CPACK_RPM_POST_INSTALL_READ_FILE ${ CPACK_RPM_POST_INSTALL_SCRIPT_FILE } )
endif ( )
if ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _POST_UNINSTALL_SCRIPT_FILE )
set ( CPACK_RPM_POST_UNINSTALL_READ_FILE ${ CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT } _POST_UNINSTALL_SCRIPT_FILE} )
else ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _POST_UNINSTALL_SCRIPT_FILE )
set ( CPACK_RPM_POST_UNINSTALL_READ_FILE ${ CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE } )
endif ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _POST_UNINSTALL_SCRIPT_FILE )
else ( CPACK_RPM_PACKAGE_COMPONENT )
set ( CPACK_RPM_POST_INSTALL_READ_FILE ${ CPACK_RPM_POST_INSTALL_SCRIPT_FILE } )
set ( CPACK_RPM_POST_UNINSTALL_READ_FILE ${ CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE } )
endif ( CPACK_RPM_PACKAGE_COMPONENT )
if ( CPACK_RPM_POST_INSTALL_READ_FILE )
if ( EXISTS ${ CPACK_RPM_POST_INSTALL_READ_FILE } )
file ( READ ${ CPACK_RPM_POST_INSTALL_READ_FILE } CPACK_RPM_SPEC_POSTINSTALL )
else ( EXISTS ${ CPACK_RPM_POST_INSTALL_READ_FILE } )
message ( "CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_READ_FILE}> does not exists - ignoring" )
endif ( EXISTS ${ CPACK_RPM_POST_INSTALL_READ_FILE } )
endif ( CPACK_RPM_POST_INSTALL_READ_FILE )
if ( CPACK_RPM_POST_UNINSTALL_READ_FILE )
if ( EXISTS ${ CPACK_RPM_POST_UNINSTALL_READ_FILE } )
file ( READ ${ CPACK_RPM_POST_UNINSTALL_READ_FILE } CPACK_RPM_SPEC_POSTUNINSTALL )
else ( EXISTS ${ CPACK_RPM_POST_UNINSTALL_READ_FILE } )
message ( "CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_READ_FILE}> does not exists - ignoring" )
endif ( EXISTS ${ CPACK_RPM_POST_UNINSTALL_READ_FILE } )
endif ( CPACK_RPM_POST_UNINSTALL_READ_FILE )
# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE)
# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE)
2010-05-20 17:09:46 +04:00
# May be used to embed a pre (un)installation script in the spec file.
2009-11-11 23:55:44 +03:00
# The refered script file(s) will be read and directly
# put after the %pre or %preun section
2011-09-20 22:21:01 +04:00
if ( CPACK_RPM_PACKAGE_COMPONENT )
if ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _PRE_INSTALL_SCRIPT_FILE )
set ( CPACK_RPM_PRE_INSTALL_READ_FILE ${ CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT } _PRE_INSTALL_SCRIPT_FILE} )
else ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _PRE_INSTALL_SCRIPT_FILE )
set ( CPACK_RPM_PRE_INSTALL_READ_FILE ${ CPACK_RPM_PRE_INSTALL_SCRIPT_FILE } )
endif ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _PRE_INSTALL_SCRIPT_FILE )
if ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _PRE_UNINSTALL_SCRIPT_FILE )
set ( CPACK_RPM_PRE_UNINSTALL_READ_FILE ${ CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT } _PRE_UNINSTALL_SCRIPT_FILE} )
else ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _PRE_UNINSTALL_SCRIPT_FILE )
set ( CPACK_RPM_PRE_UNINSTALL_READ_FILE ${ CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE } )
endif ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _PRE_UNINSTALL_SCRIPT_FILE )
else ( CPACK_RPM_PACKAGE_COMPONENT )
set ( CPACK_RPM_PRE_INSTALL_READ_FILE ${ CPACK_RPM_PRE_INSTALL_SCRIPT_FILE } )
set ( CPACK_RPM_PRE_UNINSTALL_READ_FILE ${ CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE } )
endif ( CPACK_RPM_PACKAGE_COMPONENT )
if ( CPACK_RPM_PRE_INSTALL_READ_FILE )
if ( EXISTS ${ CPACK_RPM_PRE_INSTALL_READ_FILE } )
file ( READ ${ CPACK_RPM_PRE_INSTALL_READ_FILE } CPACK_RPM_SPEC_PREINSTALL )
else ( EXISTS ${ CPACK_RPM_PRE_INSTALL_READ_FILE } )
message ( "CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_READ_FILE}> does not exists - ignoring" )
endif ( EXISTS ${ CPACK_RPM_PRE_INSTALL_READ_FILE } )
endif ( CPACK_RPM_PRE_INSTALL_READ_FILE )
if ( CPACK_RPM_PRE_UNINSTALL_READ_FILE )
if ( EXISTS ${ CPACK_RPM_PRE_UNINSTALL_READ_FILE } )
file ( READ ${ CPACK_RPM_PRE_UNINSTALL_READ_FILE } CPACK_RPM_SPEC_PREUNINSTALL )
else ( EXISTS ${ CPACK_RPM_PRE_UNINSTALL_READ_FILE } )
message ( "CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_READ_FILE}> does not exists - ignoring" )
endif ( EXISTS ${ CPACK_RPM_PRE_UNINSTALL_READ_FILE } )
endif ( CPACK_RPM_PRE_UNINSTALL_READ_FILE )
2009-11-11 23:55:44 +03:00
2010-05-20 17:09:46 +04:00
# CPACK_RPM_CHANGELOG_FILE
# May be used to embed a changelog in the spec file.
# The refered file will be read and directly put after the %changelog section
if ( CPACK_RPM_CHANGELOG_FILE )
if ( EXISTS ${ CPACK_RPM_CHANGELOG_FILE } )
file ( READ ${ CPACK_RPM_CHANGELOG_FILE } CPACK_RPM_SPEC_CHANGELOG )
else ( EXISTS ${ CPACK_RPM_CHANGELOG_FILE } )
message ( SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring" )
endif ( EXISTS ${ CPACK_RPM_CHANGELOG_FILE } )
2010-07-04 14:27:47 +04:00
else ( CPACK_RPM_CHANGELOG_FILE )
set ( CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Erk <eric.noulard@gmail.com>\n Generated by CPack RPM (no Changelog file were provided)" )
2010-05-20 17:09:46 +04:00
endif ( CPACK_RPM_CHANGELOG_FILE )
2008-09-20 01:45:37 +04:00
# 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 )
2007-08-17 17:13:15 +04:00
# Now we may create the RPM build tree structure
2007-10-13 03:33:41 +04:00
SET ( CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}" )
2008-09-20 01:45:37 +04:00
MESSAGE ( STATUS "CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}" )
2007-08-17 17:13:15 +04:00
# Prepare RPM build tree
2007-10-13 03:33:41 +04:00
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}" )
2007-08-17 17:13:15 +04:00
# it seems rpmbuild can't handle spaces in the path
# neither escaping (as below) nor putting quotes around the path seem to help
2007-10-13 03:33:41 +04:00
#STRING(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
SET ( CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}" )
2007-08-17 17:13:15 +04:00
2009-11-09 22:06:36 +03:00
# Use files tree to construct files command (spec file)
2009-11-22 20:52:47 +03:00
# We should not forget to include symlinks (thus -o -type l)
2011-09-06 00:15:31 +04:00
# We should include directory as well (thus -type d)
# but not the main local dir "." (thus -a -not -name ".")
2010-07-04 16:05:25 +04:00
# We must remove the './' due to the local search and escape the
# file name by enclosing it between double quotes (thus the sed)
2009-11-28 17:57:59 +03:00
# Then we must authorize any man pages extension (adding * at the end)
# because rpmbuild may automatically compress those files
2011-09-06 00:15:31 +04:00
EXECUTE_PROCESS ( COMMAND find . -type f -o -type l -o ( -type d -a -not -name "." )
2011-05-21 14:34:37 +04:00
C O M M A N D s e d s : . * / m a n . * / . * : & * :
C O M M A N D s e d s / \ \ . \ \ \ ( . * \ \ \ ) / \ " \ \ 1 \ " /
2010-11-13 19:56:36 +03:00
W O R K I N G _ D I R E C T O R Y " $ { W D I R } "
O U T P U T _ V A R I A B L E C P A C K _ R P M _ I N S T A L L _ F I L E S )
2009-11-28 17:57:59 +03:00
2011-04-17 19:12:38 +04:00
# In component case, replace CPACK_ABSOLUTE_DESTINATION_FILES
# with the content of CPACK_ABSOLUTE_DESTINATION_FILES_<COMPONENT>
# This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES handling
if ( CPACK_RPM_PACKAGE_COMPONENT )
if ( CPACK_ABSOLUTE_DESTINATION_FILES )
set ( COMPONENT_FILES_TAG "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}" )
set ( CPACK_ABSOLUTE_DESTINATION_FILES "${${COMPONENT_FILES_TAG}}" )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Handling Absolute Destination Files ${CPACK_ABSOLUTE_DESTINATION_FILES}" )
message ( "CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}" )
endif ( CPACK_RPM_PACKAGE_DEBUG )
endif ( )
endif ( )
2010-08-23 19:38:33 +04:00
if ( CPACK_ABSOLUTE_DESTINATION_FILES )
IF ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES}" )
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
string ( REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}" )
# Remove unecessary quotes
string ( REPLACE "\" " " " CPACK_RPM_INSTALL_FILES_LIST " ${ CPACK_RPM_INSTALL_FILES_LIST } " )
# Remove ABSOLUTE install file from INSTALL FILE LIST
list ( REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${ CPACK_ABSOLUTE_DESTINATION_FILES } )
# Rebuild INSTALL_FILES
set ( CPACK_RPM_INSTALL_FILES "" )
foreach ( F IN LISTS CPACK_RPM_INSTALL_FILES_LIST )
set ( CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}\" ${ F } \"\n")
endforeach ( F )
# Build ABSOLUTE_INSTALL_FILES
set ( CPACK_RPM_ABSOLUTE_INSTALL_FILES "" )
foreach ( F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES )
set ( CPACK_RPM_ABSOLUTE_INSTALL_FILES "${CPACK_RPM_ABSOLUTE_INSTALL_FILES}%config \" ${ F } \"\n")
endforeach ( F )
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_ABSOLUTE_DESTINATION_FILES )
2009-11-10 00:17:22 +03:00
# The name of the final spec file to be used by rpmbuild
2010-11-13 19:56:36 +03:00
SET ( CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.spec" )
2010-05-20 17:09:46 +04:00
2009-11-10 00:17:22 +03:00
# 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 )
2010-05-20 17:09:46 +04:00
2009-11-10 00:17:22 +03:00
# 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 -*-
2010-11-13 19:56:36 +03:00
B u i l d R o o t : \ @ C P A C K _ R P M _ D I R E C T O R Y \ @ / \ @ C P A C K _ P A C K A G E _ F I L E _ N A M E \ @ \ @ C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ P A R T _ P A T H \ @
2009-11-10 00:17:22 +03:00
S u m m a r y : \ @ C P A C K _ R P M _ P A C K A G E _ S U M M A R Y \ @
2011-09-05 22:22:00 +04:00
N a m e : \ @ C P A C K _ R P M _ P A C K A G E _ N A M E \ @ \ @ C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ P A R T _ N A M E \ @
2009-11-10 00:17:22 +03:00
V e r s i o n : \ @ C P A C K _ R P M _ P A C K A G E _ V E R S I O N \ @
R e l e a s e : \ @ C P A C K _ R P M _ P A C K A G E _ R E L E A S E \ @
L i c e n s e : \ @ C P A C K _ R P M _ P A C K A G E _ L I C E N S E \ @
G r o u p : \ @ C P A C K _ R P M _ P A C K A G E _ G R O U P \ @
V e n d o r : \ @ C P A C K _ R P M _ P A C K A G E _ V E N D O R \ @
2010-05-20 17:09:46 +04:00
\ @ T M P _ R P M _ U R L \ @
2009-11-10 00:17:22 +03:00
\ @ T M P _ R P M _ R E Q U I R E S \ @
2009-11-11 23:27:44 +03:00
\ @ T M P _ R P M _ P R O V I D E S \ @
2010-05-20 17:09:46 +04:00
\ @ T M P _ R P M _ O B S O L E T E S \ @
2011-06-12 14:49:44 +04:00
\ @ T M P _ R P M _ C O N F L I C T S \ @
\ @ T M P _ R P M _ A U T O P R O V \ @
\ @ T M P _ R P M _ A U T O R E Q \ @
\ @ T M P _ R P M _ A U T O R E Q P R O V \ @
2009-11-10 00:17:22 +03:00
\ @ T M P _ R P M _ B U I L D A R C H \ @
2010-07-09 22:01:57 +04:00
\ @ T M P _ R P M _ P R E F I X \ @
2010-05-20 17:09:46 +04:00
2009-11-10 00:17:22 +03:00
% d e f i n e _ r p m d i r \ @ C P A C K _ R P M _ D I R E C T O R Y \ @
% d e f i n e _ r p m f i l e n a m e \ @ C P A C K _ R P M _ F I L E _ N A M E \ @
2007-08-17 17:13:15 +04:00
% d e f i n e _ u n p a c k a g e d _ f i l e s _ t e r m i n a t e _ b u i l d 0
2009-11-10 00:17:22 +03:00
% d e f i n e _ t o p d i r \ @ C P A C K _ R P M _ D I R E C T O R Y \ @
\ @ T M P _ R P M _ S P E C _ I N S T A L L _ P O S T \ @
\ @ C P A C K _ R P M _ S P E C _ M O R E _ D E F I N E \ @
2010-04-10 13:23:01 +04:00
\ @ C P A C K _ R P M _ C O M P R E S S I O N _ T Y P E _ T M P \ @
2010-05-20 17:09:46 +04:00
2007-08-17 17:13:15 +04:00
% d e s c r i p t i o n
2009-11-10 00:17:22 +03:00
\ @ C P A C K _ R P M _ P A C K A G E _ D E S C R I P T I O N \ @
2007-08-17 17:13:15 +04:00
2009-11-15 21:55:42 +03:00
# This is a shortcutted spec file generated by CMake RPM generator
# we skip _install step because CPack does that for us.
# We do only save CPack installed tree in _prepr
# and then restore it in build.
% p r e p
2010-10-04 01:29:34 +04:00
m v $ R P M _ B U I L D _ R O O T \ " \ @ C P A C K _ T O P L E V E L _ D I R E C T O R Y \ @ / t m p B B r o o t \ "
2009-11-15 21:55:42 +03:00
2009-11-28 17:57:59 +03:00
#p build
2010-05-20 17:09:46 +04:00
2009-11-28 17:57:59 +03:00
% i n s t a l l
i f [ - e $ R P M _ B U I L D _ R O O T ] ;
t h e n
2010-12-13 22:11:06 +03:00
r m - r f $ R P M _ B U I L D _ R O O T
2010-05-20 17:09:46 +04:00
f i
2010-12-13 22:11:06 +03:00
m v \ " \ @ C P A C K _ T O P L E V E L _ D I R E C T O R Y \ @ / t m p B B r o o t \ " $ R P M _ B U I L D _ R O O T
2007-08-17 17:13:15 +04:00
% c l e a n
2009-11-11 23:55:44 +03:00
% p o s t
\ @ C P A C K _ R P M _ S P E C _ P O S T I N S T A L L \ @
% p o s t u n
\ @ C P A C K _ R P M _ S P E C _ P O S T U N I N S T A L L \ @
% p r e
\ @ C P A C K _ R P M _ S P E C _ P R E I N S T A L L \ @
% p r e u n
\ @ C P A C K _ R P M _ S P E C _ P R E U N I N S T A L L \ @
2007-08-17 17:13:15 +04:00
% f i l e s
% defattr ( -,root,root,- )
2009-11-09 22:06:36 +03:00
$ { C P A C K _ R P M _ I N S T A L L _ F I L E S }
2010-08-23 19:38:33 +04:00
$ { C P A C K _ R P M _ A B S O L U T E _ I N S T A L L _ F I L E S }
2007-08-17 17:13:15 +04:00
% c h a n g e l o g
2010-05-20 17:09:46 +04:00
\ @ C P A C K _ R P M _ S P E C _ C H A N G E L O G \ @
2007-08-17 17:13:15 +04:00
" )
2009-11-10 00:17:22 +03:00
# 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
2010-05-20 17:09:46 +04:00
# to customize their own spec file.
2009-11-10 00:17:22 +03:00
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
2010-05-20 17:09:46 +04:00
# or generate one using appropriate variables value.
2009-11-10 00:17:22 +03:00
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 )
2010-05-20 17:09:46 +04:00
# 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
2009-11-10 00:17:22 +03:00
CONFIGURE_FILE ( ${ CPACK_RPM_BINARY_SPECFILE } .in ${ CPACK_RPM_BINARY_SPECFILE } @ONLY )
2007-10-13 03:33:41 +04:00
ENDIF ( CPACK_RPM_USER_BINARY_SPECFILE )
2007-08-17 17:13:15 +04:00
IF ( RPMBUILD_EXECUTABLE )
# Now call rpmbuild using the SPECFILE
EXECUTE_PROCESS (
2010-05-20 17:09:46 +04:00
C O M M A N D " $ { R P M B U I L D _ E X E C U T A B L E } " - b b
2010-11-13 19:56:36 +03:00
- - b u i l d r o o t " $ { C P A C K _ R P M _ D I R E C T O R Y } / $ { C P A C K _ P A C K A G E _ F I L E _ N A M E } $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ P A R T _ P A T H } "
2009-05-12 23:13:10 +04:00
" $ { C P A C K _ R P M _ B I N A R Y _ S P E C F I L E } "
2010-11-13 19:56:36 +03:00
W O R K I N G _ D I R E C T O R Y " $ { C P A C K _ T O P L E V E L _ D I R E C T O R Y } / $ { C P A C K _ P A C K A G E _ F I L E _ N A M E } $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ P A R T _ P A T H } "
2011-03-10 20:20:16 +03:00
R E S U L T _ V A R I A B L E C P A C K _ R P M B U I L D _ E X E C _ R E S U L T
2010-11-13 19:56:36 +03:00
E R R O R _ F I L E " $ { C P A C K _ T O P L E V E L _ D I R E C T O R Y } / r p m b u i l d $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ P A R T _ N A M E } . e r r "
O U T P U T _ F I L E " $ { C P A C K _ T O P L E V E L _ D I R E C T O R Y } / r p m b u i l d $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ P A R T _ N A M E } . o u t " )
2011-03-10 20:20:16 +03:00
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 )
2008-09-20 01:45:37 +04:00
MESSAGE ( "CPackRPM:Debug: You may consult rpmbuild logs in: " )
2010-11-13 19:56:36 +03:00
MESSAGE ( "CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err" )
2011-03-10 20:20:16 +03:00
MESSAGE ( "CPackRPM:Debug: *** ${RPMBUILDERR} ***" )
2010-11-13 19:56:36 +03:00
MESSAGE ( "CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out" )
2011-03-10 20:20:16 +03:00
MESSAGE ( "CPackRPM:Debug: *** ${RPMBUILDERR} ***" )
2011-03-10 20:32:47 +03:00
ENDIF ( CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT )
2007-08-17 17:13:15 +04:00
ELSE ( RPMBUILD_EXECUTABLE )
IF ( ALIEN_EXECUTABLE )
MESSAGE ( FATAL_ERROR "RPM packaging through alien not done (yet)" )
ENDIF ( ALIEN_EXECUTABLE )
ENDIF ( RPMBUILD_EXECUTABLE )