Commit 3a55a0e7 authored by Alexander Smorkalov's avatar Alexander Smorkalov Committed by Brad King

CPack/Deb proper component packages file naming

Proper Debian packages file naming for multi-component setup
(breaks compatibility with previous versions)
parent c7f388e7
......@@ -453,6 +453,17 @@ if(NOT UNIX)
message(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.")
endif()
function(get_component_package_name var component)
string(TOUPPER "${component}" component_upcase)
if(CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME)
string(TOLOWER "${CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME}" package_name)
else()
string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${component}" package_name)
endif()
set("${var}" "${package_name}" PARENT_SCOPE)
endfunction()
#extract library name and version for given shared object
function(extract_so_info shared_object libname version)
if(READELF_EXECUTABLE)
......@@ -775,12 +786,7 @@ function(cpack_deb_prepare_package_vars)
set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}")
endif()
endforeach()
if(CPACK_DEBIAN_${_local_component_name}_PACKAGE_NAME)
string(TOLOWER "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
else()
string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_DEB_PACKAGE_COMPONENT}" CPACK_DEBIAN_PACKAGE_NAME)
endif()
get_component_package_name(CPACK_DEBIAN_PACKAGE_NAME ${_local_component_name})
endif()
set(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "")
......@@ -810,6 +816,15 @@ function(cpack_deb_prepare_package_vars)
endif()
endif()
# Patch package file name to be in corrent form
if(CPACK_DEB_PACKAGE_COMPONENT)
set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_OUTPUT_FILE_NAME}")
get_filename_component(BINARY_DIR "${CPACK_OUTPUT_FILE_PATH}" DIRECTORY)
set(CPACK_OUTPUT_FILE_PATH "${BINARY_DIR}/${CPACK_OUTPUT_FILE_NAME}")
endif()
# add ldconfig call in default postrm and postint
set(CPACK_ADD_LDCONFIG_CALL 0)
foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES})
......@@ -866,6 +881,8 @@ function(cpack_deb_prepare_package_vars)
#endif()
# move variables to parent scope so that they may be used to create debian package
set(GEN_CPACK_OUTPUT_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}" PARENT_SCOPE)
set(GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TEMPORARY_PACKAGE_FILE_NAME}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_DEBIAN_PACKAGE_VERSION}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_PACKAGE_SECTION "${CPACK_DEBIAN_PACKAGE_SECTION}" PARENT_SCOPE)
......
......@@ -107,6 +107,9 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel,
retval = 0;
}
// add the generated package to package file names list
packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
packageFileName += "/";
packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
packageFileNames.push_back(packageFileName);
return retval;
}
......@@ -234,6 +237,9 @@ int cmCPackDebGenerator::PackageComponentsAllInOne()
retval = 0;
}
// add the generated package to package file names list
packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
packageFileName += "/";
packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
packageFileNames.push_back(packageFileName);
return retval;
}
......@@ -742,11 +748,12 @@ int cmCPackDebGenerator::createDeb()
arFiles.push_back(topLevelString + "data.tar" + compression_suffix);
std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
outputFileName += "/";
outputFileName += this->GetOption("CPACK_OUTPUT_FILE_NAME");
outputFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
int res = ar_append(outputFileName.c_str(), arFiles);
if ( res!=0 )
{
std::string tmpFile = this->GetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME");
std::string tmpFile = this->GetOption(
"GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME");
tmpFile += "/Deb.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Problem creating archive using: " << res << std::endl;
......
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