Updates will be applied - 3:30pm EDT (UTC -400). No downtime expected.

Commit 758f58b4 authored by Domen Vrankar's avatar Domen Vrankar Committed by Brad King

CPack/RPM learned defining main component

Main component rpm package is generated
without component suffix in filename
and package name.
parent 9c4d1056
cpack-rpm-single-debuginfo
--------------------------
* The :module:`CPackRPM` module learned to generate main component package
which forces generation of a rpm for defined component without component
suffix in filename and package name.
See :variable:`CPACK_RPM_MAIN_COMPONENT` variable.
......@@ -95,6 +95,17 @@
# and it is up to the packager to set the variables in a manner that will
# prevent such errors.
#
# .. variable:: CPACK_RPM_MAIN_COMPONENT
#
# Main component that is packaged without component suffix.
#
# * Mandatory : NO
# * Default : -
#
# This variable can be set to any component or group name so that component or
# group rpm package is generated without component suffix in filename and
# package name.
#
# .. variable:: CPACK_RPM_PACKAGE_VERSION
#
# The RPM package version.
......@@ -1649,10 +1660,16 @@ function(cpack_rpm_generate_package)
endif()
if(CPACK_RPM_PACKAGE_COMPONENT)
string(APPEND CPACK_RPM_PACKAGE_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}")
cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME"
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME"
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME")
string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}"
CPACK_RPM_MAIN_COMPONENT_UPPER)
if(NOT CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER)
string(APPEND CPACK_RPM_PACKAGE_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}")
cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME"
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME"
"CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME")
endif()
endif()
# CPACK_RPM_PACKAGE_VERSION (mandatory)
......@@ -2164,7 +2181,15 @@ ${TMP_DEBUGINFO_ADDITIONAL_SOURCES}
cmake_policy(POP)
else()
# old file name format for back compatibility
set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}"
CPACK_RPM_MAIN_COMPONENT_UPPER)
if(CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER)
# this is the main component so ignore the component filename part
set(CPACK_RPM_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.rpm")
else()
set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
endif()
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")
......
......@@ -105,38 +105,141 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
packageFileNames.clear();
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) {
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
for (compGIt = this->ComponentGroups.begin();
compGIt != this->ComponentGroups.end(); ++compGIt) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
<< compGIt->first << std::endl);
retval &= PackageOnePack(initialTopLevel, compGIt->first);
const char* mainComponent = this->GetOption("CPACK_RPM_MAIN_COMPONENT");
if (mainComponent) {
std::string mainComponentUpper(mainComponent);
std::transform(mainComponentUpper.begin(), mainComponentUpper.end(),
mainComponentUpper.begin(), ::toupper);
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) {
std::map<std::string, cmCPackComponentGroup>::iterator mainCompGIt =
this->ComponentGroups.end();
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
for (compGIt = this->ComponentGroups.begin();
compGIt != this->ComponentGroups.end(); ++compGIt) {
std::string component(compGIt->first);
std::transform(component.begin(), component.end(), component.begin(),
::toupper);
if (mainComponentUpper == component) {
// main component will be handled last
mainCompGIt = compGIt;
continue;
}
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
<< compGIt->first << std::endl);
retval &= PackageOnePack(initialTopLevel, compGIt->first);
}
// Handle Orphan components (components not belonging to any groups)
std::map<std::string, cmCPackComponent>::iterator mainCompIt =
this->Components.end();
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) {
// Does the component belong to a group?
if (compIt->second.Group == CM_NULLPTR) {
std::string component(compIt->first);
std::transform(component.begin(), component.end(), component.begin(),
::toupper);
if (mainComponentUpper == component) {
// main component will be handled last
mainCompIt = compIt;
continue;
}
cmCPackLogger(
cmCPackLog::LOG_VERBOSE, "Component <"
<< compIt->second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
retval &= PackageOnePack(initialTopLevel, compIt->first);
}
}
if (retval) {
if (mainCompGIt != this->ComponentGroups.end()) {
retval &= PackageOnePack(initialTopLevel, mainCompGIt->first);
} else if (mainCompIt != this->Components.end()) {
retval &= PackageOnePack(initialTopLevel, mainCompIt->first);
} else {
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT set"
<< " to non existing component.\n");
retval = 0;
}
}
}
// Handle Orphan components (components not belonging to any groups)
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) {
// Does the component belong to a group?
if (compIt->second.Group == CM_NULLPTR) {
cmCPackLogger(
cmCPackLog::LOG_VERBOSE, "Component <"
<< compIt->second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
else {
std::map<std::string, cmCPackComponent>::iterator mainCompIt =
this->Components.end();
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) {
std::string component(compIt->first);
std::transform(component.begin(), component.end(), component.begin(),
::toupper);
if (mainComponentUpper == component) {
// main component will be handled last
mainCompIt = compIt;
continue;
}
retval &= PackageOnePack(initialTopLevel, compIt->first);
}
if (retval) {
if (mainCompIt != this->Components.end()) {
retval &= PackageOnePack(initialTopLevel, mainCompIt->first);
} else {
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT set"
<< " to non existing component.\n");
retval = 0;
}
}
}
}
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
else {
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) {
retval &= PackageOnePack(initialTopLevel, compIt->first);
} else {
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) {
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
for (compGIt = this->ComponentGroups.begin();
compGIt != this->ComponentGroups.end(); ++compGIt) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
<< compGIt->first << std::endl);
retval &= PackageOnePack(initialTopLevel, compGIt->first);
}
// Handle Orphan components (components not belonging to any groups)
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) {
// Does the component belong to a group?
if (compIt->second.Group == CM_NULLPTR) {
cmCPackLogger(
cmCPackLog::LOG_VERBOSE, "Component <"
<< compIt->second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
retval &= PackageOnePack(initialTopLevel, compIt->first);
}
}
}
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
else {
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) {
retval &= PackageOnePack(initialTopLevel, compIt->first);
}
}
}
......
set(CPACK_RPM_COMPONENT_INSTALL "ON")
install(FILES CMakeLists.txt DESTINATION foo COMPONENT applications)
install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers)
install(FILES CMakeLists.txt DESTINATION bas COMPONENT libs)
if(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid")
set(CPACK_RPM_MAIN_COMPONENT "")
else()
set(CPACK_RPM_MAIN_COMPONENT "applications")
set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT")
endif()
set(CPACK_PACKAGE_NAME "main_component")
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "0")
if(NOT RunCMake_SUBTEST_SUFFIX STREQUAL "invalid")
set(EXPECTED_FILES_COUNT "3")
set(EXPECTED_FILE_1 "main_component-0.1.1-1.*.rpm")
set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$")
set(EXPECTED_FILE_2 "main_component*-headers.rpm")
set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$")
set(EXPECTED_FILE_3 "main_component*-libs.rpm")
set(EXPECTED_FILE_CONTENT_3 "^/usr/bas${whitespaces_}/usr/bas/CMakeLists.txt$")
endif()
^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MAIN_COMPONENT-build-found-subtest/_CPack_Packages/.*/RPM/SPECS/main_component-headers.spec
CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MAIN_COMPONENT-build-found-subtest/_CPack_Packages/.*/RPM/SPECS/main_component-libs.spec
CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MAIN_COMPONENT-build-found-subtest/_CPack_Packages/.*/RPM/SPECS/main_component.spec$
CPACK_RPM_MAIN_COMPONENT set to non existing component.
......@@ -12,6 +12,7 @@ run_cpack_test(DEPENDENCIES "RPM;DEB" true)
run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true)
run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB;TGZ" true)
run_cpack_test(CUSTOM_NAMES "RPM;DEB" true)
run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false)
run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false)
run_cpack_test(RPM_DIST "RPM" false)
run_cpack_test(INSTALL_SCRIPTS "RPM" false)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment