2013-10-15 19:17:36 +04:00
#.rst:
# CPackRPM
# --------
#
# The builtin (binary) CPack RPM generator (Unix only)
#
2013-10-15 21:23:23 +04:00
# Variables specific to CPack RPM generator
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
2013-10-15 19:17:36 +04:00
# 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
#
# However CPackRPM has specific features which are controlled by the
# specifics CPACK_RPM_XXX variables. CPackRPM is a component aware
2011-10-30 23:13:20 +04:00
# generator so when CPACK_RPM_COMPONENT_INSTALL is ON some more
2013-10-15 19:17:36 +04:00
# CPACK_RPM_<ComponentName>_XXXX variables may be used in order to have
# component specific values. Note however that <componentName> refers
# to the **grouping name**. This may be either a component name or a
# component GROUP name. 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:
#
# ::
#
# http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29
#
2009-05-14 23:31:18 +04:00
# However as a handy reminder here comes the list of specific variables:
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_SUMMARY
2014-10-14 09:57:11 +04:00
# CPACK_RPM_<component>_PACKAGE_SUMMARY
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# The RPM package summary.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : YES
# * Default : CPACK_PACKAGE_DESCRIPTION_SUMMARY
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_NAME
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# The RPM package name.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : YES
# * Default : CPACK_PACKAGE_NAME
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_VERSION
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# The RPM package version.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : YES
# * Default : CPACK_PACKAGE_VERSION
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_ARCHITECTURE
2015-02-19 11:01:15 +03:00
# CPACK_RPM_<component>_PACKAGE_ARCHITECTURE
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# The RPM package architecture.
2013-10-15 19:17:36 +04:00
#
2015-02-19 11:01:14 +03:00
# * Mandatory : YES
# * Default : Native architecture output by "uname -m"
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# This may be set to "noarch" if you know you are building a noarch package.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_RELEASE
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# The RPM package release.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : YES
# * Default : 1
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# 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 value if the
# previous packaging was buggy and/or you want to put here a fancy Linux
# distro specific numbering.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_LICENSE
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# The RPM package license policy.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : YES
# * Default : "unknown"
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_GROUP
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# The RPM package group.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : YES
# * Default : "unknown"
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_VENDOR
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# The RPM package vendor.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : YES
# * Default : CPACK_PACKAGE_VENDOR if set or "unknown"
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_URL
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# The projects URL.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_DESCRIPTION
2014-10-14 09:57:11 +04:00
# CPACK_RPM_<component>_PACKAGE_DESCRIPTION
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# RPM package description.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : YES
2014-10-14 09:57:11 +04:00
# * Default : CPACK_COMPONENT_<compName>_DESCRIPTION (component based installers
# only) if set, CPACK_PACKAGE_DESCRIPTION_FILE if set or "no package
2013-10-15 21:23:23 +04:00
# description available"
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_COMPRESSION_TYPE
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# RPM compression type.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# 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.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# RPM spec requires field.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# May be used to set RPM dependencies (requires). Note that you must enclose
# the complete requires string between quotes, for example::
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8")
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# The required package list of an RPM file could be printed with::
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# rpm -qp --requires file.rpm
2013-10-15 19:17:36 +04:00
#
2014-10-08 21:39:19 +04:00
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE
#
# RPM spec requires(pre) field.
#
# * Mandatory : NO
# * Default : -
#
# May be used to set RPM preinstall dependencies (requires(pre)). Note that you must enclose
# the complete requires string between quotes, for example::
#
# set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
#
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST
#
# RPM spec requires(post) field.
#
# * Mandatory : NO
# * Default : -
#
# May be used to set RPM postinstall dependencies (requires(post)). Note that you must enclose
# the complete requires string between quotes, for example::
#
# set(CPACK_RPM_PACKAGE_REQUIRES_POST "shadow-utils, initscripts")
#
#
2014-10-09 21:29:18 +04:00
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN
#
# RPM spec requires(postun) field.
#
# * Mandatory : NO
# * Default : -
#
# May be used to set RPM postuninstall dependencies (requires(postun)). Note that you must enclose
# the complete requires string between quotes, for example::
#
# set(CPACK_RPM_PACKAGE_REQUIRES_POSTUN "shadow-utils, initscripts")
#
#
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN
#
# RPM spec requires(preun) field.
#
# * Mandatory : NO
# * Default : -
#
# May be used to set RPM preuninstall dependencies (requires(preun)). Note that you must enclose
# the complete requires string between quotes, for example::
#
# set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts")
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_SUGGESTS
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# RPM spec suggest field.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# May be used to set weak RPM dependencies (suggests). Note that you must
# enclose the complete requires string between quotes.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_PROVIDES
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# RPM spec provides field.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# May be used to set RPM dependencies (provides). The provided package list
# of an RPM file could be printed with::
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# rpm -qp --provides file.rpm
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_OBSOLETES
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# RPM spec obsoletes field.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# May be used to set RPM packages that are obsoleted by this one.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_RELOCATABLE
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# build a relocatable RPM.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : CPACK_PACKAGE_RELOCATABLE
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +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::
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# rpm --prefix or --relocate
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# in order to install it at an alternate place see rpm(8). Note that
# currently this may fail if CPACK_SET_DESTDIR is set to ON. 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.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_SPEC_INSTALL_POST
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
# * Deprecated: YES
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# This way of specifying post-install script is deprecated, use
# CPACK_RPM_POST_INSTALL_SCRIPT_FILE.
# 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
# rpmbuild to strip binaries.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_SPEC_MORE_DEFINE
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# RPM extended spec definitions lines.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# May be used to add any %define lines to the generated spec file.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_DEBUG
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# Toggle CPackRPM debug output.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# May be set when invoking cpack in order to trace debug information
# during CPack RPM run. For example you may launch CPack like this::
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_USER_BINARY_SPECFILE
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# A user provided spec file.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04: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).
# One can provide a component specific file by setting
# CPACK_RPM_<componentName>_USER_BINARY_SPECFILE.
#
# .. variable:: CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
#
# Spec file 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.
#
# .. variable:: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
#
# * Mandatory : NO
# * Default : -
#
# May be used to embed a pre (un)installation script in the spec file.
# The refered script file(s) will be read and directly
# put after the %pre or %preun section
# If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for
# each component can be overridden with
# CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE and
# CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE.
# One may verify which scriptlet has been included with::
#
# rpm -qp --scripts package.rpm
#
# .. variable:: CPACK_RPM_POST_INSTALL_SCRIPT_FILE
# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
#
# * Mandatory : NO
# * Default : -
#
# May be used to embed a post (un)installation script in the spec file.
# The refered script file(s) will be read and directly
# put after the %post or %postun section.
# If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for
# each component can be overridden with
# CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE and
# CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE.
# One may verify which scriptlet has been included with::
#
# rpm -qp --scripts package.rpm
#
# .. variable:: CPACK_RPM_USER_FILELIST
# CPACK_RPM_<COMPONENT>_USER_FILELIST
#
# * Mandatory : NO
# * Default : -
#
# May be used to explicitly specify %(<directive>) file line
# in the spec file. Like %config(noreplace) or any other directive
# that be found in the %files section. Since CPackRPM is generating
# the list of files (and directories) the user specified files of
# the CPACK_RPM_<COMPONENT>_USER_FILELIST list will be removed from
# the generated list.
#
# .. variable:: CPACK_RPM_CHANGELOG_FILE
#
# RPM changelog file.
#
# * Mandatory : NO
# * Default : -
#
# May be used to embed a changelog in the spec file.
# The refered file will be read and directly put after the %changelog
# section.
#
# .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST
#
# list of path to be excluded.
#
# * Mandatory : NO
# * Default : /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/include
#
# May be used to exclude path (directories or files) from the auto-generated
# list of paths discovered by CPack RPM. The defaut value contains a
# reasonable set of values if the variable is not defined by the user. If the
# variable is defined by the user then CPackRPM will NOT any of the default
# path. If you want to add some path to the default list then you can use
# CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION variable.
#
# .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
#
# additional list of path to be excluded.
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# May be used to add more exclude path (directories or files) from the initial
# default list of excluded paths. See CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST.
2015-01-21 02:29:46 +03:00
#
# .. variable:: CPACK_RPM_RELOCATION_PATHS
#
# * Mandatory : NO
# * Default : -
#
# May be used to specify more than one relocation path per relocatable RPM.
# Variable contains a list of relocation paths that if relative are prefixed
# by the value of CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX or by the value of
# CPACK_PACKAGING_INSTALL_PREFIX if the component version is not provided.
# Variable is not component based as its content can be used to set a different
# path prefix for e.g. binary dir and documentation dir at the same time.
# Only prefixes that are required by a certain component are added to that
# component - component must contain at least one file/directory/symbolic link
# with CPACK_RPM_RELOCATION_PATHS prefix for a certain relocation path
# to be added. Package will not contain any relocation paths if there are no
# files/directories/symbolic links on any of the provided prefix locations.
# Packages that either do not contain any relocation paths or contain
# files/directories/symbolic links that are outside relocation paths print
# out an AUTHOR_WARNING that RPM will be partially relocatable.
#
# .. variable:: CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
#
# * Mandatory : NO
# * Default : CPACK_PACKAGING_INSTALL_PREFIX
#
# May be used to set per component CPACK_PACKAGING_INSTALL_PREFIX for
# relocatable RPM packages.
2015-03-20 23:52:49 +03:00
#
# .. variable:: CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION
# CPACK_RPM_NO_<COMPONENT>_INSTALL_PREFIX_RELOCATION
#
# * Mandatory : NO
# * Default : CPACK_PACKAGING_INSTALL_PREFIX or CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
# are treated as one of relocation paths
#
# May be used to remove CPACK_PACKAGING_INSTALL_PREFIX and CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
# from relocatable RPM prefix paths.
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
2015-01-21 02:29:46 +03:00
function ( cpack_rpm_prepare_relocation_paths )
# set appropriate prefix, remove possible trailing slash and convert backslashes to slashes
if ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _PACKAGE_PREFIX )
file ( TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX}" PATH_PREFIX )
else ( )
file ( TO_CMAKE_PATH "${CPACK_PACKAGING_INSTALL_PREFIX}" PATH_PREFIX )
endif ( )
set ( RPM_RELOCATION_PATHS "${CPACK_RPM_RELOCATION_PATHS}" )
list ( REMOVE_DUPLICATES RPM_RELOCATION_PATHS )
# set base path prefix
if ( EXISTS "${WDIR}/${PATH_PREFIX}" )
2015-03-20 23:52:49 +03:00
if ( NOT CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION AND
N O T C P A C K _ R P M _ N O _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T } _ I N S T A L L _ P R E F I X _ R E L O C A T I O N )
set ( TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}Prefix: ${PATH_PREFIX}\n" )
list ( APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}" )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: removing '${PATH_PREFIX}' from relocation paths" )
endif ( )
endif ( )
2015-01-21 02:29:46 +03:00
endif ( )
# set other path prefixes
foreach ( RELOCATION_PATH ${ RPM_RELOCATION_PATHS } )
2015-02-08 22:03:53 +03:00
if ( IS_ABSOLUTE "${RELOCATION_PATH}" )
2015-01-21 02:29:46 +03:00
set ( PREPARED_RELOCATION_PATH "${RELOCATION_PATH}" )
else ( )
set ( PREPARED_RELOCATION_PATH "${PATH_PREFIX}/${RELOCATION_PATH}" )
endif ( )
if ( EXISTS "${WDIR}/${PREPARED_RELOCATION_PATH}" )
set ( TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}Prefix: ${PREPARED_RELOCATION_PATH}\n" )
list ( APPEND RPM_USED_PACKAGE_PREFIXES "${PREPARED_RELOCATION_PATH}" )
endif ( )
endforeach ( )
# warn about all the paths that are not relocatable
2015-02-11 01:03:06 +03:00
cmake_policy ( PUSH )
# Tell file(GLOB_RECURSE) not to follow directory symlinks
# even if the project does not set this policy to NEW.
cmake_policy ( SET CMP0009 NEW )
file ( GLOB_RECURSE FILE_PATHS_ "${WDIR}/*" )
cmake_policy ( POP )
2015-01-21 02:29:46 +03:00
foreach ( TMP_PATH ${ FILE_PATHS_ } )
string ( LENGTH "${WDIR}" WDIR_LEN )
string ( SUBSTRING "${TMP_PATH}" ${ WDIR_LEN } -1 TMP_PATH )
unset ( TMP_PATH_FOUND_ )
foreach ( RELOCATION_PATH ${ RPM_USED_PACKAGE_PREFIXES } )
file ( RELATIVE_PATH REL_PATH_ "${RELOCATION_PATH}" "${TMP_PATH}" )
string ( SUBSTRING "${REL_PATH_}" 0 2 PREFIX_ )
if ( NOT "${PREFIX_}" STREQUAL ".." )
set ( TPM_PATH_FOUND_ TRUE )
break ( )
endif ( )
endforeach ( )
if ( NOT TPM_PATH_FOUND_ )
message ( AUTHOR_WARNING "CPackRPM:Warning: Path ${TMP_PATH} is not on one of the relocatable paths! Package will be partially relocatable." )
endif ( )
endforeach ( )
2015-02-27 02:33:48 +03:00
set ( RPM_USED_PACKAGE_PREFIXES "${RPM_USED_PACKAGE_PREFIXES}" PARENT_SCOPE )
2015-01-21 02:29:46 +03:00
set ( TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}" PARENT_SCOPE )
endfunction ( )
2012-08-13 21:47:32 +04:00
if ( CMAKE_BINARY_DIR )
message ( FATAL_ERROR "CPackRPM.cmake may only be used by CPack internally." )
2012-08-13 21:50:14 +04:00
endif ( )
2007-08-08 19:33:42 +04:00
2012-08-13 21:47:32 +04:00
if ( NOT UNIX )
message ( FATAL_ERROR "CPackRPM.cmake may only be used under UNIX." )
2012-08-13 21:50:14 +04:00
endif ( )
2007-08-08 19:33:42 +04:00
2015-03-17 00:17:17 +03:00
function ( cpack_rpm_generate_package )
# rpmbuild is the basic command for building RPM package
# it may be a simple (symbolic) link to rpm command.
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 )
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
2011-03-10 11:48:46 +03:00
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 )
2015-03-17 00:17:17 +03:00
string ( REGEX REPLACE "^.* " ""
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
$ { _ T M P _ V E R S I O N } )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>" )
endif ( )
2012-08-13 21:50:14 +04:00
endif ( )
2011-09-20 22:21:01 +04:00
2015-03-17 00:17:17 +03:00
if ( NOT RPMBUILD_EXECUTABLE )
message ( FATAL_ERROR "RPM package requires rpmbuild executable" )
endif ( )
2007-08-17 17:13:15 +04:00
2015-03-17 00:17:17 +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 ( )
set ( LSB_RELEASE_OUTPUT "lsb_release not installed/found!" )
endif ( )
message ( "CPackRPM:Debug: LSB_RELEASE = ${LSB_RELEASE_OUTPUT}" )
endif ( )
2014-10-14 09:57:11 +04:00
2015-03-17 00:17:17 +03:00
# 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 ( )
2014-10-14 09:57:11 +04:00
2015-03-17 00:17:17 +03:00
# 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." )
2014-10-14 09:57:11 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
# Are we packaging components ?
if ( CPACK_RPM_PACKAGE_COMPONENT )
set ( CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}" )
string ( TOUPPER ${ CPACK_RPM_PACKAGE_COMPONENT } CPACK_RPM_PACKAGE_COMPONENT_UPPER )
2014-10-14 09:57:11 +04:00
else ( )
2015-03-17 00:17:17 +03:00
set ( CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "" )
2012-08-13 21:50:14 +04:00
endif ( )
2010-05-20 17:09:46 +04:00
2015-03-17 00:17:17 +03:00
set ( WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" )
#
# 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-08-17 17:13:15 +04:00
2015-03-17 00:17:17 +03:00
# CPACK_RPM_PACKAGE_SUMMARY (mandatory)
#Check for component summary first.
#If not set, it will use regular package summary logic.
if ( CPACK_RPM_PACKAGE_COMPONENT )
if ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _PACKAGE_SUMMARY )
set ( CPACK_RPM_PACKAGE_SUMMARY ${ CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT } _PACKAGE_SUMMARY} )
endif ( )
2012-08-13 21:50:14 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
if ( NOT CPACK_RPM_PACKAGE_SUMMARY )
if ( CPACK_PACKAGE_DESCRIPTION_SUMMARY )
set ( CPACK_RPM_PACKAGE_SUMMARY ${ CPACK_PACKAGE_DESCRIPTION_SUMMARY } )
else ( )
# if neither var is defined lets use the name as summary
string ( TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY )
endif ( )
2012-08-13 21:50:14 +04:00
endif ( )
2015-02-19 11:01:14 +03:00
2015-03-17 00:17:17 +03:00
# CPACK_RPM_PACKAGE_NAME (mandatory)
if ( NOT CPACK_RPM_PACKAGE_NAME )
string ( TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME )
endif ( )
2015-02-19 11:01:15 +03:00
2015-03-17 00:17:17 +03:00
# 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 ( )
set ( CPACK_RPM_PACKAGE_VERSION ${ CPACK_PACKAGE_VERSION } )
endif ( )
# 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 } )
# CPACK_RPM_PACKAGE_ARCHITECTURE (mandatory)
if ( NOT CPACK_RPM_PACKAGE_ARCHITECTURE )
execute_process ( COMMAND uname "-m"
O U T P U T _ V A R I A B L E C P A C K _ R P M _ P A C K A G E _ A R C H I T E C T U R E
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 )
else ( )
2015-02-19 11:01:15 +03:00
if ( CPACK_RPM_PACKAGE_DEBUG )
2015-03-17 00:17:17 +03:00
message ( "CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}" )
2015-02-19 11:01:15 +03:00
endif ( )
endif ( )
2007-10-13 03:33:41 +04:00
2015-03-17 00:17:17 +03:00
set ( _CPACK_RPM_PACKAGE_ARCHITECTURE ${ CPACK_RPM_PACKAGE_ARCHITECTURE } )
2007-10-13 03:33:41 +04:00
2015-03-17 00:17:17 +03:00
#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}" )
2012-08-13 21:50:14 +04:00
else ( )
2015-03-17 00:17:17 +03:00
set ( TMP_RPM_BUILDARCH "" )
2012-08-13 21:50:14 +04:00
endif ( )
2007-08-17 17:13:15 +04:00
2015-03-17 00:17:17 +03:00
# CPACK_RPM_PACKAGE_RELEASE
# 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
if ( NOT CPACK_RPM_PACKAGE_RELEASE )
set ( CPACK_RPM_PACKAGE_RELEASE 1 )
endif ( )
2014-10-14 09:57:11 +04:00
2015-03-17 00:17:17 +03:00
# CPACK_RPM_PACKAGE_LICENSE
if ( NOT CPACK_RPM_PACKAGE_LICENSE )
set ( CPACK_RPM_PACKAGE_LICENSE "unknown" )
endif ( )
2014-10-14 09:57:11 +04:00
2015-03-17 00:17:17 +03:00
# CPACK_RPM_PACKAGE_GROUP
if ( NOT CPACK_RPM_PACKAGE_GROUP )
set ( CPACK_RPM_PACKAGE_GROUP "unknown" )
2014-10-14 09:57:11 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
# CPACK_RPM_PACKAGE_VENDOR
if ( NOT CPACK_RPM_PACKAGE_VENDOR )
if ( CPACK_PACKAGE_VENDOR )
set ( CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}" )
else ( )
set ( CPACK_RPM_PACKAGE_VENDOR "unknown" )
endif ( )
endif ( )
2007-08-17 17:13:15 +04:00
2015-03-17 00:17:17 +03:00
# CPACK_RPM_PACKAGE_SOURCE
# The name of the source tarball in case we generate a source RPM
# CPACK_RPM_PACKAGE_DESCRIPTION
# The variable content may be either
# - explicitly given by the user or
# - filled with the content of CPACK_PACKAGE_DESCRIPTION_FILE
# if it is defined
# - set to a default value
#
#Check for a component description first.
#If not set, it will use regular package description logic.
if ( CPACK_RPM_PACKAGE_COMPONENT )
if ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _PACKAGE_DESCRIPTION )
set ( CPACK_RPM_PACKAGE_DESCRIPTION ${ CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT } _PACKAGE_DESCRIPTION} )
elseif ( CPACK_COMPONENT_ ${ CPACK_RPM_PACKAGE_COMPONENT_UPPER } _DESCRIPTION )
set ( CPACK_RPM_PACKAGE_DESCRIPTION ${ CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER } _DESCRIPTION} )
endif ( )
endif ( )
2008-12-03 22:37:13 +03:00
2015-03-17 00:17:17 +03:00
if ( NOT CPACK_RPM_PACKAGE_DESCRIPTION )
if ( CPACK_PACKAGE_DESCRIPTION_FILE )
file ( READ ${ CPACK_PACKAGE_DESCRIPTION_FILE } CPACK_RPM_PACKAGE_DESCRIPTION )
else ( )
set ( CPACK_RPM_PACKAGE_DESCRIPTION "no package description available" )
endif ( )
endif ( )
2015-01-21 02:29:46 +03:00
2015-03-17 00:17:17 +03: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 ( )
if ( CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma" )
set ( CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio" )
endif ( )
if ( CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz" )
set ( CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7.xzdio" )
endif ( )
if ( CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2" )
set ( CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio" )
endif ( )
if ( CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip" )
set ( CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio" )
endif ( )
2012-08-13 21:50:14 +04:00
else ( )
2015-03-17 00:17:17 +03:00
set ( CPACK_RPM_COMPRESSION_TYPE_TMP "" )
2012-08-13 21:50:14 +04:00
endif ( )
2010-07-09 22:01:57 +04:00
2015-03-17 00:17:17 +03:00
if ( CPACK_PACKAGE_RELOCATABLE )
set ( CPACK_RPM_PACKAGE_RELOCATABLE TRUE )
endif ( )
if ( CPACK_RPM_PACKAGE_RELOCATABLE )
2012-08-13 21:47:32 +04:00
if ( CPACK_RPM_PACKAGE_DEBUG )
2015-03-17 00:17:17 +03:00
message ( "CPackRPM:Debug: Trying to build a relocatable package" )
2012-08-13 21:50:14 +04:00
endif ( )
2015-03-17 00:17:17 +03: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 ( )
set ( CPACK_RPM_PACKAGE_PREFIX ${ CPACK_PACKAGING_INSTALL_PREFIX } ) # kept for back compatibility (provided external RPM spec files)
cpack_rpm_prepare_relocation_paths ( )
endif ( )
endif ( )
# Check if additional fields for RPM spec header are given
# There may be some COMPONENT specific variables as well
# If component specific var is not provided we use the global one
# for each component
foreach ( _RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}" )
endif ( )
if ( CPACK_RPM_PACKAGE_COMPONENT )
if ( DEFINED CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _PACKAGE_ ${ _RPM_SPEC_HEADER } )
2013-02-09 16:42:05 +04:00
if ( CPACK_RPM_PACKAGE_DEBUG )
2015-03-17 00:17:17 +03:00
message ( "CPackRPM:Debug: using CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}" )
2013-02-09 16:42:05 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
set ( CPACK_RPM_PACKAGE_ ${ _RPM_SPEC_HEADER } _TMP ${ CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT } _PACKAGE_ ${ _RPM_SPEC_HEADER } } )
else ( )
if ( DEFINED CPACK_RPM_PACKAGE_ ${ _RPM_SPEC_HEADER } )
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 ( )
set ( CPACK_RPM_PACKAGE_ ${ _RPM_SPEC_HEADER } _TMP ${ CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER } } )
endif ( )
endif ( )
else ( )
if ( DEFINED CPACK_RPM_PACKAGE_ ${ _RPM_SPEC_HEADER } )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}" )
2012-08-13 21:50:14 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
set ( CPACK_RPM_PACKAGE_ ${ _RPM_SPEC_HEADER } _TMP ${ CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER } } )
2013-02-09 16:42:05 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
endif ( )
2011-10-30 23:13:20 +04:00
2015-03-17 00:17:17 +03:00
# Treat the RPM Spec keyword iff it has been properly defined
if ( DEFINED CPACK_RPM_PACKAGE_ ${ _RPM_SPEC_HEADER } _TMP )
# Transform NAME --> Name e.g. PROVIDES --> Provides
# The Upper-case first letter and lowercase tail is the
# appropriate value required in the final RPM spec file.
string ( SUBSTRING ${ _RPM_SPEC_HEADER } 1 -1 _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}" )
# The following keywords require parentheses around the "pre" or "post" suffix in the final RPM spec file.
set ( SCRIPTS_REQUIREMENTS_LIST REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN )
list ( FIND SCRIPTS_REQUIREMENTS_LIST ${ _RPM_SPEC_HEADER } IS_SCRIPTS_REQUIREMENT_FOUND )
if ( NOT ${ IS_SCRIPTS_REQUIREMENT_FOUND } EQUAL -1 )
string ( REPLACE "_" "(" _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}" )
set ( _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME})" )
endif ( )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}" )
endif ( )
set ( TMP_RPM_ ${ _RPM_SPEC_HEADER } "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}" )
unset ( CPACK_RPM_PACKAGE_ ${ _RPM_SPEC_HEADER } _TMP )
2014-10-08 21:39:19 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
endforeach ( )
# 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 )
2012-08-13 21:47:32 +04:00
if ( CPACK_RPM_PACKAGE_DEBUG )
2015-03-17 00:17:17 +03:00
message ( "CPackRPM:Debug: User defined CPACK_RPM_SPEC_INSTALL_POST = ${CPACK_RPM_SPEC_INSTALL_POST}" )
2012-08-13 21:50:14 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
set ( TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}" )
2012-08-13 21:50:14 +04:00
endif ( )
2008-09-20 01:45:37 +04:00
2015-03-17 00:17:17 +03: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.
# The refered script file(s) will be read and directly
# put after the %post or %postun section
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 ( )
set ( CPACK_RPM_POST_UNINSTALL_READ_FILE ${ CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE } )
endif ( )
2011-09-20 22:21:01 +04:00
else ( )
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 } )
2012-08-13 21:50:14 +04:00
endif ( )
2011-11-05 14:40:47 +04:00
2015-03-17 00:17:17 +03:00
# Handle post-install file if it has been specified
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 ( )
message ( "CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_READ_FILE}> does not exists - ignoring" )
endif ( )
2012-08-13 21:50:14 +04:00
else ( )
2015-03-17 00:17:17 +03:00
# reset SPEC var value if no post install file has been specified
# (either globally or component-wise)
set ( CPACK_RPM_SPEC_POSTINSTALL "" )
2012-08-13 21:50:14 +04:00
endif ( )
2011-09-20 22:21:01 +04:00
2015-03-17 00:17:17 +03:00
# Handle post-uninstall file if it has been specified
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 ( )
message ( "CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_READ_FILE}> does not exists - ignoring" )
endif ( )
2012-08-13 21:50:14 +04:00
else ( )
2015-03-17 00:17:17 +03:00
# reset SPEC var value if no post uninstall file has been specified
# (either globally or component-wise)
set ( CPACK_RPM_SPEC_POSTUNINSTALL "" )
2012-08-13 21:50:14 +04:00
endif ( )
2011-09-20 22:21:01 +04:00
2015-03-17 00:17:17 +03:00
# 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)
# May be used to embed a pre (un)installation script in the spec file.
# The refered script file(s) will be read and directly
# put after the %pre or %preun section
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 ( )
set ( CPACK_RPM_PRE_INSTALL_READ_FILE ${ CPACK_RPM_PRE_INSTALL_SCRIPT_FILE } )
endif ( )
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 ( )
set ( CPACK_RPM_PRE_UNINSTALL_READ_FILE ${ CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE } )
endif ( )
2012-08-13 21:50:14 +04:00
else ( )
2011-09-20 22:21:01 +04:00
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 } )
2012-08-13 21:50:14 +04:00
endif ( )
2011-11-05 14:40:47 +04:00
2015-03-17 00:17:17 +03:00
# Handle pre-install file if it has been specified
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 ( )
message ( "CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_READ_FILE}> does not exists - ignoring" )
endif ( )
2012-08-13 21:50:14 +04:00
else ( )
2015-03-17 00:17:17 +03:00
# reset SPEC var value if no pre-install file has been specified
# (either globally or component-wise)
set ( CPACK_RPM_SPEC_PREINSTALL "" )
2012-08-13 21:50:14 +04:00
endif ( )
2011-09-20 22:21:01 +04:00
2015-03-17 00:17:17 +03:00
# Handle pre-uninstall file if it has been specified
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 ( )
message ( "CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_READ_FILE}> does not exists - ignoring" )
endif ( )
2012-08-13 21:50:14 +04:00
else ( )
2015-03-17 00:17:17 +03:00
# reset SPEC var value if no pre-uninstall file has been specified
# (either globally or component-wise)
set ( CPACK_RPM_SPEC_PREUNINSTALL "" )
2012-08-13 21:50:14 +04:00
endif ( )
2009-11-11 23:55:44 +03:00
2015-03-17 00:17:17 +03: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 ( )
message ( SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring" )
endif ( )
2012-08-13 21:50:14 +04:00
else ( )
2015-03-17 00:17:17 +03:00
set ( CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Eric Noulard <eric.noulard@gmail.com> - ${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}\n Generated by CPack RPM (no Changelog file were provided)" )
2012-08-13 21:50:14 +04:00
endif ( )
2010-05-20 17:09:46 +04:00
2015-03-17 00:17:17 +03: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 ( )
2012-08-13 21:50:14 +04:00
endif ( )
2008-09-20 01:45:37 +04:00
2015-03-17 00:17:17 +03:00
# 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}" )
# 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}" )
# 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}" )
# if we are creating a relocatable package, omit parent directories of
# CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list"
# which is passed to the find command that generates the content-list
if ( CPACK_RPM_PACKAGE_RELOCATABLE )
# get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are
# destinct parent paths of other relocation paths and remove the
# final element (so the install-prefix dir itself is not omitted
# from the RPM's content-list)
list ( SORT RPM_USED_PACKAGE_PREFIXES )
set ( _DISTINCT_PATH "NOT_SET" )
foreach ( _RPM_RELOCATION_PREFIX ${ RPM_USED_PACKAGE_PREFIXES } )
if ( NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*" )
set ( _DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}" )
string ( REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS ".${_RPM_RELOCATION_PREFIX}" )
list ( REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1 )
unset ( _TMP_LIST )
# Now generate all of the parent dirs of the relocation path
foreach ( _PREFIX_PATH_ELEM ${ _CPACK_RPM_PACKAGE_PREFIX_ELEMS } )
list ( APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}" )
string ( REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}" )
list ( FIND _RPM_DIRS_TO_OMIT "${_OMIT_DIR}" _DUPLICATE_FOUND )
if ( _DUPLICATE_FOUND EQUAL -1 )
set ( _OMIT_DIR "-o -path ${_OMIT_DIR}" )
separate_arguments ( _OMIT_DIR )
list ( APPEND _RPM_DIRS_TO_OMIT ${ _OMIT_DIR } )
endif ( )
endforeach ( )
endif ( )
endforeach ( )
endif ( )
2012-08-07 21:15:19 +04:00
2015-03-17 00:17:17 +03:00
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}" )
endif ( )
2013-04-05 14:43:50 +04:00
2015-03-17 00:17:17 +03:00
if ( NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST )
set ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/include )
if ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION )
message ( "CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list." )
list ( APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}" )
endif ( )
2013-04-05 14:43:50 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
if ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}" )
endif ( )
foreach ( _DIR ${ CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST } )
list ( APPEND _RPM_DIRS_TO_OMIT "-o;-path;.${_DIR}" )
endforeach ( )
endif ( )
2013-04-05 14:43:50 +04:00
if ( CPACK_RPM_PACKAGE_DEBUG )
2015-03-17 00:17:17 +03:00
message ( "CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}" )
endif ( )
2013-04-05 14:43:50 +04:00
2015-03-17 00:17:17 +03:00
# Use files tree to construct files command (spec file)
# We should not forget to include symlinks (thus -o -type l)
# We should include directory as well (thus -type d)
# but not the main local dir "." (thus -a -not -name ".")
# We must remove the './' due to the local search and escape the
# 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 } ) )
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 \ " /
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 )
# In component case, put CPACK_ABSOLUTE_DESTINATION_FILES_<COMPONENT>
# into CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
# otherwise, put CPACK_ABSOLUTE_DESTINATION_FILES
# This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL 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_INTERNAL "${${COMPONENT_FILES_TAG}}" )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>" )
message ( "CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}" )
endif ( )
endif ( )
else ( )
if ( CPACK_ABSOLUTE_DESTINATION_FILES )
set ( CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${CPACK_ABSOLUTE_DESTINATION_FILES}" )
endif ( )
2011-04-17 19:12:38 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
# In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM_<COMPONENT>_USER_FILELIST.
if ( CPACK_RPM_PACKAGE_COMPONENT )
if ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _USER_FILELIST )
set ( CPACK_RPM_USER_FILELIST_INTERNAL ${ CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT } _USER_FILELIST} )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>" )
message ( "CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}" )
endif ( )
else ( )
set ( CPACK_RPM_USER_FILELIST_INTERNAL "" )
endif ( )
else ( )
if ( CPACK_RPM_USER_FILELIST )
set ( CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}" )
else ( )
set ( CPACK_RPM_USER_FILELIST_INTERNAL "" )
endif ( )
2011-12-13 02:11:02 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
# Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL
# Remove those files from CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
# or CPACK_RPM_INSTALL_FILES,
# hence it must be done before these auto-generated lists are processed.
if ( CPACK_RPM_USER_FILELIST_INTERNAL )
2011-12-13 02:11:02 +04:00
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>" )
2012-08-13 21:50:14 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
# Create CMake list from CPACK_RPM_INSTALL_FILES
string ( STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST )
string ( REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST
" $ { C P A C K _ R P M _ I N S T A L L _ F I L E S _ L I S T } " )
string ( REPLACE "\" " " " CPACK_RPM_INSTALL_FILES_LIST
" $ { C P A C K _ R P M _ I N S T A L L _ F I L E S _ L I S T } " )
set ( CPACK_RPM_USER_INSTALL_FILES "" )
foreach ( F IN LISTS CPACK_RPM_USER_FILELIST_INTERNAL )
string ( REGEX REPLACE "%[A-Za-z0-9\(\),-]* " "" F_PATH ${ F } )
string ( REGEX MATCH "%[A-Za-z0-9\(\),-]*" F_PREFIX ${ F } )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: F_PREFIX=<${F_PREFIX}>, F_PATH=<${F_PATH}>" )
endif ( )
if ( F_PREFIX )
set ( F_PREFIX "${F_PREFIX} " )
endif ( )
# Rebuild the user list file
set ( CPACK_RPM_USER_INSTALL_FILES "${CPACK_RPM_USER_INSTALL_FILES}${F_PREFIX}\" ${ F_PATH } \"\n")
# Remove from CPACK_RPM_INSTALL_FILES and CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
list ( REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${ F_PATH } )
# ABSOLUTE destination files list may not exists at all
if ( CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL )
list ( REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${ F_PATH } )
endif ( )
endforeach ( )
# Rebuild CPACK_RPM_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 ( )
2011-12-13 02:11:02 +04:00
else ( )
2015-03-17 00:17:17 +03:00
set ( CPACK_RPM_USER_INSTALL_FILES "" )
2011-12-13 02:11:02 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
if ( CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}" )
endif ( )
# 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_INTERNAL } )
# 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 ( )
# Build ABSOLUTE_INSTALL_FILES
set ( CPACK_RPM_ABSOLUTE_INSTALL_FILES "" )
foreach ( F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL )
set ( CPACK_RPM_ABSOLUTE_INSTALL_FILES "${CPACK_RPM_ABSOLUTE_INSTALL_FILES}%config \" ${ F } \"\n")
endforeach ( )
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 ( )
2011-12-13 02:11:02 +04:00
else ( )
2015-03-17 00:17:17 +03:00
# reset vars in order to avoid leakage of value(s) from one component to another
set ( CPACK_RPM_ABSOLUTE_INSTALL_FILES "" )
2011-12-13 02:11:02 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
# Prepend directories in ${CPACK_RPM_INSTALL_FILES} with %dir
# This is necessary to avoid duplicate files since rpmbuild do
# recursion on its own when encountering a pathname which is a directory
# which is not flagged as %dir
2011-12-13 02:11:02 +04:00
string ( STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST )
string ( REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST
" $ { C P A C K _ R P M _ I N S T A L L _ F I L E S _ L I S T } " )
string ( REPLACE "\" " " " CPACK_RPM_INSTALL_FILES_LIST
" $ { C P A C K _ R P M _ I N S T A L L _ F I L E S _ L I S T } " )
set ( CPACK_RPM_INSTALL_FILES "" )
foreach ( F IN LISTS CPACK_RPM_INSTALL_FILES_LIST )
2015-03-17 00:17:17 +03:00
if ( IS_DIRECTORY "${WDIR}/${F}" )
set ( CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}%dir \" ${ F } \"\n")
else ( )
set ( CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}\" ${ F } \"\n")
endif ( )
2012-08-13 21:50:14 +04:00
endforeach ( )
2015-03-17 00:17:17 +03:00
set ( CPACK_RPM_INSTALL_FILES_LIST "" )
2011-04-17 19:12:38 +04:00
2015-03-17 00:17:17 +03:00
# 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" )
2010-08-23 19:38:33 +04:00
2015-03-17 00:17:17 +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}" )
2012-01-14 00:35:41 +04:00
endif ( )
2010-05-20 17:09:46 +04:00
2015-03-17 00:17:17 +03:00
#
# USER generated/provided spec file handling.
#
2013-04-01 18:06:22 +04:00
2015-03-17 00:17:17 +03:00
# We can have a component specific spec file.
if ( CPACK_RPM_PACKAGE_COMPONENT AND CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT } _USER_BINARY_SPECFILE )
set ( CPACK_RPM_USER_BINARY_SPECFILE ${ CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT } _USER_BINARY_SPECFILE} )
endif ( )
2013-04-01 18:06:22 +04:00
2015-03-17 00:17:17 +03:00
# We should generate a USER 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
2009-11-10 00:17:22 +03:00
" # -*- 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 \ @
2014-10-08 21:39:19 +04:00
\ @ T M P _ R P M _ R E Q U I R E S _ P R E \ @
\ @ T M P _ R P M _ R E Q U I R E S _ P O S T \ @
2014-10-09 21:29:18 +04:00
\ @ T M P _ R P M _ R E Q U I R E S _ P R E U N \ @
\ @ T M P _ R P M _ R E Q U I R E S _ P O S T U N \ @
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 \ @
2015-01-21 02:29:46 +03:00
\ @ T M P _ R P M _ P R E F I X E S \ @
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,- )
2013-04-01 18:06:22 +04:00
\ @ C P A C K _ R P M _ I N S T A L L _ F I L E S \ @
\ @ 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 \ @
\ @ C P A C K _ R P M _ U S E R _ 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
" )
2015-03-17 00:17:17 +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
# 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 ( )
2012-08-13 21:50:14 +04:00
endif ( )
2007-08-17 17:13:15 +04:00
2015-03-17 00:17:17 +03:00
# 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 ( )
# 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 )
2012-08-13 21:50:14 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
if ( RPMBUILD_EXECUTABLE )
# Now call rpmbuild using the SPECFILE
execute_process (
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
- - 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 } "
- - 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 } "
- - t a r g e t " $ { _ C P A C K _ R P M _ P A C K A G E _ A R C H I T E C T U R E } "
" $ { C P A C K _ R P M _ B I N A R Y _ S P E C F I L E } "
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 } "
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
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 " )
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 ( )
else ( )
if ( ALIEN_EXECUTABLE )
message ( FATAL_ERROR "RPM packaging through alien not done (yet)" )
endif ( )
2012-08-13 21:50:14 +04:00
endif ( )
2015-03-17 00:17:17 +03:00
endfunction ( )
2014-10-14 09:57:11 +04:00
2015-03-17 00:17:17 +03:00
cpack_rpm_generate_package ( )