Commit bb8cf521 authored by Domen Vrankar's avatar Domen Vrankar Committed by Brad King

CPack/RPM single debuginfo packaging

Generate a single debuginfo package even
if components packaging is enabled.

This makes issue #15668 resolution feature complete.

Closes: #15486
parent 758f58b4
......@@ -5,3 +5,7 @@ cpack-rpm-single-debuginfo
which forces generation of a rpm for defined component without component
suffix in filename and package name.
See :variable:`CPACK_RPM_MAIN_COMPONENT` variable.
* The :module:`CPackRPM` module learned to generate a single debuginfo package
on demand even if components packagin is used.
See :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` variable.
This diff is collapsed.
......@@ -107,7 +107,78 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
const char* mainComponent = this->GetOption("CPACK_RPM_MAIN_COMPONENT");
if (this->IsOn("CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE") &&
!this->IsOn("CPACK_RPM_DEBUGINFO_PACKAGE")) {
// check if we need to set CPACK_RPM_DEBUGINFO_PACKAGE because non of
// the components is setting per component debuginfo package variable
bool shouldSet = true;
if (ignoreGroup) {
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 (this->IsOn("CPACK_RPM_" + compIt->first + "_DEBUGINFO_PACKAGE") ||
this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) {
shouldSet = false;
break;
}
}
} else {
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 (this->IsOn("CPACK_RPM_" + compGIt->first + "_DEBUGINFO_PACKAGE") ||
this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) {
shouldSet = false;
break;
}
}
if (shouldSet) {
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 (this->IsOn("CPACK_RPM_" + compIt->first +
"_DEBUGINFO_PACKAGE") ||
this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) {
shouldSet = false;
break;
}
}
}
}
}
if (shouldSet) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Setting "
<< "CPACK_RPM_DEBUGINFO_PACKAGE because "
<< "CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE is set but "
<< " none of the "
<< "CPACK_RPM_<component>_DEBUGINFO_PACKAGE variables "
<< "are set." << std::endl);
this->SetOption("CPACK_RPM_DEBUGINFO_PACKAGE", "ON");
}
}
if (mainComponent) {
if (this->IsOn("CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE")) {
this->SetOption("GENERATE_SPEC_PARTS", "ON");
}
std::string mainComponentUpper(mainComponent);
std::transform(mainComponentUpper.begin(), mainComponentUpper.end(),
mainComponentUpper.begin(), ::toupper);
......@@ -163,6 +234,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
}
if (retval) {
this->SetOption("GENERATE_SPEC_PARTS", "OFF");
if (mainCompGIt != this->ComponentGroups.end()) {
retval &= PackageOnePack(initialTopLevel, mainCompGIt->first);
} else if (mainCompIt != this->Components.end()) {
......@@ -197,6 +270,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
}
if (retval) {
this->SetOption("GENERATE_SPEC_PARTS", "OFF");
if (mainCompIt != this->Components.end()) {
retval &= PackageOnePack(initialTopLevel, mainCompIt->first);
} else {
......@@ -206,7 +281,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
}
}
}
} else {
} else if (!this->IsOn("CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE") ||
this->Components.size() == 1) {
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) {
......@@ -241,6 +317,12 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
retval &= PackageOnePack(initialTopLevel, compIt->first);
}
}
} else {
cmCPackLogger(
cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT not set but"
<< " it is mandatory with CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE"
<< " being set.\n");
retval = 0;
}
if (retval) {
......@@ -259,6 +341,10 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne(
packageFileNames.clear();
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
if (this->IsOn("CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE")) {
this->SetOption("CPACK_RPM_DEBUGINFO_PACKAGE", "ON");
}
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..."
"(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)"
......
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "0")
if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo")
set(EXPECTED_FILES_COUNT "4")
set(EXPECTED_FILE_1 "single_debuginfo-0.1.1-1.*.rpm")
set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$")
set(EXPECTED_FILE_2 "single_debuginfo*-headers.rpm")
set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$")
set(EXPECTED_FILE_3 "single_debuginfo*-libs.rpm")
set(EXPECTED_FILE_CONTENT_3 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$")
set(EXPECTED_FILE_4 "single_debuginfo-debuginfo*.rpm")
set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp${whitespaces_}/src/src_1/test_lib.cpp.*")
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component" OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_no_debuginfo")
set(EXPECTED_FILES_COUNT "2")
set(EXPECTED_FILE_1 "single_debuginfo-0*-applications.rpm")
set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$")
set(EXPECTED_FILE_2 "single_debuginfo-applications-debuginfo*.rpm")
set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*")
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_main" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_components")
set(EXPECTED_FILES_COUNT "2")
set(EXPECTED_FILE_1 "single_debuginfo-0*.rpm")
set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$")
set(EXPECTED_FILE_2 "single_debuginfo-debuginfo*.rpm")
set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*")
endif()
^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_components-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$
^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-headers.spec
CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-libs.spec
CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$
CPack Error: CPACK_RPM_MAIN_COMPONENT not set but it is mandatory with CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE being set.
^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-one_component-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-applications.spec$
^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-one_component_main-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$
^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-one_component_no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-applications.spec$
^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-valid-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-headers.spec
CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-valid-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-libs.spec
CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-valid-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$
......@@ -19,5 +19,6 @@ run_cpack_test(INSTALL_SCRIPTS "RPM" false)
run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true)
run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true)
run_cpack_test(DEBUGINFO "RPM" true)
run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_component_main;no_debuginfo;one_component_no_debuginfo;no_components;valid" "RPM" true)
run_cpack_test(LONG_FILENAMES "DEB" false)
run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false)
set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
# PGI compiler doesn't add build id to binaries by default
if(CMAKE_CXX_COMPILER_ID STREQUAL "PGI")
string(APPEND CMAKE_EXE_LINKER_FLAGS "-Wl,--build-id")
string(APPEND CMAKE_SHARED_LINKER_FLAGS "-Wl,--build-id")
endif()
if(NOT RunCMake_SUBTEST_SUFFIX STREQUAL "no_components")
set(CPACK_RPM_COMPONENT_INSTALL "ON")
endif()
set(CMAKE_BUILD_TYPE Debug)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
"int test_lib();\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
"#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n")
add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
"#include \"test_lib.hpp\"\nint main() {return test_lib();}\n")
add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
target_link_libraries(test_prog test_lib)
install(TARGETS test_prog DESTINATION foo COMPONENT applications)
if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid"
OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_main_component"
OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo")
install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers)
install(TARGETS test_lib DESTINATION bas COMPONENT libs)
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component"
OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_no_debuginfo")
set(CPACK_COMPONENTS_ALL applications)
endif()
set(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE ON)
if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid"
OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_main"
OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo")
set(CPACK_RPM_MAIN_COMPONENT "applications")
set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT")
endif()
if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid"
OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_main_component"
OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component")
set(CPACK_RPM_APPLICATIONS_DEBUGINFO_PACKAGE ON)
set(CPACK_RPM_LIBS_DEBUGINFO_PACKAGE ON)
endif()
set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/src")
set(CPACK_PACKAGE_NAME "single_debuginfo")
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