CPack/RPM support for upper cased component variables

CPACK_* variables expect component name in upper case.
CPACK_RPM_* variables expected component name to be
in same case as component name.
This patch adds support for CPACK_RPM_* variables with
upper case component names to match the convention with
CPACK_* variables and also preserves same case component
names for back compatibility.
This commit is contained in:
Domen Vrankar 2016-02-13 02:09:32 +01:00
parent 86d2f32525
commit 7c7efd1ed9
12 changed files with 245 additions and 203 deletions

View File

@ -0,0 +1,15 @@
cpack-rpm-upper-cased-components
--------------------------------
* The "CPackRPM" module now supports upper cased component name
in per component CPackRPM specific variables.
E.g. component named ``foo`` now expects component specific
variable to be ``CPACK_RPM_FOO_PACKAGE_NAME`` while before
it expected ``CPACK_RPM_foo_PACKAGE_NAME``.
Upper cased component name part in variables is compatible
with convention used for other CPack variables.
For back compatibility old format of variables is still valid
and prefered if both versions of variable are set, but the
preferred future use is upper cased component names in variables.
New variables that will be added to CPackRPM in later versions
will only support upper cased component variable format.

View File

@ -7,25 +7,35 @@
# Variables specific to CPack RPM generator # Variables specific to CPack RPM generator
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# #
# CPackRPM may be used to create RPM package using CPack. CPackRPM is a # CPackRPM may be used to create RPM package using CPack.
# CPack generator thus it uses the CPACK_XXX variables used by CPack : # CPackRPM is a CPack generator thus it uses the ``CPACK_XXX`` variables
# https://cmake.org/Wiki/CMake:CPackConfiguration # used by CPack : https://cmake.org/Wiki/CMake:CPackConfiguration.
# #
# However CPackRPM has specific features which are controlled by the # CPackRPM has specific features which are controlled by the specifics
# specifics CPACK_RPM_XXX variables. CPackRPM is a component aware # :code:`CPACK_RPM_XXX` variables.
# generator so when CPACK_RPM_COMPONENT_INSTALL is ON some more #
# CPACK_RPM_<ComponentName>_XXXX variables may be used in order to have # :code:`CPACK_RPM_<COMPONENT>_XXXX` variables may be used in order to have
# component specific values. Note however that <componentName> refers # **component** specific values. Note however that ``<COMPONENT>`` refers to the
# to the **grouping name**. This may be either a component name or a # **grouping name** written in upper case. It may be either a component name or
# component GROUP name. Usually those vars correspond to RPM spec file # a component GROUP name. Usually those vars correspond to RPM spec file
# entities, one may find information about spec files here # entities, one may find information about spec files here
# http://www.rpm.org/wiki/Docs. You'll find a detailed usage of # http://www.rpm.org/wiki/Docs
# CPackRPM on the wiki:
# #
# :: # .. note::
# #
# https://cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29 # `<COMPONENT>` part of variables is prefered to be in upper case (for e.g. if
# 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.
# #
# List of CPack/RPM specific variables:
# https://cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29 .
# However as a handy reminder here comes the list of specific variables: # However as a handy reminder here comes the list of specific variables:
# #
# .. variable:: CPACK_RPM_PACKAGE_SUMMARY # .. variable:: CPACK_RPM_PACKAGE_SUMMARY
@ -557,7 +567,7 @@
# invalid location. # invalid location.
#============================================================================= #=============================================================================
# Copyright 2007-2009 Kitware, Inc. # Copyright 2007-2016 Kitware, Inc.
# #
# Distributed under the OSI-approved BSD License (the "License"); # Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details. # see accompanying file Copyright.txt for details.
@ -575,6 +585,8 @@ function(cpack_rpm_prepare_relocation_paths)
# set appropriate prefix, remove possible trailing slash and convert backslashes to slashes # set appropriate prefix, remove possible trailing slash and convert backslashes to slashes
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX) if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX)
file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX}" PATH_PREFIX) file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX}" PATH_PREFIX)
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)
else() else()
file(TO_CMAKE_PATH "${CPACK_PACKAGING_INSTALL_PREFIX}" PATH_PREFIX) file(TO_CMAKE_PATH "${CPACK_PACKAGING_INSTALL_PREFIX}" PATH_PREFIX)
endif() endif()
@ -585,7 +597,8 @@ function(cpack_rpm_prepare_relocation_paths)
# set base path prefix # set base path prefix
if(EXISTS "${WDIR}/${PATH_PREFIX}") if(EXISTS "${WDIR}/${PATH_PREFIX}")
if(NOT CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION AND if(NOT CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION AND
NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION) NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION AND
NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_INSTALL_PREFIX_RELOCATION)
set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}Prefix: ${PATH_PREFIX}\n") set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}Prefix: ${PATH_PREFIX}\n")
list(APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}") list(APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}")
@ -1044,6 +1057,17 @@ if(NOT UNIX)
message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.") message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.")
endif() endif()
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()
function(cpack_rpm_generate_package) function(cpack_rpm_generate_package)
# rpmbuild is the basic command for building RPM package # rpmbuild is the basic command for building RPM package
# it may be a simple (symbolic) link to rpm command. # it may be a simple (symbolic) link to rpm command.
@ -1124,12 +1148,10 @@ function(cpack_rpm_generate_package)
# CPACK_RPM_PACKAGE_SUMMARY (mandatory) # CPACK_RPM_PACKAGE_SUMMARY (mandatory)
#Check for component summary first.
#If not set, it will use regular package summary logic.
if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_RPM_PACKAGE_COMPONENT)
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY) cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_SUMMARY"
set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY}) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY"
endif() "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_SUMMARY")
endif() endif()
if(NOT CPACK_RPM_PACKAGE_SUMMARY) if(NOT CPACK_RPM_PACKAGE_SUMMARY)
@ -1142,17 +1164,15 @@ function(cpack_rpm_generate_package)
endif() endif()
# CPACK_RPM_PACKAGE_NAME (mandatory) # CPACK_RPM_PACKAGE_NAME (mandatory)
if(NOT CPACK_RPM_PACKAGE_NAME) if(NOT CPACK_RPM_PACKAGE_NAME)
string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME) string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME)
endif() endif()
if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_RPM_PACKAGE_COMPONENT)
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME) set(CPACK_RPM_PACKAGE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_COMPONENT}")
set(CPACK_RPM_PACKAGE_NAME ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME}) cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME"
else() "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME"
set(CPACK_RPM_PACKAGE_NAME ${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_COMPONENT}) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME")
endif()
endif() endif()
# CPACK_RPM_PACKAGE_VERSION (mandatory) # CPACK_RPM_PACKAGE_VERSION (mandatory)
@ -1179,19 +1199,18 @@ function(cpack_rpm_generate_package)
endif() endif()
endif() endif()
set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE})
#prefer component architecture
if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_RPM_PACKAGE_COMPONENT)
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE) cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_ARCHITECTURE"
set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE}) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE"
if(CPACK_RPM_PACKAGE_DEBUG) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_ARCHITECTURE")
message("CPackRPM:Debug: using component build arch = ${_CPACK_RPM_PACKAGE_ARCHITECTURE}")
endif() if(CPACK_RPM_PACKAGE_DEBUG)
message("CPackRPM:Debug: using component build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
endif() endif()
endif() endif()
if(${_CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch")
set(TMP_RPM_BUILDARCH "Buildarch: ${_CPACK_RPM_PACKAGE_ARCHITECTURE}") if(${CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch")
set(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
else() else()
set(TMP_RPM_BUILDARCH "") set(TMP_RPM_BUILDARCH "")
endif() endif()
@ -1214,13 +1233,10 @@ function(cpack_rpm_generate_package)
endif() endif()
# CPACK_RPM_PACKAGE_GROUP # CPACK_RPM_PACKAGE_GROUP
#Check for component group first.
#If not set, it will use regular package group logic.
if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_RPM_PACKAGE_COMPONENT)
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP) cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_GROUP"
set(CPACK_RPM_PACKAGE_GROUP ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP}) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP"
endif() "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_GROUP")
endif() endif()
if(NOT CPACK_RPM_PACKAGE_GROUP) if(NOT CPACK_RPM_PACKAGE_GROUP)
@ -1247,14 +1263,11 @@ function(cpack_rpm_generate_package)
# - set to a default value # - set to a default value
# #
#Check for a component description first.
#If not set, it will use regular package description logic.
if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_RPM_PACKAGE_COMPONENT)
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION) cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_DESCRIPTION"
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION}) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION"
elseif(CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_DESCRIPTION"
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION}) "CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION")
endif()
endif() endif()
if(NOT CPACK_RPM_PACKAGE_DESCRIPTION) if(NOT CPACK_RPM_PACKAGE_DESCRIPTION)
@ -1306,32 +1319,21 @@ function(cpack_rpm_generate_package)
# If component specific var is not provided we use the global one # If component specific var is not provided we use the global one
# for each component # 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) foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN)
if(CPACK_RPM_PACKAGE_DEBUG)
message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}")
endif()
if(CPACK_RPM_PACKAGE_COMPONENT)
cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}"
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}"
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_${_RPM_SPEC_HEADER}")
endif()
if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER})
if(CPACK_RPM_PACKAGE_DEBUG) if(CPACK_RPM_PACKAGE_DEBUG)
message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}") message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}")
endif()
if(CPACK_RPM_PACKAGE_COMPONENT)
if(DEFINED CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER})
if(CPACK_RPM_PACKAGE_DEBUG)
message("CPackRPM:Debug: using CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}")
endif()
set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}})
else()
if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER})
if(CPACK_RPM_PACKAGE_DEBUG)
message("CPackRPM:Debug: CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER} not defined")
message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}")
endif()
set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}})
endif()
endif()
else()
if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER})
if(CPACK_RPM_PACKAGE_DEBUG)
message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}")
endif()
set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}})
endif()
endif() endif()
set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}})
endif()
# Treat the RPM Spec keyword iff it has been properly defined # Treat the RPM Spec keyword iff it has been properly defined
if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)
@ -1373,94 +1375,38 @@ function(cpack_rpm_generate_package)
# May be used to embed a post (un)installation script in the spec 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 # The refered script file(s) will be read and directly
# put after the %post or %postun section # put after the %post or %postun section
if(CPACK_RPM_PACKAGE_COMPONENT) # ----------------------------------------------------------------
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE)
set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE})
else()
set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE})
endif()
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE)
set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE})
else()
set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE})
endif()
else()
set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE})
set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE})
endif()
# Handle post-install file if it has been specified
if(CPACK_RPM_POST_INSTALL_READ_FILE)
if(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE})
file(READ ${CPACK_RPM_POST_INSTALL_READ_FILE} CPACK_RPM_SPEC_POSTINSTALL)
else()
message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_READ_FILE}> does not exists - ignoring")
endif()
else()
# reset SPEC var value if no post install file has been specified
# (either globally or component-wise)
set(CPACK_RPM_SPEC_POSTINSTALL "")
endif()
# Handle post-uninstall file if it has been specified
if(CPACK_RPM_POST_UNINSTALL_READ_FILE)
if(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE})
file(READ ${CPACK_RPM_POST_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_POSTUNINSTALL)
else()
message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_READ_FILE}> does not exists - ignoring")
endif()
else()
# reset SPEC var value if no post uninstall file has been specified
# (either globally or component-wise)
set(CPACK_RPM_SPEC_POSTUNINSTALL "")
endif()
# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE) # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE)
# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE) # 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. # May be used to embed a pre (un)installation script in the spec file.
# The refered script file(s) will be read and directly # The refered script file(s) will be read and directly
# put after the %pre or %preun section # put after the %pre or %preun section
if(CPACK_RPM_PACKAGE_COMPONENT) foreach(RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL")
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE) foreach(RPM_SCRIPT_FILE_TIME_ "PRE" "POST")
set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE}) set("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
else() "${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE}")
set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE})
endif()
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE)
set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE})
else()
set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE})
endif()
else()
set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE})
set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE})
endif()
# Handle pre-install file if it has been specified if(CPACK_RPM_PACKAGE_COMPONENT)
if(CPACK_RPM_PRE_INSTALL_READ_FILE) cpack_rpm_variable_fallback("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
if(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE"
file(READ ${CPACK_RPM_PRE_INSTALL_READ_FILE} CPACK_RPM_SPEC_PREINSTALL) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE")
else() endif()
message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_READ_FILE}> does not exists - ignoring")
endif()
else()
# reset SPEC var value if no pre-install file has been specified
# (either globally or component-wise)
set(CPACK_RPM_SPEC_PREINSTALL "")
endif()
# Handle pre-uninstall file if it has been specified # Handle file if it has been specified
if(CPACK_RPM_PRE_UNINSTALL_READ_FILE) if(CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE)
if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) if(EXISTS ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE})
file(READ ${CPACK_RPM_PRE_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_PREUNINSTALL) file(READ ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}
else() "CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}")
message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_READ_FILE}> does not exists - ignoring") else()
endif() 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")
else() endif()
# reset SPEC var value if no pre-uninstall file has been specified else()
# (either globally or component-wise) # reset SPEC var value if no file has been specified
set(CPACK_RPM_SPEC_PREUNINSTALL "") # (either globally or component-wise)
endif() set("CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}" "")
endif()
endforeach()
endforeach()
# CPACK_RPM_CHANGELOG_FILE # CPACK_RPM_CHANGELOG_FILE
# May be used to embed a changelog in the spec file. # May be used to embed a changelog in the spec file.
@ -1495,7 +1441,7 @@ function(cpack_rpm_generate_package)
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS) file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS)
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS) file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS)
#set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${_CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") #set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
# it seems rpmbuild can't handle spaces in the path # it seems rpmbuild can't handle spaces in the path
# neither escaping (as below) nor putting quotes around the path seem to help # neither escaping (as below) nor putting quotes around the path seem to help
@ -1510,12 +1456,14 @@ function(cpack_rpm_generate_package)
# This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL handling # This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL handling
if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_RPM_PACKAGE_COMPONENT)
if(CPACK_ABSOLUTE_DESTINATION_FILES) if(CPACK_ABSOLUTE_DESTINATION_FILES)
set(COMPONENT_FILES_TAG "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}") cpack_rpm_variable_fallback("COMPONENT_FILES_TAG"
set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}") "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}"
if(CPACK_RPM_PACKAGE_DEBUG) "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}")
message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>") set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}")
message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") if(CPACK_RPM_PACKAGE_DEBUG)
endif() message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>")
message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
endif()
endif() endif()
else() else()
if(CPACK_ABSOLUTE_DESTINATION_FILES) if(CPACK_ABSOLUTE_DESTINATION_FILES)
@ -1524,22 +1472,18 @@ function(cpack_rpm_generate_package)
endif() endif()
# In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM_<COMPONENT>_USER_FILELIST. # In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM_<COMPONENT>_USER_FILELIST.
set(CPACK_RPM_USER_FILELIST_INTERNAL "")
if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_RPM_PACKAGE_COMPONENT)
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST) cpack_rpm_variable_fallback("CPACK_RPM_USER_FILELIST_INTERNAL"
set(CPACK_RPM_USER_FILELIST_INTERNAL ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST}) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST"
if(CPACK_RPM_PACKAGE_DEBUG) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_FILELIST")
message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>")
message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") if(CPACK_RPM_PACKAGE_DEBUG AND CPACK_RPM_USER_FILELIST_INTERNAL)
endif() message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>")
else() message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
set(CPACK_RPM_USER_FILELIST_INTERNAL "")
endif()
else()
if(CPACK_RPM_USER_FILELIST)
set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}")
else()
set(CPACK_RPM_USER_FILELIST_INTERNAL "")
endif() endif()
elseif(CPACK_RPM_USER_FILELIST)
set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}")
endif() endif()
# Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL # Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL
@ -1578,7 +1522,6 @@ function(cpack_rpm_generate_package)
if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL)
list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH}) list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH})
endif() endif()
endforeach() endforeach()
# Rebuild CPACK_RPM_INSTALL_FILES # Rebuild CPACK_RPM_INSTALL_FILES
@ -1650,8 +1593,10 @@ function(cpack_rpm_generate_package)
# #
# We can have a component specific spec file. # We can have a component specific spec file.
if(CPACK_RPM_PACKAGE_COMPONENT AND CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE) if(CPACK_RPM_PACKAGE_COMPONENT)
set(CPACK_RPM_USER_BINARY_SPECFILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE}) cpack_rpm_variable_fallback("CPACK_RPM_USER_BINARY_SPECFILE"
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE"
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_BINARY_SPECFILE")
endif() endif()
# We should generate a USER spec file template: # We should generate a USER spec file template:
@ -1762,7 +1707,7 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT
COMMAND "${RPMBUILD_EXECUTABLE}" -bb COMMAND "${RPMBUILD_EXECUTABLE}" -bb
--define "_topdir ${CPACK_RPM_DIRECTORY}" --define "_topdir ${CPACK_RPM_DIRECTORY}"
--buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
--target "${_CPACK_RPM_PACKAGE_ARCHITECTURE}" --target "${CPACK_RPM_PACKAGE_ARCHITECTURE}"
"${CPACK_RPM_BINARY_SPECFILE}" "${CPACK_RPM_BINARY_SPECFILE}"
WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT

View File

@ -14,24 +14,24 @@ if(CPACK_GENERATOR MATCHES "RPM")
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/foo/bar") set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/foo/bar")
# test requires # test requires
set(CPACK_RPM_applications_PACKAGE_REQUIRES "mylib-libraries") set(CPACK_RPM_APPLICATIONS_PACKAGE_REQUIRES "mylib-libraries")
# test a "noarch" rpm # test a "noarch" rpm
set(CPACK_RPM_headers_PACKAGE_ARCHITECTURE "noarch") set(CPACK_RPM_HEADERS_PACKAGE_ARCHITECTURE "noarch")
# test cross-built rpm # test cross-built rpm
set(CPACK_RPM_applications_PACKAGE_ARCHITECTURE "armv7hf") set(CPACK_RPM_APPLICATIONS_PACKAGE_ARCHITECTURE "armv7hf")
# test package summary override - headers rpm is generated in the middle # test package summary override - headers rpm is generated in the middle
set(CPACK_RPM_PACKAGE_SUMMARY "default summary") set(CPACK_RPM_PACKAGE_SUMMARY "default summary")
set(CPACK_RPM_headers_PACKAGE_SUMMARY "headers summary") set(CPACK_RPM_HEADERS_PACKAGE_SUMMARY "headers summary")
# test package description override - headers rpm is generated in the middle # test package description override - headers rpm is generated in the middle
set(CPACK_RPM_headers_PACKAGE_DESCRIPTION "headers description") set(CPACK_RPM_HEADERS_PACKAGE_DESCRIPTION "headers description")
# test package do not use CPACK_PACKAGING_INSTALL_PREFIX # test package do not use CPACK_PACKAGING_INSTALL_PREFIX
# as relocation path # as relocation path
set(CPACK_RPM_NO_libraries_INSTALL_PREFIX_RELOCATION true) set(CPACK_RPM_NO_LIBRARIES_INSTALL_PREFIX_RELOCATION true)
endif() endif()
if(CPACK_GENERATOR MATCHES "DEB") if(CPACK_GENERATOR MATCHES "DEB")

View File

@ -7,7 +7,7 @@ endif()
if(CPACK_GENERATOR MATCHES "RPM") if(CPACK_GENERATOR MATCHES "RPM")
set(CPACK_RPM_COMPONENT_INSTALL "ON") set(CPACK_RPM_COMPONENT_INSTALL "ON")
set(CPACK_RPM_Development_PACKAGE_REQUIRES "mylib-Runtime") set(CPACK_RPM_DEVELOPMENT_PACKAGE_REQUIRES "mylib-Runtime")
endif() endif()
if(CPACK_GENERATOR MATCHES "DEB") if(CPACK_GENERATOR MATCHES "DEB")

View File

@ -136,8 +136,8 @@ if(CPackGen MATCHES "RPM")
endif() endif()
set(CPACK_RPM_PACKAGE_SUMMARY "default summary") set(CPACK_RPM_PACKAGE_SUMMARY "default summary")
set(CPACK_RPM_headers_PACKAGE_SUMMARY "headers summary") set(CPACK_RPM_HEADERS_PACKAGE_SUMMARY "headers summary")
set(CPACK_RPM_headers_PACKAGE_DESCRIPTION "headers description") set(CPACK_RPM_HEADERS_PACKAGE_DESCRIPTION "headers description")
set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
"An extremely useful application that makes use of MyLib") "An extremely useful application that makes use of MyLib")
set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
@ -206,8 +206,8 @@ if(CPackGen MATCHES "RPM")
/usr/foo/bar/other_relocatable /usr/foo/bar/other_relocatable
/usr/foo/bar/other_relocatable/depth_two$") /usr/foo/bar/other_relocatable/depth_two$")
elseif(check_file_headers_match) elseif(check_file_headers_match)
set(check_file_match_expected_summary ".*${CPACK_RPM_headers_PACKAGE_SUMMARY}.*") set(check_file_match_expected_summary ".*${CPACK_RPM_HEADERS_PACKAGE_SUMMARY}.*")
set(check_file_match_expected_description ".*${CPACK_RPM_headers_PACKAGE_DESCRIPTION}.*") set(check_file_match_expected_description ".*${CPACK_RPM_HEADERS_PACKAGE_DESCRIPTION}.*")
set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
set(check_file_match_expected_architecture "noarch") set(check_file_match_expected_architecture "noarch")
set(spec_regex "*headers*") set(spec_regex "*headers*")

View File

@ -0,0 +1,26 @@
set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
# default
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh"
"echo \"pre install\"\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh"
"echo \"post install\"\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh"
"echo \"pre uninstall\"\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh"
"echo \"post uninstall\"\n")
# specific
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh"
"echo \"pre install foo\"\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh"
"echo \"post install foo\"\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh"
"echo \"pre uninstall foo\"\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh"
"echo \"post uninstall foo\"\n")
install(FILES CMakeLists.txt DESTINATION foo COMPONENT foo)
install(FILES CMakeLists.txt DESTINATION bar COMPONENT bar)
set(CPACK_PACKAGE_NAME "install_scripts")

View File

@ -4,19 +4,19 @@ set(CPACK_RPM_COMPONENT_INSTALL "ON")
# does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755 # does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755
set(CPACK_RPM_PACKAGE_AUTOREQ "no") set(CPACK_RPM_PACKAGE_AUTOREQ "no")
set(CPACK_RPM_PACKAGE_AUTOPROV "no") set(CPACK_RPM_PACKAGE_AUTOPROV "no")
set(CPACK_RPM_applications_auto_PACKAGE_AUTOREQPROV "yes") set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_AUTOREQPROV "yes")
set(CPACK_RPM_libs_auto_PACKAGE_AUTOREQPROV "yes") set(CPACK_RPM_LIBS_AUTO_PACKAGE_AUTOREQPROV "yes")
set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b") set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b")
set(CPACK_RPM_applications_PACKAGE_REQUIRES "depend-application, depend-application-b") set(CPACK_RPM_APPLICATIONS_PACKAGE_REQUIRES "depend-application, depend-application-b")
set(CPACK_RPM_applications_auto_PACKAGE_REQUIRES "depend-application, depend-application-b") set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_REQUIRES "depend-application, depend-application-b")
set(CPACK_RPM_headers_PACKAGE_REQUIRES "depend-headers") set(CPACK_RPM_HEADERS_PACKAGE_REQUIRES "depend-headers")
set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b") set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b")
set(CPACK_RPM_applications_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") set(CPACK_RPM_APPLICATIONS_PACKAGE_CONFLICTS "conflict-application, conflict-application-b")
set(CPACK_RPM_applications_auto_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_CONFLICTS "conflict-application, conflict-application-b")
set(CPACK_RPM_headers_PACKAGE_CONFLICTS "conflict-headers") set(CPACK_RPM_HEADERS_PACKAGE_CONFLICTS "conflict-headers")
set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b") set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b")
set(CPACK_RPM_libs_PACKAGE_PROVIDES "provided-lib") set(CPACK_RPM_LIBS_PACKAGE_PROVIDES "provided-lib")
set(CPACK_RPM_libs_auto_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") set(CPACK_RPM_LIBS_AUTO_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b")

View File

@ -0,0 +1,7 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "2")
set(EXPECTED_FILE_1 "install_scripts*-foo.rpm")
set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$")
set(EXPECTED_FILE_2 "install_scripts*-bar.rpm")
set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$")

View File

@ -0,0 +1,29 @@
function(checkScripts_ FILE COMPARE_LIST)
set(whitespaces_ "[\t\n\r ]*")
execute_process(COMMAND ${RPM_EXECUTABLE} -qp --scripts ${FILE}
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
OUTPUT_VARIABLE FILE_SCRIPTS_
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE "\n" ";" FILE_SCRIPTS_LIST_ "${FILE_SCRIPTS_}")
foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST)
unset(FOUND_)
foreach(COMPARE_ IN LISTS FILE_SCRIPTS_LIST_)
if(COMPARE_ MATCHES "${COMPARE_REGEX_}")
set(FOUND_ true)
break()
endif()
endforeach()
if(NOT FOUND_)
message(FATAL_ERROR "Missing scripts in '${FILE}'; file info: '${FILE_SCRIPTS_}'; missing: '${COMPARE_REGEX_}'")
endif()
endforeach()
endfunction()
checkScripts_("${FOUND_FILE_1}" "echo \"pre install foo\";echo \"post install foo\";echo \"pre uninstall foo\";echo \"post uninstall foo\"")
checkScripts_("${FOUND_FILE_2}" "echo \"pre install\";echo \"post install\";echo \"pre uninstall\";echo \"post uninstall\"")

View File

@ -0,0 +1,19 @@
set(CPACK_RPM_COMPONENT_INSTALL "ON")
set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/post_install.sh")
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh")
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh")
set(CPACK_RPM_foo_PRE_INSTALL_SCRIPT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh")
set(CPACK_RPM_foo_POST_INSTALL_SCRIPT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh")
set(CPACK_RPM_foo_PRE_UNINSTALL_SCRIPT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh")
set(CPACK_RPM_foo_POST_UNINSTALL_SCRIPT_FILE
"${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh")

View File

@ -1,5 +1,5 @@
set(CPACK_RPM_COMPONENT_INSTALL "ON") set(CPACK_RPM_COMPONENT_INSTALL "ON")
set(CPACK_RPM_PACKAGE_GROUP "default") set(CPACK_RPM_PACKAGE_GROUP "default")
set(CPACK_RPM_pkg_2_PACKAGE_NAME "second") set(CPACK_RPM_PKG_2_PACKAGE_NAME "second")
set(CPACK_RPM_pkg_2_PACKAGE_GROUP "second_group") set(CPACK_RPM_PKG_2_PACKAGE_GROUP "second_group")

View File

@ -11,3 +11,4 @@ run_cpack_test(DEPENDENCIES "RPM;DEB" true)
run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true) run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true)
run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB;TGZ" true) run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB;TGZ" true)
run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false) run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false)
run_cpack_test(INSTALL_SCRIPTS "RPM" false)