2016-09-27 22:01:08 +03:00
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
2013-10-15 19:17:36 +04:00
#.rst:
# CPackRPM
# --------
#
2016-05-31 23:06:39 +03:00
# The built in (binary) CPack RPM generator (Unix only)
2013-10-15 19:17:36 +04:00
#
2013-10-15 21:23:23 +04:00
# Variables specific to CPack RPM generator
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
2016-05-31 23:06:39 +03:00
# CPackRPM may be used to create RPM packages using :module:`CPack`.
# CPackRPM is a :module:`CPack` generator thus it uses the ``CPACK_XXX``
# variables used by :module:`CPack`.
2013-10-15 19:17:36 +04:00
#
2016-02-13 04:09:32 +03:00
# CPackRPM has specific features which are controlled by the specifics
# :code:`CPACK_RPM_XXX` variables.
2013-10-15 19:17:36 +04:00
#
2016-02-13 04:09:32 +03:00
# :code:`CPACK_RPM_<COMPONENT>_XXXX` variables may be used in order to have
# **component** specific values. Note however that ``<COMPONENT>`` refers to the
# **grouping name** written in upper case. It may be either a component name or
2016-05-31 23:06:39 +03:00
# a component GROUP name. Usually those variables correspond to RPM spec file
# entities. One may find information about spec files here
2016-02-13 04:09:32 +03:00
# http://www.rpm.org/wiki/Docs
#
# .. note::
#
2016-03-29 21:24:20 +03:00
# `<COMPONENT>` part of variables is preferred to be in upper case (for e.g. if
2016-02-13 04:09:32 +03:00
# component is named `foo` then use `CPACK_RPM_FOO_XXXX` variable name format)
# as is with other `CPACK_<COMPONENT>_XXXX` variables.
# For the purposes of back compatibility (CMake/CPack version 3.5 and lower)
# support for same cased component (e.g. `fOo` would be used as
# `CPACK_RPM_fOo_XXXX`) is still supported for variables defined in older
# versions of CMake/CPack but is not guaranteed for variables that
# will be added in the future. For the sake of back compatibility same cased
# component variables also override upper cased versions where both are
# present.
#
2016-05-31 23:06:39 +03:00
# Here are some CPackRPM wiki resources that are here for historic reasons and
# are no longer maintained but may still prove useful:
#
# - https://cmake.org/Wiki/CMake:CPackConfiguration
# - https://cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29
#
# List of CPackRPM specific variables:
#
2016-11-02 11:53:55 +03:00
# .. variable:: CPACK_RPM_COMPONENT_INSTALL
2016-05-31 23:06:39 +03:00
#
# Enable component packaging for CPackRPM
#
# * Mandatory : NO
# * Default : OFF
#
# If enabled (ON) multiple packages are generated. By default a single package
# containing files of all components is generated.
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
2016-05-31 23:06:39 +03:00
# * Default : :variable:`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
2015-12-07 21:11:51 +03:00
# CPACK_RPM_<component>_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
2016-05-31 23:06:39 +03:00
# * Default : :variable:`CPACK_PACKAGE_NAME`
2013-10-15 19:17:36 +04:00
#
2016-05-15 04:01:34 +03:00
# .. variable:: CPACK_RPM_FILE_NAME
# CPACK_RPM_<component>_FILE_NAME
#
# Package file name.
#
# * Mandatory : YES
# * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].rpm`` with spaces
# replaced by '-'
#
# This may be set to ``RPM-DEFAULT`` to allow rpmbuild tool to generate package
# file name by itself.
2016-05-31 23:06:39 +03:00
# Alternatively provided package file name must end with ``.rpm`` suffix.
2016-05-15 04:01:34 +03:00
#
# .. note::
#
# By using user provided spec file, rpm macro extensions such as for
# generating debuginfo packages or by simply using multiple components more
# than one rpm file may be generated, either from a single spec file or from
# multiple spec files (each component execution produces it's own spec file).
# In such cases duplicate file names may occur as a result of this variable
# setting or spec file content structure. Duplicate files get overwritten
# and it is up to the packager to set the variables in a manner that will
# prevent such errors.
#
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
2016-05-31 23:06:39 +03:00
# * Default : :variable:`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
2016-05-31 23:06:39 +03:00
# * Default : Native architecture output by ``uname -m``
2013-10-15 19:17:36 +04:00
#
2016-05-31 23:06:39 +03: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
2016-05-11 12:21:11 +03:00
# :variable:`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
2013-10-15 21:23:23 +04:00
# distro specific numbering.
2013-10-15 19:17:36 +04:00
#
2016-05-11 12:21:11 +03:00
# .. note::
#
# This is the string that goes into the RPM ``Release:`` field. Some distros
# (e.g. Fedora, CentOS) require ``1%{?dist}`` format and not just a number.
# ``%{?dist}`` part can be added by setting :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`.
#
# .. variable:: CPACK_RPM_PACKAGE_RELEASE_DIST
#
# The dist tag that is added RPM ``Release:`` field.
#
# * Mandatory : NO
# * Default : OFF
#
# This is the reported ``%{dist}`` tag from the current distribution or empty
# ``%{dist}`` if RPM macro is not set. If this variable is set then RPM
# ``Release:`` field value is set to ``${CPACK_RPM_PACKAGE_RELEASE}%{?dist}``.
#
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
2015-12-07 21:11:51 +03:00
# CPACK_RPM_<component>_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
2015-07-16 23:48:27 +03:00
# CPACK_RPM_<component>_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
2016-05-31 23:06:39 +03:00
# * Default : :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION` (component
# based installers only) if set, :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`
# if set or "no package 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
2016-05-31 23:06:39 +03:00
# compression whereas older cannot use such RPM. Using this one can enforce
# compression type to be used.
#
# Possible values are:
#
# - lzma
# - xz
# - bzip2
# - gzip
2013-10-15 19:17:36 +04:00
#
2015-07-16 23:48:27 +03:00
# .. variable:: CPACK_RPM_PACKAGE_AUTOREQ
# CPACK_RPM_<component>_PACKAGE_AUTOREQ
#
# RPM spec autoreq field.
#
# * Mandatory : NO
# * Default : -
#
# May be used to enable (1, yes) or disable (0, no) automatic shared libraries
# dependency detection. Dependencies are added to requires list.
#
# .. note::
#
2016-05-31 23:06:39 +03:00
# By default automatic dependency detection is enabled by rpm generator.
2015-07-16 23:48:27 +03:00
#
# .. variable:: CPACK_RPM_PACKAGE_AUTOPROV
# CPACK_RPM_<component>_PACKAGE_AUTOPROV
#
# RPM spec autoprov field.
#
# * Mandatory : NO
# * Default : -
#
# May be used to enable (1, yes) or disable (0, no) automatic listing of shared
# libraries that are provided by the package. Shared libraries are added to
# provides list.
#
# .. note::
#
2016-05-31 23:06:39 +03:00
# By default automatic provides detection is enabled by rpm generator.
2015-07-16 23:48:27 +03:00
#
# .. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV
# CPACK_RPM_<component>_PACKAGE_AUTOREQPROV
#
# RPM spec autoreqprov field.
#
# * Mandatory : NO
# * Default : -
#
# Variable enables/disables autoreq and autoprov at the same time.
# See :variable:`CPACK_RPM_PACKAGE_AUTOREQ` and :variable:`CPACK_RPM_PACKAGE_AUTOPROV`
# for more details.
#
# .. note::
#
2016-05-31 23:06:39 +03:00
# By default automatic detection feature is enabled by rpm.
2015-07-16 23:48:27 +03:00
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES
2015-07-16 23:48:27 +03:00
# CPACK_RPM_<component>_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
#
2016-05-31 23:06:39 +03:00
# May be used to set RPM dependencies (requires). Note that you must enclose
2013-10-15 21:23:23 +04:00
# 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
#
2015-07-17 18:11:37 +03:00
# .. variable:: CPACK_RPM_PACKAGE_CONFLICTS
# CPACK_RPM_<component>_PACKAGE_CONFLICTS
#
# RPM spec conflicts field.
#
# * Mandatory : NO
# * Default : -
#
2016-05-31 23:06:39 +03:00
# May be used to set negative RPM dependencies (conflicts). Note that you must
# enclose the complete requires string between quotes, for example::
2015-07-17 18:11:37 +03:00
#
# set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2")
#
# The conflicting package list of an RPM file could be printed with::
#
# rpm -qp --conflicts file.rpm
#
2014-10-08 21:39:19 +04:00
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE
2015-07-16 23:48:27 +03:00
# CPACK_RPM_<component>_PACKAGE_REQUIRES_PRE
2014-10-08 21:39:19 +04:00
#
# RPM spec requires(pre) field.
#
# * Mandatory : NO
# * Default : -
#
2016-05-31 23:06:39 +03:00
# May be used to set RPM preinstall dependencies (requires(pre)). Note that
# you must enclose the complete requires string between quotes, for example::
2014-10-08 21:39:19 +04:00
#
# set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
#
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST
2015-07-16 23:48:27 +03:00
# CPACK_RPM_<component>_PACKAGE_REQUIRES_POST
2014-10-08 21:39:19 +04:00
#
# RPM spec requires(post) field.
#
# * Mandatory : NO
# * Default : -
#
2016-05-31 23:06:39 +03:00
# May be used to set RPM postinstall dependencies (requires(post)). Note that
# you must enclose the complete requires string between quotes, for example::
2014-10-08 21:39:19 +04:00
#
# set(CPACK_RPM_PACKAGE_REQUIRES_POST "shadow-utils, initscripts")
#
2014-10-09 21:29:18 +04:00
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN
2015-07-16 23:48:27 +03:00
# CPACK_RPM_<component>_PACKAGE_REQUIRES_POSTUN
2014-10-09 21:29:18 +04:00
#
# RPM spec requires(postun) field.
#
# * Mandatory : NO
# * Default : -
#
2016-05-31 23:06:39 +03:00
# May be used to set RPM postuninstall dependencies (requires(postun)). Note
# that you must enclose the complete requires string between quotes, for
# example::
2014-10-09 21:29:18 +04:00
#
# set(CPACK_RPM_PACKAGE_REQUIRES_POSTUN "shadow-utils, initscripts")
#
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN
2015-07-16 23:48:27 +03:00
# CPACK_RPM_<component>_PACKAGE_REQUIRES_PREUN
2014-10-09 21:29:18 +04:00
#
# RPM spec requires(preun) field.
#
# * Mandatory : NO
# * Default : -
#
2016-05-31 23:06:39 +03:00
# May be used to set RPM preuninstall dependencies (requires(preun)). Note that
# you must enclose the complete requires string between quotes, for example::
2014-10-09 21:29:18 +04:00
#
# set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts")
#
2013-10-15 21:23:23 +04:00
# .. variable:: CPACK_RPM_PACKAGE_SUGGESTS
2015-07-16 23:48:27 +03:00
# CPACK_RPM_<component>_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
#
2016-05-31 23:06:39 +03:00
# May be used to set weak RPM dependencies (suggests). Note that you must
2013-10-15 21:23:23 +04:00
# 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
2015-07-16 23:48:27 +03:00
# CPACK_RPM_<component>_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
#
2016-05-31 23:06:39 +03:00
# May be used to set RPM dependencies (provides). The provided package list
2013-10-15 21:23:23 +04:00
# 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
2015-07-16 23:48:27 +03:00
# CPACK_RPM_<component>_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
#
2016-05-31 23:06:39 +03:00
# in order to install it at an alternate place see rpm(8). Note that
# currently this may fail if :variable:`CPACK_SET_DESTDIR` is set to ``ON``. If
# :variable:`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
#
2016-05-31 23:06:39 +03:00
# Deprecated - use :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE` instead.
#
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
2016-05-31 23:06:39 +03:00
# :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE`.
2013-10-15 21:23:23 +04:00
# May be used to set an RPM post-install command inside the spec file.
2016-05-31 23:06:39 +03:00
# For example setting it to ``/bin/true`` may be used to prevent
2013-10-15 21:23:23 +04:00
# 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
#
2016-05-31 23:06:39 +03: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
2016-05-31 23:06:39 +03:00
# CPACK_RPM_<componentName>_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).
#
# .. 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
2016-05-31 23:06:39 +03:00
# binary spec file which may be used with
# :variable:`CPACK_RPM_USER_BINARY_SPECFILE`.
2013-10-15 21:23:23 +04:00
#
# .. variable:: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
#
2016-05-31 23:06:39 +03:00
# Path to file containing pre (un)install script.
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
#
# May be used to embed a pre (un)installation script in the spec file.
2016-05-31 23:06:39 +03:00
# The referred script file (or both) will be read and directly
# put after the ``%pre`` or ``%preun`` section
2016-11-02 11:53:55 +03:00
# If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the (un)install
2016-05-31 23:06:39 +03:00
# script for each component can be overridden with
# ``CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE`` and
# ``CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE``.
2013-10-15 21:23:23 +04:00
# 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
#
2016-05-31 23:06:39 +03:00
# Path to file containing post (un)install script.
#
2013-10-15 21:23:23 +04:00
# * Mandatory : NO
# * Default : -
#
# May be used to embed a post (un)installation script in the spec file.
2016-05-31 23:06:39 +03:00
# The referred script file (or both) will be read and directly
# put after the ``%post`` or ``%postun`` section.
2016-11-02 11:53:55 +03:00
# If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the (un)install
2016-05-31 23:06:39 +03:00
# script for each component can be overridden with
# ``CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE`` and
# ``CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE``.
2013-10-15 21:23:23 +04:00
# 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 : -
#
2016-05-31 23:06:39 +03:00
# 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
2013-10-15 21:23:23 +04:00
# the list of files (and directories) the user specified files of
2016-05-31 23:06:39 +03:00
# the ``CPACK_RPM_<COMPONENT>_USER_FILELIST`` list will be removed from
2013-10-15 21:23:23 +04:00
# 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.
2016-05-31 23:06:39 +03:00
# The referred file will be read and directly put after the ``%changelog``
2013-10-15 21:23:23 +04:00
# 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
2016-05-31 23:06:39 +03:00
# path. If you want to add some path to the default list then you can use
# :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION` variable.
2013-10-15 21:23:23 +04:00
#
# .. 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
2016-05-31 23:06:39 +03:00
# default list of excluded paths. See
# :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST`.
2015-01-21 02:29:46 +03:00
#
# .. variable:: CPACK_RPM_RELOCATION_PATHS
#
2016-05-31 23:06:39 +03:00
# Packages relocation paths list.
#
2015-01-21 02:29:46 +03:00
# * 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
2016-05-31 23:06:39 +03:00
# by the value of :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX` or by the
# value of :variable:`CPACK_PACKAGING_INSTALL_PREFIX` if the component version
# is not provided.
2015-01-21 02:29:46 +03:00
# 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
2016-05-31 23:06:39 +03:00
# with :variable:`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.
2015-01-21 02:29:46 +03:00
# Packages that either do not contain any relocation paths or contain
# files/directories/symbolic links that are outside relocation paths print
2016-05-31 23:06:39 +03:00
# out an ``AUTHOR_WARNING`` that RPM will be partially relocatable.
2015-01-21 02:29:46 +03:00
#
# .. variable:: CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
#
2016-05-31 23:06:39 +03:00
# Per component relocation path install prefix.
#
2015-01-21 02:29:46 +03:00
# * Mandatory : NO
# * Default : CPACK_PACKAGING_INSTALL_PREFIX
#
2016-05-31 23:06:39 +03:00
# May be used to set per component :variable:`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
#
2016-05-31 23:06:39 +03:00
# Removal of default install prefix from relocation paths list.
#
2015-03-20 23:52:49 +03:00
# * 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.
2015-03-29 21:55:20 +03:00
#
2015-04-19 19:22:18 +03:00
# .. variable:: CPACK_RPM_ADDITIONAL_MAN_DIRS
#
# * Mandatory : NO
# * Default : -
#
# May be used to set additional man dirs that could potentially be compressed
# by brp-compress RPM macro. Variable content must be a list of regular
# expressions that point to directories containing man files or to man files
# directly. Note that in order to compress man pages a path must also be
# present in brp-compress RPM script and that brp-compress script must be
# added to RPM configuration by the operating system.
#
# Regular expressions that are added by default were taken from brp-compress
# RPM macro:
#
# - /usr/man/man.*
# - /usr/man/.*/man.*
# - /usr/info.*
# - /usr/share/man/man.*
# - /usr/share/man/.*/man.*
# - /usr/share/info.*
# - /usr/kerberos/man.*
# - /usr/X11R6/man/man.*
# - /usr/lib/perl5/man/man.*
# - /usr/share/doc/.*/man/man.*
# - /usr/lib/.*/man/man.*
#
2016-03-29 01:51:18 +03:00
# .. variable:: CPACK_RPM_DEFAULT_USER
# CPACK_RPM_<compName>_DEFAULT_USER
#
# default user ownership of RPM content
#
# * Mandatory : NO
# * Default : root
#
# Value should be user name and not UID.
# Note that <compName> must be in upper-case.
#
# .. variable:: CPACK_RPM_DEFAULT_GROUP
# CPACK_RPM_<compName>_DEFAULT_GROUP
#
# default group ownership of RPM content
#
# * Mandatory : NO
# * Default : root
#
# Value should be group name and not GID.
# Note that <compName> must be in upper-case.
#
# .. variable:: CPACK_RPM_DEFAULT_FILE_PERMISSIONS
# CPACK_RPM_<compName>_DEFAULT_FILE_PERMISSIONS
#
# default permissions used for packaged files
#
# * Mandatory : NO
# * Default : - (system default)
#
2016-05-31 23:06:39 +03:00
# Accepted values are lists with ``PERMISSIONS``. Valid permissions
# are:
#
# - OWNER_READ
# - OWNER_WRITE
# - OWNER_EXECUTE
# - GROUP_READ
# - GROUP_WRITE
# - GROUP_EXECUTE
# - WORLD_READ
# - WORLD_WRITE
# - WORLD_EXECUTE
#
2016-03-29 01:51:18 +03:00
# Note that <compName> must be in upper-case.
#
# .. variable:: CPACK_RPM_DEFAULT_DIR_PERMISSIONS
# CPACK_RPM_<compName>_DEFAULT_DIR_PERMISSIONS
#
# default permissions used for packaged directories
#
# * Mandatory : NO
# * Default : - (system default)
#
# Accepted values are lists with PERMISSIONS. Valid permissions
2016-05-31 23:06:39 +03:00
# are the same as for :variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`.
2016-03-29 01:51:18 +03:00
# Note that <compName> must be in upper-case.
#
2015-03-29 21:55:20 +03:00
# Packaging of Symbolic Links
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
# CPackRPM supports packaging of symbolic links::
#
# execute_process(COMMAND ${CMAKE_COMMAND}
# -E create_symlink <relative_path_location> <symlink_name>)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/<symlink_name>
# DESTINATION <symlink_location> COMPONENT libraries)
#
# Symbolic links will be optimized (paths will be shortened if possible)
# before being added to the package or if multiple relocation paths are
# detected, a post install symlink relocation script will be generated.
#
# Symbolic links may point to locations that are not packaged by the same
# package (either a different component or even not packaged at all) but
# those locations will be treated as if they were a part of the package
# while determining if symlink should be either created or present in a
# post install script - depending on relocation paths.
#
2016-03-31 08:48:38 +03:00
# Symbolic links that point to locations outside packaging path produce a
# warning and are treated as non relocatable permanent symbolic links.
2015-03-29 21:55:20 +03:00
#
2016-05-31 23:06:39 +03:00
# Currently there are a few limitations though:
2015-03-29 21:55:20 +03:00
#
# * For component based packaging component interdependency is not checked
# when processing symbolic links. Symbolic links pointing to content of
# a different component are treated the same way as if pointing to location
# that will not be packaged.
#
# * Symbolic links pointing to a location through one or more intermediate
# symbolic links will not be handled differently - if the intermediate
# symbolic link(s) is also on a relocatable path, relocating it during
# package installation may cause initial symbolic link to point to an
# invalid location.
2016-09-20 00:44:06 +03:00
#
2016-09-22 20:24:25 +03:00
# Packaging of debug information
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
# Debuginfo packages contain debug symbols and sources for debugging packaged
# binaries.
#
# .. note::
#
# Currently multiple debuginfo packages are generated if component based
# packaging is used - one debuginfo package per component. This duplicates
# sources if multiple binaries are using them. This is a side effect of
# how CPackRPM currently generates component packages and will be addressed
# in later versions of the generator.
#
# Debuginfo RPM packaging has it's own set of variables:
#
# .. variable:: CPACK_RPM_DEBUGINFO_PACKAGE
# CPACK_RPM_<component>_DEBUGINFO_PACKAGE
#
# Enable generation of debuginfo RPM package(s).
#
# * Mandatory : NO
# * Default : OFF
#
# .. note::
#
# Binaries must contain debug symbols before packaging so use either ``Debug``
# or ``RelWithDebInfo`` for :variable:`CMAKE_BUILD_TYPE` variable value.
#
# .. note::
#
# Packages generated from packages without binary files, with binary files but
# without execute permissions or without debug symbols will be empty.
#
# .. variable:: CPACK_BUILD_SOURCE_DIRS
#
# Provides locations of root directories of source files from which binaries
# were built.
#
# * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
# * Default : -
#
# .. note::
#
# For CMake project :variable:`CPACK_BUILD_SOURCE_DIRS` is set by default to
# point to :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR` paths.
#
# .. note::
#
# Sources with path prefixes that do not fall under any location provided with
# :variable:`CPACK_BUILD_SOURCE_DIRS` will not be present in debuginfo package.
#
# .. variable:: CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX
# CPACK_RPM_<component>_BUILD_SOURCE_DIRS_PREFIX
#
# Prefix of location where sources will be placed during package installation.
#
# * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
# * Default : "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>" and
# for component packaging "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>-<component>"
#
# .. note::
#
# Each source path prefix is additionaly suffixed by ``src_<index>`` where
# index is index of the path used from :variable:`CPACK_BUILD_SOURCE_DIRS`
# variable. This produces ``<CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX>/src_<index>``
# replacement path.
# Limitation is that replaced path part must be shorter or of equal
# length than the length of its replacement. If that is not the case either
# :variable:`CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX` variable has to be set to
# a shorter path or source directories must be placed on a longer path.
#
# .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS
#
# Directories containing sources that should be excluded from debuginfo packages.
#
# * Mandatory : NO
# * Default : "/usr /usr/src /usr/src/debug"
#
# Listed paths are owned by other RPM packages and should therefore not be
# deleted on debuginfo package uninstallation.
#
# .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION
#
# Paths that should be appended to :variable:`CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS`
# for exclusion.
#
# * Mandatory : NO
# * Default : -
#
2016-09-20 00:44:06 +03:00
# Packaging of sources (SRPM)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
# SRPM packaging is enabled by setting :variable:`CPACK_RPM_PACKAGE_SOURCES`
# variable while usually using :variable:`CPACK_INSTALLED_DIRECTORIES` variable
# to provide directory containing CMakeLists.txt and source files.
#
# For CMake projects SRPM package would be product by executing:
#
# ``cpack -G RPM --config ./CPackSourceConfig.cmake``
#
# .. note::
#
# Produced SRPM package is expected to be built with :manual:`cmake(1)` executable
# and packaged with :manual:`cpack(1)` executable so CMakeLists.txt has to be
# located in root source directory and must be able to generate binary rpm
# packages by executing ``cpack -G`` command. The two executables as well as
# rpmbuild must also be present when generating binary rpm packages from the
# produced SRPM package.
#
# Once the SRPM package is generated it can be used to generate binary packages
# by creating a directory structure for rpm generation and executing rpmbuild
# tool:
#
# ``mkdir -p build_dir/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}``
# ``rpmbuild --define "_topdir <path_to_build_dir>" --rebuild <SRPM_file_name>``
#
# Generated packages will be located in build_dir/RPMS directory or its sub
# directories.
#
# .. note::
#
# SRPM package internally uses CPack/RPM generator to generate binary packages
# so CMakeScripts.txt can decide during the SRPM to binary rpm generation step
# what content the package(s) should have as well as how they should be packaged
# (monolithic or components). CMake can decide this for e.g. by reading environment
# variables set by the package manager before starting the process of generating
# binary rpm packages. This way a single SRPM package can be used to produce
# different binary rpm packages on different platforms depending on the platform's
# packaging rules.
#
# Source RPM packaging has it's own set of variables:
#
# .. variable:: CPACK_RPM_PACKAGE_SOURCES
#
# Should the content be packaged as a source rpm (default is binary rpm).
#
# * Mandatory : NO
# * Default : OFF
#
# .. note::
#
# For cmake projects :variable:`CPACK_RPM_PACKAGE_SOURCES` variable is set
# to ``OFF`` in CPackConfig.cmake and ``ON`` in CPackSourceConfig.cmake
# generated files.
#
# .. variable:: CPACK_RPM_SOURCE_PKG_BUILD_PARAMS
#
# Additional command-line parameters provided to :manual:`cmake(1)` executable.
#
# * Mandatory : NO
# * Default : -
#
# .. variable:: CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX
#
# Packaging install prefix that would be provided in :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
# variable for producing binary RPM packages.
#
# * Mandatory : YES
# * Default : "/"
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
2016-03-29 01:51:18 +03:00
function ( get_unix_permissions_octal_notation PERMISSIONS_VAR RETURN_VAR )
set ( PERMISSIONS ${ ${PERMISSIONS_VAR } } )
list ( LENGTH PERMISSIONS PERM_LEN_PRE )
list ( REMOVE_DUPLICATES PERMISSIONS )
list ( LENGTH PERMISSIONS PERM_LEN_POST )
if ( NOT ${ PERM_LEN_PRE } EQUAL ${ PERM_LEN_POST } )
message ( FATAL_ERROR "${PERMISSIONS_VAR} contains duplicate values." )
endif ( )
foreach ( PERMISSION_TYPE "OWNER" "GROUP" "WORLD" )
set ( ${ PERMISSION_TYPE } _PERMISSIONS 0 )
foreach ( PERMISSION ${ PERMISSIONS } )
if ( "${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_READ" )
math ( EXPR ${ PERMISSION_TYPE } _PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 4" )
elseif ( "${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_WRITE" )
math ( EXPR ${ PERMISSION_TYPE } _PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 2" )
elseif ( "${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_EXECUTE" )
math ( EXPR ${ PERMISSION_TYPE } _PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 1" )
elseif ( PERMISSION MATCHES "${PERMISSION_TYPE}.*" )
message ( FATAL_ERROR "${PERMISSIONS_VAR} contains invalid values." )
endif ( )
endforeach ( )
endforeach ( )
set ( ${ RETURN_VAR } "${OWNER_PERMISSIONS}${GROUP_PERMISSIONS}${WORLD_PERMISSIONS}" PARENT_SCOPE )
endfunction ( )
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 )
2016-02-13 04:09:32 +03:00
elseif ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT_UPPER } _PACKAGE_PREFIX )
file ( TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX}" PATH_PREFIX )
2015-01-21 02:29:46 +03:00
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
2016-02-13 04:09:32 +03:00
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 A N D
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 _ U P P E R } _ I N S T A L L _ P R E F I X _ R E L O C A T I O N )
2016-07-28 01:41:13 +03:00
string ( APPEND TMP_RPM_PREFIXES "Prefix: ${PATH_PREFIX}\n" )
2015-03-20 23:52:49 +03:00
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}" )
2016-07-28 01:41:13 +03:00
string ( APPEND TMP_RPM_PREFIXES "Prefix: ${PREPARED_RELOCATION_PATH}\n" )
2015-01-21 02:29:46 +03:00
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 ( )
2015-04-12 21:50:05 +03:00
function ( cpack_rpm_prepare_content_list )
2015-04-19 19:22:18 +03:00
# get files list
cmake_policy ( PUSH )
cmake_policy ( SET CMP0009 NEW )
file ( GLOB_RECURSE CPACK_RPM_INSTALL_FILES LIST_DIRECTORIES true RELATIVE "${WDIR}" "${WDIR}/*" )
cmake_policy ( POP )
set ( CPACK_RPM_INSTALL_FILES "/${CPACK_RPM_INSTALL_FILES}" )
string ( REPLACE ";" ";/" CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}" )
2015-04-12 21:50:05 +03:00
# 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)
2015-04-19 19:22:18 +03:00
list ( SORT RPM_USED_PACKAGE_PREFIXES )
2015-04-12 21:50:05 +03:00
set ( _DISTINCT_PATH "NOT_SET" )
2015-04-19 19:22:18 +03:00
foreach ( _RPM_RELOCATION_PREFIX ${ RPM_USED_PACKAGE_PREFIXES } )
2015-04-12 21:50:05 +03:00
if ( NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*" )
set ( _DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}" )
2015-04-19 19:22:18 +03:00
string ( REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS " ${_RPM_RELOCATION_PREFIX}" )
2016-09-20 01:17:54 +03:00
cmake_policy ( PUSH )
cmake_policy ( SET CMP0007 NEW )
list ( REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1 )
cmake_policy ( POP )
2015-04-12 21:50:05 +03:00
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}" )
2015-04-19 19:22:18 +03:00
separate_arguments ( _OMIT_DIR )
list ( APPEND _RPM_DIRS_TO_OMIT ${ _OMIT_DIR } )
2015-04-12 21:50:05 +03:00
endforeach ( )
endif ( )
endforeach ( )
endif ( )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}" )
endif ( )
2015-04-19 19:22:18 +03:00
if ( NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST )
2015-04-12 21:50:05 +03:00
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 )
2015-04-19 19:22:18 +03:00
if ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION )
2016-07-11 21:53:31 +03:00
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list." )
endif ( )
2015-04-12 21:50:05 +03:00
list ( APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}" )
endif ( )
endif ( )
if ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST )
2015-04-19 19:22:18 +03:00
if ( CPACK_RPM_PACKAGE_DEBUG )
2015-04-12 21:50:05 +03:00
message ( "CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}" )
endif ( )
2015-04-19 19:22:18 +03:00
list ( APPEND _RPM_DIRS_TO_OMIT ${ CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST } )
2015-04-12 21:50:05 +03:00
endif ( )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}" )
endif ( )
2015-04-19 19:22:18 +03:00
list ( REMOVE_ITEM CPACK_RPM_INSTALL_FILES ${ _RPM_DIRS_TO_OMIT } )
# add man paths that will be compressed
# (copied from /usr/lib/rpm/brp-compress - script that does the actual
# compressing)
list ( APPEND MAN_LOCATIONS "/usr/man/man.*" "/usr/man/.*/man.*" "/usr/info.*"
" / u s r / s h a r e / m a n / m a n . * " " / u s r / s h a r e / m a n / . * / m a n . * " " / u s r / s h a r e / i n f o . * "
" / u s r / k e r b e r o s / m a n . * " " / u s r / X 1 1 R 6 / m a n / m a n . * " " / u s r / l i b / p e r l 5 / m a n / m a n . * "
" / u s r / s h a r e / d o c / . * / m a n / m a n . * " " / u s r / l i b / . * / m a n / m a n . * " )
if ( CPACK_RPM_ADDITIONAL_MAN_DIRS )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: CPACK_RPM_ADDITIONAL_MAN_DIRS= ${CPACK_RPM_ADDITIONAL_MAN_DIRS}" )
endif ( )
list ( APPEND MAN_LOCATIONS ${ CPACK_RPM_ADDITIONAL_MAN_DIRS } )
endif ( )
foreach ( PACK_LOCATION IN LISTS CPACK_RPM_INSTALL_FILES )
foreach ( MAN_LOCATION IN LISTS MAN_LOCATIONS )
# man pages are files inside a certain location
if ( PACK_LOCATION MATCHES "${MAN_LOCATION}/"
A N D N O T I S _ D I R E C T O R Y " $ { W D I R } $ { P A C K _ L O C A T I O N } "
A N D N O T I S _ S Y M L I N K " $ { W D I R } $ { P A C K _ L O C A T I O N } " )
list ( FIND CPACK_RPM_INSTALL_FILES "${PACK_LOCATION}" INDEX )
# insert file location that covers compressed man pages
# even if using a wildcard causes duplicates as those are
# handled by RPM and we still keep the same file list
# in spec file - wildcard only represents file type (e.g. .gz)
list ( INSERT CPACK_RPM_INSTALL_FILES ${ INDEX } "${PACK_LOCATION}*" )
# remove file location that doesn't cover compressed man pages
math ( EXPR INDEX ${ INDEX } +1 )
list ( REMOVE_AT CPACK_RPM_INSTALL_FILES ${ INDEX } )
break ( )
endif ( )
endforeach ( )
endforeach ( )
2015-04-12 21:50:05 +03:00
set ( CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}" PARENT_SCOPE )
endfunction ( )
2015-03-29 21:55:20 +03:00
function ( cpack_rpm_symlink_get_relocation_prefixes LOCATION PACKAGE_PREFIXES RETURN_VARIABLE )
foreach ( PKG_PREFIX IN LISTS PACKAGE_PREFIXES )
string ( REGEX MATCH "^${PKG_PREFIX}/.*" FOUND_ "${LOCATION}" )
if ( FOUND_ )
list ( APPEND TMP_PREFIXES "${PKG_PREFIX}" )
endif ( )
endforeach ( )
set ( ${ RETURN_VARIABLE } "${TMP_PREFIXES}" PARENT_SCOPE )
endfunction ( )
function ( cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES )
list ( LENGTH PACKAGE_PREFIXES LAST_INDEX )
set ( SORTED_PACKAGE_PREFIXES "${PACKAGE_PREFIXES}" )
list ( SORT SORTED_PACKAGE_PREFIXES )
list ( REVERSE SORTED_PACKAGE_PREFIXES )
math ( EXPR LAST_INDEX ${ LAST_INDEX } -1 )
foreach ( SYMLINK_INDEX RANGE ${ LAST_INDEX } )
list ( GET SORTED_PACKAGE_PREFIXES ${ SYMLINK_INDEX } SRC_PATH )
list ( FIND PACKAGE_PREFIXES "${SRC_PATH}" SYMLINK_INDEX ) # reverse magic
string ( LENGTH "${SRC_PATH}" SRC_PATH_LEN )
set ( PARTS_CNT 0 )
set ( SCRIPT_PART "if [ \" $ RPM_INSTALL_PREFIX ${ SYMLINK_INDEX } \" != \"${SRC_PATH}\" ]; then\n " )
# both paths relocated
foreach ( POINT_INDEX RANGE ${ LAST_INDEX } )
list ( GET SORTED_PACKAGE_PREFIXES ${ POINT_INDEX } POINT_PATH )
list ( FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX ) # reverse magic
string ( LENGTH "${POINT_PATH}" POINT_PATH_LEN )
if ( _RPM_RELOCATION_SCRIPT_ ${ SYMLINK_INDEX } _ ${ POINT_INDEX } )
if ( "${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}" )
set ( INDENT "" )
else ( )
2016-07-28 01:41:13 +03:00
string ( APPEND SCRIPT_PART " if [ \" $ RPM_INSTALL_PREFIX ${ POINT_INDEX } \" != \"${POINT_PATH}\" ]; then\n " )
2015-03-29 21:55:20 +03:00
set ( INDENT " " )
endif ( )
foreach ( RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_ ${ SYMLINK_INDEX } _ ${ POINT_INDEX } )
math ( EXPR PARTS_CNT ${ PARTS_CNT } +1 )
math ( EXPR RELOCATION_INDEX ${ RELOCATION_NO } -1 )
list ( GET _RPM_RELOCATION_SCRIPT_PAIRS ${ RELOCATION_INDEX } RELOCATION_SCRIPT_PAIR )
string ( FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX )
math ( EXPR SRC_PATH_END ${ SPLIT_INDEX } - ${ SRC_PATH_LEN } )
string ( SUBSTRING ${ RELOCATION_SCRIPT_PAIR } ${ SRC_PATH_LEN } ${ SRC_PATH_END } SYMLINK_ )
math ( EXPR POINT_PATH_START ${ SPLIT_INDEX } +1+ ${ POINT_PATH_LEN } )
string ( SUBSTRING ${ RELOCATION_SCRIPT_PAIR } ${ POINT_PATH_START } -1 POINT_ )
2016-07-28 01:41:13 +03:00
string ( APPEND SCRIPT_PART " ${INDENT}if [ -z \" $ CPACK_RPM_RELOCATED_SYMLINK_ ${ RELOCATION_INDEX } \" ]; then\n " )
string ( APPEND SCRIPT_PART " ${INDENT}ln -s \" $ RPM_INSTALL_PREFIX ${ POINT_INDEX } ${ POINT_ } \" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n")
string ( APPEND SCRIPT_PART " ${INDENT}CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n" )
string ( APPEND SCRIPT_PART " ${INDENT}fi\n" )
2015-03-29 21:55:20 +03:00
endforeach ( )
if ( NOT "${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}" )
2016-07-28 01:41:13 +03:00
string ( APPEND SCRIPT_PART " fi\n" )
2015-03-29 21:55:20 +03:00
endif ( )
endif ( )
endforeach ( )
# source path relocated
if ( _RPM_RELOCATION_SCRIPT_ ${ SYMLINK_INDEX } _X )
foreach ( RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_ ${ SYMLINK_INDEX } _X )
math ( EXPR PARTS_CNT ${ PARTS_CNT } +1 )
math ( EXPR RELOCATION_INDEX ${ RELOCATION_NO } -1 )
list ( GET _RPM_RELOCATION_SCRIPT_PAIRS ${ RELOCATION_INDEX } RELOCATION_SCRIPT_PAIR )
string ( FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX )
math ( EXPR SRC_PATH_END ${ SPLIT_INDEX } - ${ SRC_PATH_LEN } )
string ( SUBSTRING ${ RELOCATION_SCRIPT_PAIR } ${ SRC_PATH_LEN } ${ SRC_PATH_END } SYMLINK_ )
math ( EXPR POINT_PATH_START ${ SPLIT_INDEX } +1 )
string ( SUBSTRING ${ RELOCATION_SCRIPT_PAIR } ${ POINT_PATH_START } -1 POINT_ )
2016-07-28 01:41:13 +03:00
string ( APPEND SCRIPT_PART " if [ -z \" $ CPACK_RPM_RELOCATED_SYMLINK_ ${ RELOCATION_INDEX } \" ]; then\n " )
string ( APPEND SCRIPT_PART " ln -s \" ${ POINT_ } \" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n")
string ( APPEND SCRIPT_PART " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n" )
string ( APPEND SCRIPT_PART " fi\n" )
2015-03-29 21:55:20 +03:00
endforeach ( )
endif ( )
if ( PARTS_CNT )
set ( SCRIPT "${SCRIPT_PART}" )
2016-07-28 01:41:13 +03:00
string ( APPEND SCRIPT "fi\n" )
2015-03-29 21:55:20 +03:00
endif ( )
endforeach ( )
# point path relocated
foreach ( POINT_INDEX RANGE ${ LAST_INDEX } )
list ( GET SORTED_PACKAGE_PREFIXES ${ POINT_INDEX } POINT_PATH )
list ( FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX ) # reverse magic
string ( LENGTH "${POINT_PATH}" POINT_PATH_LEN )
if ( _RPM_RELOCATION_SCRIPT_X_ ${ POINT_INDEX } )
2016-07-28 01:41:13 +03:00
string ( APPEND SCRIPT "if [ \" $ RPM_INSTALL_PREFIX ${ POINT_INDEX } \" != \"${POINT_PATH}\" ]; then\n " )
2015-03-29 21:55:20 +03:00
foreach ( RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_ ${ POINT_INDEX } )
math ( EXPR RELOCATION_INDEX ${ RELOCATION_NO } -1 )
list ( GET _RPM_RELOCATION_SCRIPT_PAIRS ${ RELOCATION_INDEX } RELOCATION_SCRIPT_PAIR )
string ( FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX )
string ( SUBSTRING ${ RELOCATION_SCRIPT_PAIR } 0 ${ SPLIT_INDEX } SYMLINK_ )
math ( EXPR POINT_PATH_START ${ SPLIT_INDEX } +1+ ${ POINT_PATH_LEN } )
string ( SUBSTRING ${ RELOCATION_SCRIPT_PAIR } ${ POINT_PATH_START } -1 POINT_ )
2016-07-28 01:41:13 +03:00
string ( APPEND SCRIPT " if [ -z \" $ CPACK_RPM_RELOCATED_SYMLINK_ ${ RELOCATION_INDEX } \" ]; then\n " )
string ( APPEND SCRIPT " ln -s \" $ RPM_INSTALL_PREFIX ${ POINT_INDEX } ${ POINT_ } \" \"${SYMLINK_}\"\n")
string ( APPEND SCRIPT " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n" )
string ( APPEND SCRIPT " fi\n" )
2015-03-29 21:55:20 +03:00
endforeach ( )
2016-07-28 01:41:13 +03:00
string ( APPEND SCRIPT "fi\n" )
2015-03-29 21:55:20 +03:00
endif ( )
endforeach ( )
# no path relocated
if ( _RPM_RELOCATION_SCRIPT_X_X )
foreach ( RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_X )
math ( EXPR RELOCATION_INDEX ${ RELOCATION_NO } -1 )
list ( GET _RPM_RELOCATION_SCRIPT_PAIRS ${ RELOCATION_INDEX } RELOCATION_SCRIPT_PAIR )
string ( FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX )
string ( SUBSTRING ${ RELOCATION_SCRIPT_PAIR } 0 ${ SPLIT_INDEX } SYMLINK_ )
math ( EXPR POINT_PATH_START ${ SPLIT_INDEX } +1 )
string ( SUBSTRING ${ RELOCATION_SCRIPT_PAIR } ${ POINT_PATH_START } -1 POINT_ )
2016-07-28 01:41:13 +03:00
string ( APPEND SCRIPT "if [ -z \" $ CPACK_RPM_RELOCATED_SYMLINK_ ${ RELOCATION_INDEX } \" ]; then\n " )
string ( APPEND SCRIPT " ln -s \" ${ POINT_ } \" \"${SYMLINK_}\"\n")
string ( APPEND SCRIPT "fi\n" )
2015-03-29 21:55:20 +03:00
endforeach ( )
endif ( )
set ( RPM_SYMLINK_POSTINSTALL "${SCRIPT}" PARENT_SCOPE )
endfunction ( )
function ( cpack_rpm_symlink_add_for_relocation_script PACKAGE_PREFIXES SYMLINK SYMLINK_RELOCATION_PATHS POINT POINT_RELOCATION_PATHS )
list ( LENGTH SYMLINK_RELOCATION_PATHS SYMLINK_PATHS_COUTN )
list ( LENGTH POINT_RELOCATION_PATHS POINT_PATHS_COUNT )
list ( APPEND _RPM_RELOCATION_SCRIPT_PAIRS "${SYMLINK}:${POINT}" )
list ( LENGTH _RPM_RELOCATION_SCRIPT_PAIRS PAIR_NO )
if ( SYMLINK_PATHS_COUTN )
foreach ( SYMLINK_RELOC_PATH IN LISTS SYMLINK_RELOCATION_PATHS )
list ( FIND PACKAGE_PREFIXES "${SYMLINK_RELOC_PATH}" SYMLINK_INDEX )
# source path relocated
list ( APPEND _RPM_RELOCATION_SCRIPT_ ${ SYMLINK_INDEX } _X "${PAIR_NO}" )
list ( APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X" )
foreach ( POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS )
list ( FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX )
# both paths relocated
list ( APPEND _RPM_RELOCATION_SCRIPT_ ${ SYMLINK_INDEX } _ ${ POINT_INDEX } "${PAIR_NO}" )
list ( APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX}" )
# point path relocated
list ( APPEND _RPM_RELOCATION_SCRIPT_X_ ${ POINT_INDEX } "${PAIR_NO}" )
list ( APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}" )
endforeach ( )
endforeach ( )
elseif ( POINT_PATHS_COUNT )
foreach ( POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS )
list ( FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX )
# point path relocated
list ( APPEND _RPM_RELOCATION_SCRIPT_X_ ${ POINT_INDEX } "${PAIR_NO}" )
list ( APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}" )
endforeach ( )
endif ( )
# no path relocated
list ( APPEND _RPM_RELOCATION_SCRIPT_X_X "${PAIR_NO}" )
list ( APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_X" )
# place variables into parent scope
foreach ( VAR IN LISTS RELOCATION_VARS )
set ( ${ VAR } "${${VAR}}" PARENT_SCOPE )
endforeach ( )
set ( _RPM_RELOCATION_SCRIPT_PAIRS "${_RPM_RELOCATION_SCRIPT_PAIRS}" PARENT_SCOPE )
set ( REQUIRES_SYMLINK_RELOCATION_SCRIPT "true" PARENT_SCOPE )
set ( DIRECTIVE "%ghost " PARENT_SCOPE )
endfunction ( )
function ( cpack_rpm_prepare_install_files INSTALL_FILES_LIST WDIR PACKAGE_PREFIXES IS_RELOCATABLE )
# Prepend directories in ${CPACK_RPM_INSTALL_FILES} with %dir
# This is necessary to avoid duplicate files since rpmbuild does
# recursion on its own when encountering a pathname which is a directory
# which is not flagged as %dir
string ( STRIP "${INSTALL_FILES_LIST}" INSTALL_FILES_LIST )
string ( REPLACE "\n" ";" INSTALL_FILES_LIST
" $ { I N S T A L L _ F I L E S _ L I S T } " )
string ( REPLACE "\" " " " INSTALL_FILES_LIST
" $ { I N S T A L L _ F I L E S _ L I S T } " )
string ( LENGTH "${WDIR}" WDR_LEN_ )
list ( SORT INSTALL_FILES_LIST ) # make file order consistent on all platforms
foreach ( F IN LISTS INSTALL_FILES_LIST )
unset ( DIRECTIVE )
if ( IS_SYMLINK "${WDIR}/${F}" )
if ( IS_RELOCATABLE )
# check that symlink has relocatable format
get_filename_component ( SYMLINK_LOCATION_ "${WDIR}/${F}" DIRECTORY )
execute_process ( COMMAND ls -la "${WDIR}/${F}"
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 S Y M L I N K _ P O I N 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 ( FIND "${SYMLINK_POINT_}" "->" SYMLINK_POINT_INDEX_ REVERSE )
math ( EXPR SYMLINK_POINT_INDEX_ ${ SYMLINK_POINT_INDEX_ } +3 )
string ( LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_ )
# get destination path
string ( SUBSTRING "${SYMLINK_POINT_}" ${ SYMLINK_POINT_INDEX_ } ${ SYMLINK_POINT_LENGTH_ } SYMLINK_POINT_ )
# check if path is relative or absolute
string ( SUBSTRING "${SYMLINK_POINT_}" 0 1 SYMLINK_IS_ABSOLUTE_ )
if ( ${ SYMLINK_IS_ABSOLUTE_ } STREQUAL "/" )
# prevent absolute paths from having /../ or /./ section inside of them
get_filename_component ( SYMLINK_POINT_ "${SYMLINK_POINT_}" ABSOLUTE )
else ( )
# handle relative path
get_filename_component ( SYMLINK_POINT_ "${SYMLINK_LOCATION_}/${SYMLINK_POINT_}" ABSOLUTE )
endif ( )
2016-03-31 08:48:38 +03:00
# recalculate path length after conversion to canonical form
string ( LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_ )
2015-03-29 21:55:20 +03:00
2016-03-31 08:48:38 +03:00
if ( SYMLINK_POINT_ MATCHES "${WDIR}/.*" )
# only symlinks that are pointing inside the packaging structure should be checked for relocation
string ( SUBSTRING "${SYMLINK_POINT_}" ${ WDR_LEN_ } -1 SYMLINK_POINT_WD_ )
cpack_rpm_symlink_get_relocation_prefixes ( "${F}" "${PACKAGE_PREFIXES}" "SYMLINK_RELOCATIONS" )
cpack_rpm_symlink_get_relocation_prefixes ( "${SYMLINK_POINT_WD_}" "${PACKAGE_PREFIXES}" "POINT_RELOCATIONS" )
2015-03-29 21:55:20 +03:00
2016-03-31 08:48:38 +03:00
list ( LENGTH SYMLINK_RELOCATIONS SYMLINK_RELOCATIONS_COUNT )
list ( LENGTH POINT_RELOCATIONS POINT_RELOCATIONS_COUNT )
else ( )
# location pointed to is ouside WDR so it should be treated as a permanent symlink
set ( SYMLINK_POINT_WD_ "${SYMLINK_POINT_}" )
unset ( SYMLINK_RELOCATIONS )
unset ( POINT_RELOCATIONS )
unset ( SYMLINK_RELOCATIONS_COUNT )
unset ( POINT_RELOCATIONS_COUNT )
message ( AUTHOR_WARNING "CPackRPM:Warning: Symbolic link '${F}' points to location that is outside packaging path! Link will possibly not be relocatable." )
endif ( )
2015-03-29 21:55:20 +03:00
if ( SYMLINK_RELOCATIONS_COUNT AND POINT_RELOCATIONS_COUNT )
# find matching
foreach ( SYMLINK_RELOCATION_PREFIX IN LISTS SYMLINK_RELOCATIONS )
list ( FIND POINT_RELOCATIONS "${SYMLINK_RELOCATION_PREFIX}" FOUND_INDEX )
if ( NOT ${ FOUND_INDEX } EQUAL -1 )
break ( )
endif ( )
endforeach ( )
if ( NOT ${ FOUND_INDEX } EQUAL -1 )
# symlinks have the same subpath
if ( ${ SYMLINK_RELOCATIONS_COUNT } EQUAL 1 AND ${ POINT_RELOCATIONS_COUNT } EQUAL 1 )
# permanent symlink
get_filename_component ( SYMLINK_LOCATION_ "${F}" DIRECTORY )
file ( RELATIVE_PATH FINAL_PATH_ ${ SYMLINK_LOCATION_ } ${ SYMLINK_POINT_WD_ } )
execute_process ( COMMAND "${CMAKE_COMMAND}" -E create_symlink "${FINAL_PATH_}" "${WDIR}/${F}" )
else ( )
# relocation subpaths
cpack_rpm_symlink_add_for_relocation_script ( "${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
" $ { S Y M L I N K _ P O I N T _ W D _ } " " $ { P O I N T _ R E L O C A T I O N S } " )
endif ( )
else ( )
# not on the same relocation path
cpack_rpm_symlink_add_for_relocation_script ( "${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
" $ { S Y M L I N K _ P O I N T _ W D _ } " " $ { P O I N T _ R E L O C A T I O N S } " )
endif ( )
elseif ( POINT_RELOCATIONS_COUNT )
# point is relocatable
cpack_rpm_symlink_add_for_relocation_script ( "${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
" $ { S Y M L I N K _ P O I N T _ W D _ } " " $ { P O I N T _ R E L O C A T I O N S } " )
else ( )
# is not relocatable or points to non relocatable path - permanent symlink
execute_process ( COMMAND "${CMAKE_COMMAND}" -E create_symlink "${SYMLINK_POINT_WD_}" "${WDIR}/${F}" )
endif ( )
endif ( )
elseif ( IS_DIRECTORY "${WDIR}/${F}" )
set ( DIRECTIVE "%dir " )
endif ( )
2016-07-28 01:41:13 +03:00
string ( APPEND INSTALL_FILES "${DIRECTIVE}\" ${ F } \"\n")
2015-03-29 21:55:20 +03:00
endforeach ( )
if ( REQUIRES_SYMLINK_RELOCATION_SCRIPT )
cpack_rpm_symlink_create_relocation_script ( "${PACKAGE_PREFIXES}" )
endif ( )
set ( RPM_SYMLINK_POSTINSTALL "${RPM_SYMLINK_POSTINSTALL}" PARENT_SCOPE )
set ( CPACK_RPM_INSTALL_FILES "${INSTALL_FILES}" 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
2016-08-23 00:40:15 +03:00
# We need to check if the binaries were compiled with debug symbols
# because without them the package will be useless
function ( cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR )
2016-09-20 01:41:33 +03:00
if ( NOT CPACK_BUILD_SOURCE_DIRS )
message ( FATAL_ERROR "CPackRPM: CPACK_BUILD_SOURCE_DIRS variable is not set!"
" R e q u i r e d f o r d e b u g i n f o p a c k a g i n g . S e e d o c u m e n t a t i o n o f "
" C P A C K _ R P M _ D E B U G I N F O _ P A C K A G E v a r i a b l e f o r d e t a i l s . " )
endif ( )
2016-08-23 00:40:15 +03:00
# With objdump we should check the debug symbols
find_program ( OBJDUMP_EXECUTABLE objdump )
if ( NOT OBJDUMP_EXECUTABLE )
2016-09-20 01:41:33 +03:00
message ( FATAL_ERROR "CPackRPM: objdump binary could not be found!"
" R e q u i r e d f o r d e b u g i n f o p a c k a g i n g . S e e d o c u m e n t a t i o n o f "
" C P A C K _ R P M _ D E B U G I N F O _ P A C K A G E v a r i a b l e f o r d e t a i l s . " )
2016-08-23 00:40:15 +03:00
endif ( )
2016-09-20 01:41:33 +03:00
# With debugedit we prepare source files list
find_program ( DEBUGEDIT_EXECUTABLE debugedit "/usr/lib/rpm/" )
if ( NOT DEBUGEDIT_EXECUTABLE )
message ( FATAL_ERROR "CPackRPM: debugedit binary could not be found!"
" R e q u i r e d f o r d e b u g i n f o p a c k a g i n g . S e e d o c u m e n t a t i o n o f "
" C P A C K _ R P M _ D E B U G I N F O _ P A C K A G E v a r i a b l e f o r d e t a i l s . " )
endif ( )
unset ( mkdir_list_ )
unset ( cp_list_ )
unset ( additional_sources_ )
2016-08-23 00:40:15 +03:00
foreach ( F IN LISTS INSTALL_FILES )
2016-09-20 01:41:33 +03:00
if ( IS_DIRECTORY "${WORKING_DIR}/${F}" OR IS_SYMLINK "${WORKING_DIR}/${F}" )
continue ( )
endif ( )
2016-08-23 00:40:15 +03:00
execute_process ( COMMAND "${OBJDUMP_EXECUTABLE}" -h ${ WORKING_DIR } / ${ F }
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 } "
R E S U L T _ V A R I A B L E O B J D U M P _ E X E C _ R E S U L T
2016-10-05 23:31:41 +03:00
O U T P U T _ V A R I A B L E O B J D U M P _ O U T
E R R O R _ Q U I E T )
2016-08-23 00:40:15 +03:00
# Check that if the given file was executable or not
if ( NOT OBJDUMP_EXEC_RESULT )
string ( FIND "${OBJDUMP_OUT}" "debug" FIND_RESULT )
2016-09-20 01:41:33 +03:00
if ( FIND_RESULT GREATER -1 )
set ( index_ 0 )
foreach ( source_dir_ IN LISTS CPACK_BUILD_SOURCE_DIRS )
string ( LENGTH "${source_dir_}" source_dir_len_ )
string ( LENGTH "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}" debuginfo_dir_len )
if ( source_dir_len_ LESS debuginfo_dir_len )
message ( FATAL_ERROR "CPackRPM: source dir path '${source_dir_}' is"
" l o n g e r t h a n d e b u g i n f o s o u r c e s d i r p a t h ' $ { C P A C K _ R P M _ B U I L D _ S O U R C E _ D I R S _ P R E F I X } / s r c _ $ { i n d e x _ } ' ! "
" S o u r c e d i r p a t h m u s t b e s h o r t e r t h a n d e b u g i n f o s o u r c e s d i r p a t h . "
" S e t C P A C K _ R P M _ B U I L D _ S O U R C E _ D I R S _ P R E F I X v a r i a b l e t o a s h o r t e r v a l u e "
" o r m a k e s o u r c e d i r p a t h l o n g e r . "
" R e q u i r e d f o r d e b u g i n f o p a c k a g i n g . S e e d o c u m e n t a t i o n o f "
" C P A C K _ R P M _ D E B U G I N F O _ P A C K A G E v a r i a b l e f o r d e t a i l s . " )
endif ( )
file ( REMOVE "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list" )
execute_process ( COMMAND "${DEBUGEDIT_EXECUTABLE}" -b "${source_dir_}" -d "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}" -i -l "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list" "${WORKING_DIR}/${F}"
R E S U L T _ V A R I A B L E r e s _
O U T P U T _ V A R I A B L E o p t _
E R R O R _ V A R I A B L E e r r _
)
file ( STRINGS
" $ { 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 } / d e b u g s o u r c e s _ a d d . l i s t "
s o u r c e s _ )
list ( REMOVE_DUPLICATES sources_ )
foreach ( source_ IN LISTS sources_ )
if ( EXISTS "${source_dir_}/${source_}" AND NOT IS_DIRECTORY "${source_dir_}/${source_}" )
get_filename_component ( path_part_ "${source_}" DIRECTORY )
list ( APPEND mkdir_list_ "%{buildroot}${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${path_part_}" )
list ( APPEND cp_list_ "cp \" ${ source_dir_ } / ${ source_ } \" \"%{buildroot}${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${path_part_}\"")
list ( APPEND additional_sources_ "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${source_}" )
endif ( )
endforeach ( )
math ( EXPR index_ "${index_} + 1" )
endforeach ( )
else ( )
2016-08-23 00:40:15 +03:00
message ( WARNING "CPackRPM: File: ${F} does not contain debug symbols. They will possibly be missing from debuginfo package!" )
endif ( )
endif ( )
endforeach ( )
2016-09-20 01:41:33 +03:00
2016-10-06 09:04:58 +03:00
list ( LENGTH mkdir_list_ len_ )
if ( len_ )
list ( REMOVE_DUPLICATES mkdir_list_ )
unset ( TMP_RPM_DEBUGINFO_INSTALL )
foreach ( part_ IN LISTS mkdir_list_ )
string ( APPEND TMP_RPM_DEBUGINFO_INSTALL "mkdir -p \" ${ part_ } \"\n")
endforeach ( )
endif ( )
2016-09-20 01:41:33 +03:00
2016-10-06 09:04:58 +03:00
list ( LENGTH cp_list_ len_ )
if ( len_ )
list ( REMOVE_DUPLICATES cp_list_ )
foreach ( part_ IN LISTS cp_list_ )
string ( APPEND TMP_RPM_DEBUGINFO_INSTALL "${part_}\n" )
endforeach ( )
endif ( )
2016-09-20 01:41:33 +03:00
2016-09-22 19:34:54 +03:00
if ( NOT DEFINED CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS )
set ( CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS /usr /usr/src /usr/src/debug )
if ( CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Adding ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION} to builtin omit list." )
endif ( )
list ( APPEND CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS "${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION}" )
endif ( )
endif ( )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS= ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS}" )
endif ( )
2016-10-06 09:04:58 +03:00
list ( LENGTH additional_sources_ len_ )
if ( len_ )
list ( REMOVE_DUPLICATES additional_sources_ )
unset ( additional_sources_all_ )
foreach ( source_ IN LISTS additional_sources_ )
string ( REPLACE "/" ";" split_source_ " ${source_}" )
list ( REMOVE_AT split_source_ 0 )
unset ( tmp_path_ )
# Now generate all segments of the path
foreach ( segment_ IN LISTS split_source_ )
string ( APPEND tmp_path_ "/${segment_}" )
list ( APPEND additional_sources_all_ "${tmp_path_}" )
endforeach ( )
2016-09-22 19:34:54 +03:00
endforeach ( )
2016-10-06 09:04:58 +03:00
list ( REMOVE_DUPLICATES additional_sources_all_ )
list ( REMOVE_ITEM additional_sources_all_
$ { C P A C K _ R P M _ D E B U G I N F O _ E X C L U D E _ D I R S } )
2016-09-22 19:34:54 +03:00
2016-10-06 09:04:58 +03:00
unset ( TMP_DEBUGINFO_ADDITIONAL_SOURCES )
foreach ( source_ IN LISTS additional_sources_all_ )
string ( APPEND TMP_DEBUGINFO_ADDITIONAL_SOURCES "${source_}\n" )
endforeach ( )
endif ( )
2016-09-20 01:41:33 +03:00
set ( TMP_RPM_DEBUGINFO_INSTALL "${TMP_RPM_DEBUGINFO_INSTALL}" PARENT_SCOPE )
2016-10-06 09:04:58 +03:00
set ( TMP_DEBUGINFO_ADDITIONAL_SOURCES "${TMP_DEBUGINFO_ADDITIONAL_SOURCES}"
P A R E N T _ S C O P E )
2016-08-23 00:40:15 +03:00
endfunction ( )
2016-02-13 04:09:32 +03:00
function ( cpack_rpm_variable_fallback OUTPUT_VAR_NAME )
set ( FALLBACK_VAR_NAMES ${ ARGN } )
foreach ( variable_name IN LISTS FALLBACK_VAR_NAMES )
if ( ${ variable_name } )
set ( ${ OUTPUT_VAR_NAME } "${${variable_name}}" PARENT_SCOPE )
break ( )
endif ( )
endforeach ( )
endfunction ( )
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 )
string ( TOUPPER ${ CPACK_RPM_PACKAGE_COMPONENT } CPACK_RPM_PACKAGE_COMPONENT_UPPER )
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)
if ( CPACK_RPM_PACKAGE_COMPONENT )
2016-02-13 04:09:32 +03:00
cpack_rpm_variable_fallback ( "CPACK_RPM_PACKAGE_SUMMARY"
" C P A C K _ R P M _ $ { 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 C K A G E _ S U M M A R Y "
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ P A C K A G E _ S U M M A R Y " )
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-12-07 21:11:51 +03:00
if ( CPACK_RPM_PACKAGE_COMPONENT )
2016-07-28 01:41:13 +03:00
string ( APPEND CPACK_RPM_PACKAGE_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}" )
2016-02-13 04:09:32 +03:00
cpack_rpm_variable_fallback ( "CPACK_RPM_PACKAGE_NAME"
" C P A C K _ R P M _ $ { 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 C K A G E _ N A M E "
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ P A C K A G E _ N A M E " )
2015-12-07 21:11:51 +03:00
endif ( )
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
if ( CPACK_RPM_PACKAGE_COMPONENT )
2016-02-13 04:09:32 +03:00
cpack_rpm_variable_fallback ( "CPACK_RPM_PACKAGE_ARCHITECTURE"
" C P A C K _ R P M _ $ { 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 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 _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ P A C K A G E _ A R C H I T E C T U R E " )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: using component build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}" )
2015-03-17 00:17:17 +03:00
endif ( )
endif ( )
2016-02-13 04:09:32 +03:00
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 )
2016-05-11 12:21:11 +03:00
set ( CPACK_RPM_PACKAGE_RELEASE "1" )
endif ( )
if ( CPACK_RPM_PACKAGE_RELEASE_DIST )
2016-07-28 01:41:13 +03:00
string ( APPEND CPACK_RPM_PACKAGE_RELEASE "%{?dist}" )
2015-03-17 00:17:17 +03:00
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
2015-12-07 21:11:51 +03:00
if ( CPACK_RPM_PACKAGE_COMPONENT )
2016-02-13 04:09:32 +03:00
cpack_rpm_variable_fallback ( "CPACK_RPM_PACKAGE_GROUP"
" C P A C K _ R P M _ $ { 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 C K A G E _ G R O U P "
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ P A C K A G E _ G R O U P " )
2015-12-07 21:11:51 +03:00
endif ( )
2015-03-17 00:17:17 +03:00
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
#
if ( CPACK_RPM_PACKAGE_COMPONENT )
2016-02-13 04:09:32 +03:00
cpack_rpm_variable_fallback ( "CPACK_RPM_PACKAGE_DESCRIPTION"
" C P A C K _ R P M _ $ { 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 C K A G E _ D E S C R I P T I O N "
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ P A C K A G E _ D E S C R I P T I O N "
" C P A C K _ C O M P O N E N T _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ D E S C R I P T I O N " )
2015-03-17 00:17:17 +03:00
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
2016-09-20 00:44:06 +03:00
if ( NOT CPACK_RPM_PACKAGE_SOURCES )
if ( CPACK_PACKAGE_RELOCATABLE OR CPACK_RPM_PACKAGE_RELOCATABLE )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: Trying to build a relocatable package" )
endif ( )
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." )
set ( CPACK_RPM_PACKAGE_RELOCATABLE FALSE )
else ( )
set ( CPACK_RPM_PACKAGE_PREFIX ${ CPACK_PACKAGING_INSTALL_PREFIX } ) # kept for back compatibility (provided external RPM spec files)
cpack_rpm_prepare_relocation_paths ( )
set ( CPACK_RPM_PACKAGE_RELOCATABLE TRUE )
endif ( )
2012-08-13 21:50:14 +04:00
endif ( )
2016-09-20 00:44:06 +03:00
else ( )
if ( CPACK_RPM_PACKAGE_COMPONENT )
message ( FATAL_ERROR "CPACK_RPM_PACKAGE_SOURCES parameter can not be used"
" i n c o m b i n a t i o n w i t h 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 a m e t e r ! " )
2015-03-17 00:17:17 +03:00
endif ( )
2016-09-20 00:44:06 +03:00
set ( CPACK_RPM_PACKAGE_RELOCATABLE FALSE ) # disable relocatable option if building source RPM
2015-03-17 00:17:17 +03:00
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 )
2016-02-13 04:09:32 +03:00
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}" )
endif ( )
if ( CPACK_RPM_PACKAGE_COMPONENT )
cpack_rpm_variable_fallback ( "CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}"
" C P A C K _ R P M _ $ { 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 C K A G E _ $ { _ R P M _ S P E C _ H E A D E R } "
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ P A C K A G E _ $ { _ R P M _ S P E C _ H E A D E R } " )
endif ( )
if ( DEFINED CPACK_RPM_PACKAGE_ ${ _RPM_SPEC_HEADER } )
2015-03-17 00:17:17 +03:00
if ( CPACK_RPM_PACKAGE_DEBUG )
2016-02-13 04:09:32 +03:00
message ( "CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}" )
2015-03-17 00:17:17 +03:00
endif ( )
2016-02-13 04:09:32 +03:00
set ( CPACK_RPM_PACKAGE_ ${ _RPM_SPEC_HEADER } _TMP ${ CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER } } )
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 )
2016-07-28 01:41:13 +03:00
string ( APPEND _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_TAIL}" )
2015-03-17 00:17:17 +03:00
# 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}" )
2016-07-28 01:41:13 +03:00
string ( APPEND _PACKAGE_HEADER_NAME ")" )
2015-03-17 00:17:17 +03:00
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
2016-02-13 04:09:32 +03: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
2016-02-13 04:09:32 +03:00
foreach ( RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL" )
foreach ( RPM_SCRIPT_FILE_TIME_ "PRE" "POST" )
set ( "CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
" $ { C P A C K _ R P M _ $ { R P M _ S C R I P T _ F I L E _ T I M E _ } _ $ { R P M _ S C R I P T _ F I L E _ T Y P E _ } _ S C R I P T _ F I L E } " )
2011-11-05 14:40:47 +04:00
2016-02-13 04:09:32 +03:00
if ( CPACK_RPM_PACKAGE_COMPONENT )
cpack_rpm_variable_fallback ( "CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T } _ $ { R P M _ S C R I P T _ F I L E _ T I M E _ } _ $ { R P M _ S C R I P T _ F I L E _ T Y P E _ } _ S C R I P T _ F I L E "
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ $ { R P M _ S C R I P T _ F I L E _ T I M E _ } _ $ { R P M _ S C R I P T _ F I L E _ T Y P E _ } _ S C R I P T _ F I L E " )
endif ( )
2011-09-20 22:21:01 +04:00
2016-02-13 04:09:32 +03:00
# Handle file if it has been specified
if ( CPACK_RPM_ ${ RPM_SCRIPT_FILE_TIME_ } _ ${ RPM_SCRIPT_FILE_TYPE_ } _READ_FILE )
if ( EXISTS ${ CPACK_RPM_${RPM_SCRIPT_FILE_TIME_ } _ ${ RPM_SCRIPT_FILE_TYPE_ } _READ_FILE} )
file ( READ ${ CPACK_RPM_${RPM_SCRIPT_FILE_TIME_ } _ ${ RPM_SCRIPT_FILE_TYPE_ } _READ_FILE}
" C P A C K _ R P M _ S P E C _ $ { R P M _ S C R I P T _ F I L E _ T I M E _ } $ { R P M _ S C R I P T _ F I L E _ T Y P E _ } " )
else ( )
message ( "CPackRPM:Warning: CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE <${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}> does not exists - ignoring" )
endif ( )
else ( )
# reset SPEC var value if no file has been specified
# (either globally or component-wise)
set ( "CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}" "" )
endif ( )
endforeach ( )
endforeach ( )
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 )
# 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}" )
2015-04-12 21:50:05 +03:00
cpack_rpm_prepare_content_list ( )
2015-03-17 00:17:17 +03:00
# 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 )
2016-02-13 04:09:32 +03:00
cpack_rpm_variable_fallback ( "COMPONENT_FILES_TAG"
" C P A C K _ A B S O L U T E _ D E S T I N A T I O N _ F I L E S _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T } "
" C P A C K _ A B S O L U T E _ D E S T I N A T I O N _ F I L E S _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } " )
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 ( )
2015-03-17 00:17:17 +03:00
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.
2016-02-13 04:09:32 +03:00
set ( CPACK_RPM_USER_FILELIST_INTERNAL "" )
2015-03-17 00:17:17 +03:00
if ( CPACK_RPM_PACKAGE_COMPONENT )
2016-02-13 04:09:32 +03:00
cpack_rpm_variable_fallback ( "CPACK_RPM_USER_FILELIST_INTERNAL"
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T } _ U S E R _ F I L E L I S T "
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ U S E R _ F I L E L I S T " )
if ( CPACK_RPM_PACKAGE_DEBUG AND CPACK_RPM_USER_FILELIST_INTERNAL )
message ( "CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>" )
message ( "CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}" )
2015-03-17 00:17:17 +03:00
endif ( )
2016-02-13 04:09:32 +03:00
elseif ( CPACK_RPM_USER_FILELIST )
set ( CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}" )
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 )
2016-06-24 20:45:40 +03:00
string ( REGEX REPLACE "%[A-Za-z]+(\\([^()]*\\))? " "" F_PATH ${ F } )
string ( REGEX MATCH "%[A-Za-z]+(\\([^()]*\\))?" F_PREFIX ${ F } )
2015-03-17 00:17:17 +03:00
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: F_PREFIX=<${F_PREFIX}>, F_PATH=<${F_PATH}>" )
endif ( )
if ( F_PREFIX )
2016-07-28 01:41:13 +03:00
string ( APPEND F_PREFIX " " )
2015-03-17 00:17:17 +03:00
endif ( )
# Rebuild the user list file
2016-07-28 01:41:13 +03:00
string ( APPEND CPACK_RPM_USER_INSTALL_FILES "${F_PREFIX}\" ${ F_PATH } \"\n")
2015-03-17 00:17:17 +03:00
# 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 )
2016-07-28 01:41:13 +03:00
string ( APPEND CPACK_RPM_INSTALL_FILES "\" ${ F } \"\n")
2015-03-17 00:17:17 +03:00
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 )
2016-07-28 01:41:13 +03:00
string ( APPEND CPACK_RPM_INSTALL_FILES "\" ${ F } \"\n")
2015-03-17 00:17:17 +03:00
endforeach ( )
# Build ABSOLUTE_INSTALL_FILES
set ( CPACK_RPM_ABSOLUTE_INSTALL_FILES "" )
foreach ( F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL )
2016-07-28 01:41:13 +03:00
string ( APPEND CPACK_RPM_ABSOLUTE_INSTALL_FILES "%config \" ${ F } \"\n")
2015-03-17 00:17:17 +03:00
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 ( )
2016-09-20 01:41:33 +03:00
cpack_rpm_variable_fallback ( "CPACK_RPM_DEBUGINFO_PACKAGE"
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T } _ D E B U G I N F O _ P A C K A G E "
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ D E B U G I N F O _ P A C K A G E "
" C P A C K _ R P M _ D E B U G I N F O _ P A C K A G E " )
if ( CPACK_RPM_DEBUGINFO_PACKAGE )
cpack_rpm_variable_fallback ( "CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX"
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T } _ B U I L D _ S O U R C E _ D I R S _ P R E F I X "
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ B U I L D _ S O U R C E _ D I R S _ P R E F I X "
" C P A C K _ R P M _ B U I L D _ S O U R C E _ D I R S _ P R E F I X " )
if ( NOT CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX )
set ( CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" )
endif ( )
cpack_rpm_debugsymbol_check ( "${CPACK_RPM_INSTALL_FILES}" "${WDIR}" )
set ( TMP_RPM_DEBUGINFO "
# Modified version of %%debug_package macro
# defined in /usr/lib/rpm/macros as that one
# can't handle injection of extra source files.
% i f n a r c h n o a r c h
% g l o b a l _ _ d e b u g _ p a c k a g e 1
% p a c k a g e d e b u g i n f o
S u m m a r y : D e b u g i n f o r m a t i o n f o r p a c k a g e % { n a m e }
G r o u p : D e v e l o p m e n t / D e b u g
A u t o R e q P r o v : 0
% d e s c r i p t i o n d e b u g i n f o
T h i s p a c k a g e p r o v i d e s d e b u g i n f o r m a t i o n f o r p a c k a g e % { n a m e } .
D e b u g i n f o r m a t i o n i s u s e f u l w h e n d e v e l o p i n g a p p l i c a t i o n s t h a t u s e t h i s
p a c k a g e o r w h e n d e b u g g i n g t h i s p a c k a g e .
% f i l e s d e b u g i n f o - f d e b u g f i l e s . l i s t
% defattr ( -,root,root )
$ { T M P _ D E B U G I N F O _ A D D I T I O N A L _ S O U R C E S }
% e n d i f
" )
endif ( )
2015-03-29 21:55:20 +03:00
# Prepare install files
cpack_rpm_prepare_install_files (
" $ { C P A C K _ R P M _ I N S T A L L _ F I L E S } "
" $ { W D I R } "
" $ { R P M _ U S E D _ P A C K A G E _ P R E F I X E S } "
" $ { C P A C K _ R P M _ P A C K A G E _ R E L O C A T A B L E } "
)
2011-04-17 19:12:38 +04:00
2016-03-29 01:51:18 +03:00
# set default user and group
foreach ( _PERM_TYPE "USER" "GROUP" )
if ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT_UPPER } _DEFAULT_ ${ _PERM_TYPE } )
set ( TMP_DEFAULT_ ${ _PERM_TYPE } "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}}" )
elseif ( CPACK_RPM_DEFAULT_ ${ _PERM_TYPE } )
set ( TMP_DEFAULT_ ${ _PERM_TYPE } "${CPACK_RPM_DEFAULT_${_PERM_TYPE}}" )
else ( )
set ( TMP_DEFAULT_ ${ _PERM_TYPE } "root" )
endif ( )
endforeach ( )
# set default file and dir permissions
foreach ( _PERM_TYPE "FILE" "DIR" )
if ( CPACK_RPM_ ${ CPACK_RPM_PACKAGE_COMPONENT_UPPER } _DEFAULT_ ${ _PERM_TYPE } _PERMISSIONS )
get_unix_permissions_octal_notation ( "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS" )
set ( _PERMISSIONS_VAR "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS" )
elseif ( CPACK_RPM_DEFAULT_ ${ _PERM_TYPE } _PERMISSIONS )
get_unix_permissions_octal_notation ( "CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS" )
set ( _PERMISSIONS_VAR "CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS" )
else ( )
set ( TMP_DEFAULT_ ${ _PERM_TYPE } _PERMISSIONS "-" )
endif ( )
endforeach ( )
2015-03-17 00:17:17 +03:00
# The name of the final spec file to be used by rpmbuild
2015-12-07 21:11:51 +03:00
set ( CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_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.
2016-02-13 04:09:32 +03:00
if ( CPACK_RPM_PACKAGE_COMPONENT )
cpack_rpm_variable_fallback ( "CPACK_RPM_USER_BINARY_SPECFILE"
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T } _ U S E R _ B I N A R Y _ S P E C F I L E "
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ U S E R _ B I N A R Y _ S P E C F I L E " )
2015-03-17 00:17:17 +03:00
endif ( )
2013-04-01 18:06:22 +04:00
2016-05-15 04:01:34 +03:00
cpack_rpm_variable_fallback ( "CPACK_RPM_FILE_NAME"
2016-07-11 12:48:22 +03:00
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T } _ F I L E _ N A M E "
2016-05-15 04:01:34 +03:00
" C P A C K _ R P M _ $ { C P A C K _ R P M _ P A C K A G E _ C O M P O N E N T _ U P P E R } _ F I L E _ N A M E "
" C P A C K _ R P M _ F I L E _ N A M E " )
if ( NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT" )
if ( CPACK_RPM_FILE_NAME )
cmake_policy ( PUSH )
cmake_policy ( SET CMP0010 NEW )
if ( NOT CPACK_RPM_FILE_NAME MATCHES ".*\\.rpm" )
cmake_policy ( POP )
message ( FATAL_ERROR "'${CPACK_RPM_FILE_NAME}' is not a valid RPM package file name as it must end with '.rpm'!" )
endif ( )
cmake_policy ( POP )
else ( )
# old file name format for back compatibility
set ( CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}" )
endif ( )
# else example:
#set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
2016-08-23 00:40:15 +03:00
if ( NOT CPACK_RPM_DEBUGINFO_PACKAGE )
set ( FILE_NAME_DEFINE "%define _rpmfilename ${CPACK_RPM_FILE_NAME}" )
endif ( )
2016-05-15 04:01:34 +03:00
endif ( )
2016-09-20 00:44:06 +03:00
if ( CPACK_RPM_PACKAGE_SOURCES ) # source rpm
set ( archive_name_ "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}" )
execute_process (
C O M M A N D $ { C M A K E _ C O M M A N D } - E t a r " c f v z " " $ { C P A C K _ R P M _ D I R E C T O R Y } / S O U R C E S / $ { a r c h i v e _ n a m e _ } . t a r . g z " " $ { C P A C K _ P A C K A G E _ F I L E _ N A M E } "
W O R K I N G _ D I R E C T O R Y $ { C P A C K _ R P M _ D I R E C T O R Y }
)
set ( TMP_RPM_SOURCE "Source: ${archive_name_}.tar.gz" )
if ( CPACK_RPM_BUILDREQUIRES )
set ( TMP_RPM_BUILD_REQUIRES "BuildRequires: ${CPACK_RPM_BUILDREQUIRES}" )
endif ( )
# Disable debuginfo packages - srpm generates invalid packages due to
# releasing controll to cpack to generate binary packages.
# Note however that this doesn't prevent cpack to generate debuginfo
# packages when run from srpm with --rebuild.
set ( TMP_RPM_DISABLE_DEBUGINFO "%define debug_package %{nil}" )
if ( NOT CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX )
set ( CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX "/" )
endif ( )
set ( TMP_RPM_BUILD
"
% b u i l d
m k d i r c p a c k _ r p m _ b u i l d _ d i r
c d c p a c k _ r p m _ b u i l d _ d i r
c m a k e $ { C P A C K _ R P M _ S O U R C E _ P K G _ B U I L D _ P A R A M S } - D C P A C K _ P A C K A G I N G _ I N S T A L L _ P R E F I X = $ { C P A C K _ R P M _ S O U R C E _ P K G _ P A C K A G I N G _ I N S T A L L _ P R E F I X } . . / $ { C P A C K _ P A C K A G E _ F I L E _ N A M E }
m a k e % { ? _ s m p _ m f l a g s } " # %{?_smp_mflags} -> -j option
)
set ( TMP_RPM_INSTALL
"
c d c p a c k _ r p m _ b u i l d _ d i r
c p a c k - G R P M
m v * . r p m % _ r p m d i r "
)
set ( TMP_RPM_PREP "%setup -c" )
set ( RPMBUILD_FLAGS "-bs" )
2015-03-17 00:17:17 +03:00
file ( WRITE ${ CPACK_RPM_BINARY_SPECFILE } .in
2009-11-10 00:17:22 +03:00
" # -*- rpm-spec -*-
2016-09-20 00:44:06 +03:00
B u i l d R o o t : % _ t o p d i r / \ @ C P A C K _ P A C K A G E _ F I L E _ N A M E \ @
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 \ @
2015-12-07 21:11:51 +03:00
N a m e : \ @ C P A C K _ R P M _ P A C K A G E _ 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 \ @
2016-09-20 00:44:06 +03:00
\ @ T M P _ R P M _ S O U R C E \ @
\ @ T M P _ R P M _ B U I L D _ R E Q U I R E S \ @
\ @ T M P _ R P M _ B U I L D A R C H \ @
\ @ T M P _ R P M _ P R E F I X E S \ @
\ @ T M P _ R P M _ D I S A B L E _ D E B U G I N F O \ @
% d e f i n e _ r p m d i r % _ t o p d i r / R P M S
% d e f i n e _ s r c r p m d i r % _ t o p d i r / S R P M S
\ @ F I L E _ N A M E _ D E F I N E \ @
% 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
\ @ 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 \ @
\ @ 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 \ @
% d e s c r i p t i o n
\ @ 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 \ @
# 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
\ @ T M P _ R P M _ P R E P \ @
\ @ T M P _ R P M _ B U I L D \ @
#p build
% i n s t a l l
\ @ T M P _ R P M _ I N S T A L L \ @
% c l e a n
% c h a n g e l o g
\ @ C P A C K _ R P M _ S P E C _ C H A N G E L O G \ @
"
)
else ( ) # binary rpm
# 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 )
set ( RPMBUILD_FLAGS "-bb" )
file ( WRITE ${ CPACK_RPM_BINARY_SPECFILE } .in
" # -*- rpm-spec -*-
B u i l d R o o t : % _ t o p d i r / \ @ 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 \ @
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 \ @
N a m e : \ @ C P A C K _ R P M _ P A C K A G E _ N A M E \ @
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
2016-08-23 00:40:15 +03:00
\ @ T M P _ R P M _ D E B U G I N F O \ @
2016-09-20 00:44:06 +03:00
% d e f i n e _ r p m d i r % _ t o p d i r / R P M S
% d e f i n e _ s r c r p m d i r % _ t o p d i r / S R P M S
2016-05-15 04:01:34 +03:00
\ @ F I L E _ N A M E _ D E F I N 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
\ @ 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
2016-09-20 00:44:06 +03:00
m v $ R P M _ B U I L D _ R O O T % _ t o p d i r / t m p B B r o o t
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
2016-09-20 00:44:06 +03:00
m v % _ t o p d i r / 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
2016-09-20 01:41:33 +03:00
\ @ T M P _ R P M _ D E B U G I N F O _ I N S T A L L \ @
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
2015-03-29 21:55:20 +03:00
\ @ R P M _ S Y M L I N K _ P O S T I N S T A L L \ @
2009-11-11 23:55:44 +03:00
\ @ 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
2016-03-29 01:51:18 +03:00
% defattr ( \@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@)
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 \ @
2016-09-20 00:44:06 +03:00
"
)
endif ( )
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 )
2016-08-23 00:40:15 +03:00
message ( FATAL_ERROR "CPackRPM: STOP here Generated USER binary spec file template is: ${CPACK_RPM_BINARY_SPECFILE}.in" )
2015-03-17 00:17:17 +03:00
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 (
2016-09-20 00:44:06 +03: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 } " $ { R P M B U I L D _ F L A G S }
2015-03-17 00:17:17 +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 } "
2016-09-20 01:41:33 +03:00
- - b u i l d r o o t " % _ t o p d i r / $ { 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 } "
2016-02-13 04:09:32 +03:00
- - 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 } "
2015-03-17 00:17:17 +03:00
" $ { 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
2015-12-07 21:11:51 +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 _ 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 _ N A M E } . o u t " )
2015-03-17 00:17:17 +03:00
if ( CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT )
2015-12-07 21:11:51 +03:00
file ( READ ${ CPACK_TOPLEVEL_DIRECTORY } /rpmbuild ${ CPACK_RPM_PACKAGE_NAME } .err RPMBUILDERR )
file ( READ ${ CPACK_TOPLEVEL_DIRECTORY } /rpmbuild ${ CPACK_RPM_PACKAGE_NAME } .out RPMBUILDOUT )
2015-03-17 00:17:17 +03:00
message ( "CPackRPM:Debug: You may consult rpmbuild logs in: " )
2015-12-07 21:11:51 +03:00
message ( "CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err" )
2015-03-17 00:17:17 +03:00
message ( "CPackRPM:Debug: *** ${RPMBUILDERR} ***" )
2015-12-07 21:11:51 +03:00
message ( "CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out" )
2015-05-05 08:47:10 +03:00
message ( "CPackRPM:Debug: *** ${RPMBUILDOUT} ***" )
2015-03-17 00:17:17 +03:00
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 ( )
2016-05-15 04:01:34 +03:00
# find generated rpm files and take their names
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 )
2016-09-20 00:44:06 +03:00
file ( GLOB_RECURSE GENERATED_FILES "${CPACK_RPM_DIRECTORY}/RPMS/*.rpm"
" $ { C P A C K _ R P M _ D I R E C T O R Y } / S R P M S / * . r p m " )
2016-05-15 04:01:34 +03:00
cmake_policy ( POP )
if ( NOT GENERATED_FILES )
message ( FATAL_ERROR "RPM package was not generated! ${CPACK_RPM_DIRECTORY}" )
endif ( )
2016-08-23 00:40:15 +03:00
if ( CPACK_RPM_DEBUGINFO_PACKAGE AND NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT" )
string ( TOLOWER "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm" EXPECTED_FILENAME )
foreach ( F IN LISTS GENERATED_FILES )
if ( F MATCHES ".*/${EXPECTED_FILENAME}" )
get_filename_component ( FILE_PATH "${F}" DIRECTORY )
file ( RENAME "${F}" "${FILE_PATH}/${CPACK_RPM_FILE_NAME}" )
list ( APPEND new_files_list_ "${FILE_PATH}/${CPACK_RPM_FILE_NAME}" )
else ( )
list ( APPEND new_files_list_ "${F}" )
endif ( )
endforeach ( )
set ( GENERATED_FILES "${new_files_list_}" )
endif ( )
2016-05-15 04:01:34 +03:00
set ( GEN_CPACK_OUTPUT_FILES "${GENERATED_FILES}" PARENT_SCOPE )
if ( CPACK_RPM_PACKAGE_DEBUG )
message ( "CPackRPM:Debug: GEN_CPACK_OUTPUT_FILES = ${GENERATED_FILES}" )
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 ( )