Merge topic 'cpack-deb-improvements'

4461e8bb CPack/Deb cpack-deb-improvements release notes
7e940bf7 CPack/Deb test changes due to breaking changes
3b648894 CPack/Deb package release number in file name
316dd613 CPack/Deb proper package file naming
271e03f0 CPack/Deb per-component package architecture
23baaf8d CPack/Deb inter package dependencies
3a55a0e7 CPack/Deb proper component packages file naming
c7f388e7 CPack/Deb generation of postinst and postrm ldconfig files
2d589653 CPack/Deb generation of DEBIAN/shlibs control file
This commit is contained in:
Brad King 2016-05-16 10:11:30 -04:00 committed by CMake Topic Stage
commit 2b25174da6
31 changed files with 552 additions and 99 deletions

View File

@ -0,0 +1,27 @@
cpack-deb-imporvements
----------------------
* The :module:`CPackDeb` module learned how to generate ``DEBIAN/shlibs``
contorl file when package contains shared libraries.
* The :module:`CPackDeb` module learned how to generate ``DEBIAN/postinst`` and
``DEBIAN/postrm`` files if the package installs libraries in
ldconfig-controlled locations (e.g. ``/lib/``, ``/usr/lib/``).
* The :module:`CPackDeb` module learned how to generate dependencies between
Debian packages if multi-component setup is used and
:variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables are set.
This breaks compatibility with previous versions.
* The :module:`CPackDeb` module learned how to set the package release number
(``DebianRevisionNumber`` in package file name). See
:variable:`CPACK_DEBIAN_PACKAGE_RELEASE`.
* The :module:`CPackDeb` module now generates properly-named Debian packages::
<PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
This breaks compatibility with previous versions.
* The :module:`CPackDeb` module learned how to set the package architecture
per-component. See :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE`.

View File

@ -50,8 +50,21 @@
# * Mandatory : YES
# * Default : :variable:`CPACK_PACKAGE_VERSION`
#
# .. variable:: CPACK_DEBIAN_PACKAGE_RELEASE
#
# The Debian package release - Debian revision number.
#
# * Mandatory : YES
# * Default : 1
#
# This is the numbering of the DEB package itself, i.e. the version of the
# packaging and not the version of the content (see
# :variable:`CPACK_DEBIAN_PACKAGE_VERSION`). One may change the default value
# if the previous packaging was buggy and/or you want to put here a fancy Linux
# distro specific numbering.
#
# .. variable:: CPACK_DEBIAN_PACKAGE_ARCHITECTURE
# CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE
#
# The Debian package architecture
#
@ -331,6 +344,32 @@
# See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
#
#
# .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS
#
# * Mandatory : NO
# * Default : OFF
#
# Allows to generate shlibs control file automatically. Compatibility is defined by
# CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY variable value.
#
# .. note::
#
# Libraries are only considered if they have both library name and version
# set. This can be done by setting SOVERSION property with
# :command:`set_target_properties` command.
#
#
# .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY
#
# * Mandatory : NO
# * Default : "="
#
# Defines compatibility policy for auto-generated shlibs control file.
# Possible values: "=", ">="
#
# See https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps
#
#
# .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
# CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA
#
@ -399,6 +438,10 @@
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
# Copyright 2007-2009 Mathieu Malaterre <mathieu.malaterre@gmail.com>
# Copyright 2014-2016 Alexander Smorkalov <alexander.smorkalov@itseez.com>
# Copyright 2014-2016 Roman Donchenko <roman.donchenko@itseez.com>
# Copyright 2014-2016 Roman Kharitonov <roman.kharitonov@itseez.com>
# Copyright 2014-2016 Ilya Lavrenov <ilya.lavrenov@itseez.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@ -423,6 +466,38 @@ 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)
execute_process(COMMAND "${READELF_EXECUTABLE}" -d "${shared_object}"
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(result EQUAL 0)
string(REGEX MATCH "\\(SONAME\\)[^\n]*\\[([^\n]+)\\.so\\.([^\n]*)\\]" soname "${output}")
set(${libname} "${CMAKE_MATCH_1}" PARENT_SCOPE)
set(${version} "${CMAKE_MATCH_2}" PARENT_SCOPE)
else()
message(WARNING "Error running readelf for \"${shared_object}\"")
endif()
else()
message(FATAL_ERROR "Readelf utility is not available.")
endif()
endfunction()
function(cpack_deb_prepare_package_vars)
# CPACK_DEBIAN_PACKAGE_SHLIBDEPS
# If specify OFF, only user depends are used
@ -447,6 +522,39 @@ function(cpack_deb_prepare_package_vars)
endif()
endif()
if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OR CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
# Generating binary list - Get type of all install files
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_ LIST_DIRECTORIES false RELATIVE "${WDIR}" "${WDIR}/*")
cmake_policy(POP)
# get file info so that we can determine if file is executable or not
unset(CPACK_DEB_INSTALL_FILES)
foreach(FILE_ IN LISTS FILE_PATHS_)
execute_process(COMMAND file "./${FILE_}"
WORKING_DIRECTORY "${WDIR}"
OUTPUT_VARIABLE INSTALL_FILE_)
list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}")
endforeach()
# Only dynamically linked ELF files are included
# Extract only file name infront of ":"
foreach(_FILE IN LISTS CPACK_DEB_INSTALL_FILES)
if(_FILE MATCHES "ELF.*dynamically linked")
string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
list(APPEND CPACK_DEB_BINARY_FILES "${CMAKE_MATCH_1}")
set(CONTAINS_EXECUTABLE_FILES_ TRUE)
endif()
if(_FILE MATCHES "ELF.*shared object")
string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
list(APPEND CPACK_DEB_SHARED_OBJECT_FILES "${CMAKE_MATCH_1}")
endif()
endforeach()
endif()
if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
# dpkg-shlibdeps is a Debian utility for generating dependency list
find_program(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps)
@ -468,33 +576,6 @@ function(cpack_deb_prepare_package_vars)
message("CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>")
endif()
# Generating binary list - Get type of all install files
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_ LIST_DIRECTORIES false RELATIVE "${WDIR}" "${WDIR}/*")
cmake_policy(POP)
# get file info so that we can determine if file is executable or not
unset(CPACK_DEB_INSTALL_FILES)
foreach(FILE_ IN LISTS FILE_PATHS_)
execute_process(COMMAND file "./${FILE_}"
WORKING_DIRECTORY "${WDIR}"
OUTPUT_VARIABLE INSTALL_FILE_)
list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}")
endforeach()
# Only dynamically linked ELF files are included
# Extract only file name infront of ":"
foreach(_FILE ${CPACK_DEB_INSTALL_FILES})
if( ${_FILE} MATCHES "ELF.*dynamically linked")
string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
list(APPEND CPACK_DEB_BINARY_FILES "${CMAKE_MATCH_1}")
set(CONTAINS_EXECUTABLE_FILES_ TRUE)
endif()
endforeach()
if(CONTAINS_EXECUTABLE_FILES_)
message("CPackDeb: - Generating dependency list")
@ -586,7 +667,9 @@ function(cpack_deb_prepare_package_vars)
endif()
# Architecture: (mandatory)
if(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
if(CPACK_DEB_PACKAGE_COMPONENT AND CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE}")
elseif(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
# There is no such thing as i686 architecture on debian, you should use i386 instead
# $ dpkg --print-architecture
find_program(DPKG_CMD dpkg)
@ -630,6 +713,22 @@ function(cpack_deb_prepare_package_vars)
endif()
endif()
endforeach()
set(COMPONENT_DEPENDS "")
foreach (_PACK ${CPACK_COMPONENT_${_local_component_name}_DEPENDS})
get_component_package_name(_PACK_NAME "${_PACK}")
if(COMPONENT_DEPENDS)
set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION}), ${COMPONENT_DEPENDS}")
else()
set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION})")
endif()
endforeach()
if(COMPONENT_DEPENDS)
if(CPACK_DEBIAN_PACKAGE_DEPENDS)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}")
else()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}")
endif()
endif()
endif()
# at this point, the CPACK_DEBIAN_PACKAGE_DEPENDS is properly set
@ -637,7 +736,7 @@ function(cpack_deb_prepare_package_vars)
# Append automatically discovered dependencies .
if(NOT "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}" STREQUAL "")
if (CPACK_DEBIAN_PACKAGE_DEPENDS)
set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}")
set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
else ()
set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
endif ()
@ -718,14 +817,75 @@ function(cpack_deb_prepare_package_vars)
set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}")
endif()
endforeach()
get_component_package_name(CPACK_DEBIAN_PACKAGE_NAME ${_local_component_name})
endif()
if(CPACK_DEBIAN_${_local_component_name}_PACKAGE_NAME)
string(TOLOWER "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
set(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "")
if (NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=")
endif()
find_program(READELF_EXECUTABLE NAMES readelf)
if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
if(READELF_EXECUTABLE)
foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES)
extract_so_info("${_FILE}" libname soversion)
if(libname AND soversion)
list(APPEND CPACK_DEBIAN_PACKAGE_SHLIBS_LIST
"${libname} ${soversion} ${CPACK_DEBIAN_PACKAGE_NAME} (${CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY} ${CPACK_PACKAGE_VERSION})")
else()
string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_DEB_PACKAGE_COMPONENT}" CPACK_DEBIAN_PACKAGE_NAME)
message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.")
endif()
endforeach()
if (CPACK_DEBIAN_PACKAGE_SHLIBS_LIST)
string(REPLACE ";" "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}")
endif()
else()
message(FATAL_ERROR "Readelf utility is not available. CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS option is not available.")
endif()
endif()
# add ldconfig call in default postrm and postint
set(CPACK_ADD_LDCONFIG_CALL 0)
foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES})
get_filename_component(_DIR ${_FILE} DIRECTORY)
# all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning
if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib")
set(CPACK_ADD_LDCONFIG_CALL 1)
endif()
endforeach()
if(CPACK_ADD_LDCONFIG_CALL)
set(CPACK_DEBIAN_GENERATE_POSTINST 1)
set(CPACK_DEBIAN_GENERATE_POSTRM 1)
foreach(f ${PACKAGE_CONTROL_EXTRA})
get_filename_component(n "${f}" NAME)
if("${n}" STREQUAL "postinst")
set(CPACK_DEBIAN_GENERATE_POSTINST 0)
endif()
if("${n}" STREQUAL "postrm")
set(CPACK_DEBIAN_GENERATE_POSTRM 0)
endif()
endforeach()
else()
set(CPACK_DEBIAN_GENERATE_POSTINST 0)
set(CPACK_DEBIAN_GENERATE_POSTRM 0)
endif()
if(NOT CPACK_DEBIAN_PACKAGE_RELEASE)
set(CPACK_DEBIAN_PACKAGE_RELEASE 1)
endif()
# Patch package file name to be in corrent debian format:
# <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
set(CPACK_OUTPUT_FILE_NAME
"${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${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}")
# Print out some debug information if we were asked for that
if(CPACK_DEBIAN_PACKAGE_DEBUG)
message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = '${CPACK_TOPLEVEL_DIRECTORY}'")
@ -755,6 +915,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)
@ -773,11 +935,14 @@ function(cpack_deb_prepare_package_vars)
set(GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS "${CPACK_DEBIAN_PACKAGE_CONFLICTS}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_PACKAGE_PROVIDES "${CPACK_DEBIAN_PACKAGE_PROVIDES}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_PACKAGE_REPLACES "${CPACK_DEBIAN_PACKAGE_REPLACES}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_PACKAGE_SHLIBS "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
"${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_PACKAGE_SOURCE
"${CPACK_DEBIAN_PACKAGE_SOURCE}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_GENERATE_POSTINST "${CPACK_DEBIAN_GENERATE_POSTINST}" PARENT_SCOPE)
set(GEN_CPACK_DEBIAN_GENERATE_POSTRM "${CPACK_DEBIAN_GENERATE_POSTRM}" PARENT_SCOPE)
set(GEN_WDIR "${WDIR}" PARENT_SCOPE)
endfunction()

View File

@ -60,7 +60,8 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel,
cmSystemTools::GetParentDirectory(toplevel)
);
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
cmsys::SystemTools::LowerCase(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")))
+"-"+packageName + this->GetOutputExtension()
);
@ -107,6 +108,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;
}
@ -165,17 +169,16 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
return retval;
}
int cmCPackDebGenerator::PackageComponentsAllInOne()
//----------------------------------------------------------------------
int cmCPackDebGenerator::PackageComponentsAllInOne(
const std::string& compInstDirName)
{
int retval = 1;
std::string compInstDirName;
/* Reset package file name list it will be populated during the
* component packaging run*/
packageFileNames.clear();
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
compInstDirName = "ALL_COMPONENTS_IN_ONE";
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..."
"(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)"
@ -187,7 +190,8 @@ int cmCPackDebGenerator::PackageComponentsAllInOne()
cmSystemTools::GetParentDirectory(toplevel)
);
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
cmsys::SystemTools::LowerCase(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")))
+ this->GetOutputExtension()
);
// all GROUP in one vs all COMPONENT in one
@ -201,11 +205,15 @@ int cmCPackDebGenerator::PackageComponentsAllInOne()
/* replace the TEMPORARY package file name */
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
packageFileName.c_str());
if(!compInstDirName.empty())
{
// Tell CPackDeb.cmake the path where the component is.
std::string component_path = "/";
component_path += compInstDirName;
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
}
if (!this->ReadListFile("CPackDeb.cmake"))
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
@ -227,20 +235,22 @@ int cmCPackDebGenerator::PackageComponentsAllInOne()
}
packageFiles = gl.GetFiles();
int res = createDeb();
if (res != 1)
{
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;
}
int cmCPackDebGenerator::PackageFiles()
{
int retval = -1;
/* Are we in the component packaging case */
if (WantsComponentInstallation()) {
// CASE 1 : COMPONENT ALL-IN-ONE package
@ -248,7 +258,7 @@ int cmCPackDebGenerator::PackageFiles()
// then the package file is unique and should be open here.
if (componentPackageMethod == ONE_PACKAGE)
{
return PackageComponentsAllInOne();
return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE");
}
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group
@ -263,27 +273,15 @@ int cmCPackDebGenerator::PackageFiles()
// CASE 3 : NON COMPONENT package.
else
{
if (!this->ReadListFile("CPackDeb.cmake"))
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while execution CPackDeb.cmake" << std::endl);
retval = 0;
return PackageComponentsAllInOne("");
}
else
{
packageFiles = files;
return createDeb();
}
}
return retval;
}
int cmCPackDebGenerator::createDeb()
{
// debian-binary file
std::string dbfilename;
dbfilename += this->GetOption("GEN_WDIR");
dbfilename += "/debian-binary";
const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
const std::string dbfilename = strGenWDIR + "/debian-binary";
{ // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(dbfilename.c_str());
out << "2.0";
@ -291,9 +289,7 @@ int cmCPackDebGenerator::createDeb()
}
// control file
std::string ctlfilename;
ctlfilename = this->GetOption("GEN_WDIR");
ctlfilename += "/control";
std::string ctlfilename = strGenWDIR + "/control";
// debian policy enforce lower case for package name
// mandatory entries:
@ -405,7 +401,41 @@ int cmCPackDebGenerator::createDeb()
out << std::endl;
}
const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
const std::string shlibsfilename = strGenWDIR + "/shlibs";
const char* debian_pkg_shlibs = this->GetOption(
"GEN_CPACK_DEBIAN_PACKAGE_SHLIBS");
const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS")
&& debian_pkg_shlibs && *debian_pkg_shlibs;
if( gen_shibs )
{
cmGeneratedFileStream out(shlibsfilename.c_str());
out << debian_pkg_shlibs;
out << std::endl;
}
const std::string postinst = strGenWDIR + "/postinst";
const std::string postrm = strGenWDIR + "/postrm";
if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST"))
{
cmGeneratedFileStream out(postinst.c_str());
out <<
"#!/bin/sh\n\n"
"set -e\n\n"
"if [ \"$1\" = \"configure\" ]; then\n"
"\tldconfig\n"
"fi\n";
}
if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM"))
{
cmGeneratedFileStream out(postrm.c_str());
out <<
"#!/bin/sh\n\n"
"set -e\n\n"
"if [ \"$1\" = \"remove\" ]; then\n"
"\tldconfig\n"
"fi\n";
}
cmArchiveWrite::Compress tar_compression_type = cmArchiveWrite::CompressGZip;
const char* debian_compression_type =
@ -605,6 +635,54 @@ int cmCPackDebGenerator::createDeb()
return 0;
}
// adds generated shlibs file
if( gen_shibs )
{
if( !control_tar.Add(shlibsfilename, strGenWDIR.length(), ".") )
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error adding file to tar:" << std::endl
<< "#top level directory: "
<< strGenWDIR << std::endl
<< "#file: \"shlibs\"" << std::endl
<< "#error:" << control_tar.GetError() << std::endl);
return 0;
}
}
// adds LDCONFIG related files
if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST"))
{
control_tar.SetPermissions(permission755);
if(!control_tar.Add(postinst, strGenWDIR.length(), "."))
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error adding file to tar:" << std::endl
<< "#top level directory: "
<< strGenWDIR << std::endl
<< "#file: \"postinst\"" << std::endl
<< "#error:" << control_tar.GetError() << std::endl);
return 0;
}
control_tar.SetPermissions(permission644);
}
if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM"))
{
control_tar.SetPermissions(permission755);
if(!control_tar.Add(postrm, strGenWDIR.length(), "."))
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error adding file to tar:" << std::endl
<< "#top level directory: "
<< strGenWDIR << std::endl
<< "#file: \"postinst\"" << std::endl
<< "#error:" << control_tar.GetError() << std::endl);
return 0;
}
control_tar.SetPermissions(permission644);
}
// for the other files, we use
// -either the original permission on the files
// -either a permission strictly defined by the Debian policies
@ -662,11 +740,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;

View File

@ -60,7 +60,7 @@ protected:
* Special case of component install where all
* components will be put in a single installer.
*/
int PackageComponentsAllInOne();
int PackageComponentsAllInOne(const std::string& compInstDirName);
virtual int PackageFiles();
virtual const char* GetOutputExtension() { return ".deb"; }
virtual bool SupportsComponentInstallation() const;

View File

@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)
@ -60,9 +60,9 @@ if(DPKGDEB_EXECUTABLE)
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-application'\n")
endif()
elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
if(NOT "${dpkg_depends}" STREQUAL "depend-headers")
if(NOT "${dpkg_depends}" STREQUAL "mylib-libraries (= 1.0.2), depend-headers")
set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-headers'\n")
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.2), depend-headers'\n")
endif()
elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
if(NOT "${dpkg_depends}" STREQUAL "depend-default")

View File

@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)
set(config_verbose -V)
@ -73,9 +73,9 @@ if(DPKGDEB_EXECUTABLE)
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' does contains 'depend-default'\n")
endif()
elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
if(NOT "${dpkg_depends}" STREQUAL "depend-headers")
if(NOT "${dpkg_depends}" STREQUAL "mylib-libraries (= 1.0.2), depend-headers")
set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-headers'\n")
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.2), depend-headers'\n")
endif()
elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
if(NOT "${dpkg_depends}" STREQUAL "depend-default")

View File

@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)

View File

@ -7,7 +7,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)

View File

@ -5,7 +5,7 @@ endif()
include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# TODO: currently debian doens't produce lower cased names
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)

View File

@ -9,7 +9,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# requirements
# debian now produces lower case names
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)

View File

@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)
set(config_verbose -V)

View File

@ -5,7 +5,7 @@ endif()
include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# TODO: currently debian doens't produce lower cased names
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib_1.0.2-1_*.deb")
set(expected_count 1)
set(actual_output)

View File

@ -60,7 +60,7 @@ elseif (CPackGen MATCHES "RPM")
set(expected_count 1)
endif ()
elseif (CPackGen MATCHES "DEB")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2-1_*.deb")
if (${CPackComponentWay} STREQUAL "default")
set(expected_count 1)
elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")

View File

@ -9,6 +9,20 @@ function(run_cpack_test TEST_NAME types build)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
if(EXISTS "${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake")
include("${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake")
set(FOUND_PREREQUIREMENTS false)
get_test_prerequirements("FOUND_PREREQUIREMENTS"
"${TEST_CONFIG_DIR}/${type}_config.cmake")
# skip the test if prerequirements are not met
if(NOT FOUND_PREREQUIREMENTS)
message(STATUS "${TEST_NAME} - SKIPPED")
return()
endif()
endif()
# execute cmake
set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}")
run_cmake(${TEST_NAME})

View File

@ -1,5 +1,5 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "components_empty_dir*.deb")
set(EXPECTED_FILE_1 "components_empty_dir-test_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$")

View File

@ -1,9 +1,9 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "3")
set(EXPECTED_FILE_1 "deb_extra-*-foo.deb")
set(EXPECTED_FILE_1 "deb_extra-foo_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$")
set(EXPECTED_FILE_2 "deb_extra-*-bar.deb")
set(EXPECTED_FILE_2 "deb_extra-bar_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_2 "^.*/usr/${whitespaces_}.*/usr/bar/${whitespaces_}.*/usr/bar/CMakeLists.txt$")
set(EXPECTED_FILE_3 "deb_extra-*-bas.deb")
set(EXPECTED_FILE_3 "deb_extra-bas_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_3 "^.*/usr/${whitespaces_}.*/usr/bas/${whitespaces_}.*/usr/bas/CMakeLists.txt$")

View File

@ -0,0 +1,6 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "generate_shlibs_0.1.1-1_*.deb")
# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/libtest_lib\\..*$")

View File

@ -0,0 +1,7 @@
function(get_test_prerequirements found_var)
find_program(READELF_EXECUTABLE NAMES readelf)
if(READELF_EXECUTABLE)
set(${found_var} true PARENT_SCOPE)
endif()
endfunction()

View File

@ -0,0 +1,3 @@
set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs \\(\\= 0\\.1\\.1\\)\n$")
set(shlibs_shlibs_permissions_regex "-rw-r--r-- .*")
verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs")

View File

@ -0,0 +1,6 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "generate_shlibs_ldconfig_0.1.1-1_*.deb")
# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/lib${whitespaces_}.*/usr/lib/libtest_lib\\..*$")

View File

@ -0,0 +1,7 @@
function(get_test_prerequirements found_var)
find_program(READELF_EXECUTABLE NAMES readelf)
if(READELF_EXECUTABLE)
set(${found_var} true PARENT_SCOPE)
endif()
endfunction()

View File

@ -0,0 +1,7 @@
set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs_ldconfig \\(>\\= 0\\.1\\.1\\)\n$")
set(shlibs_shlibs_permissions_regex "-rw-r--r-- .*")
set(shlibs_postinst ".*ldconfig.*")
set(shlibs_postinst_permissions_regex "-rwxr-xr-x .*")
set(shlibs_postrm ".*ldconfig.*")
set(shlibs_postrm_permissions_regex "-rwxr-xr-x .*")
verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs;postinst;postrm")

View File

@ -1,14 +1,14 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "5")
set(EXPECTED_FILE_1 "dependencies*-applications.deb")
set(EXPECTED_FILE_1 "dependencies-applications_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$")
set(EXPECTED_FILE_2 "dependencies*-applications_auto.deb")
set(EXPECTED_FILE_2 "dependencies-applications_auto_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$")
set(EXPECTED_FILE_3 "dependencies*-headers.deb")
set(EXPECTED_FILE_3 "dependencies-headers_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$")
set(EXPECTED_FILE_4 "dependencies*-libs.deb")
set(EXPECTED_FILE_4 "dependencies-libs_0.1.1-1_*.deb")
# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it
set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$")
set(EXPECTED_FILE_5 "dependencies*-libs_auto.deb")
set(EXPECTED_FILE_5 "dependencies-libs_auto_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$")

View File

@ -1,5 +1,5 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "empty_dir*.deb")
set(EXPECTED_FILE_1 "empty_dir_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$")

View File

@ -1,7 +1,7 @@
set(ALL_FILES_GLOB "*.deb")
function(getPackageContent FILE RESULT_VAR)
execute_process(COMMAND ${DPKG_EXECUTABLE} -c ${FILE}
execute_process(COMMAND ${DPKG_EXECUTABLE} -c "${FILE}"
OUTPUT_VARIABLE package_content_
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
@ -9,8 +9,73 @@ function(getPackageContent FILE RESULT_VAR)
set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE)
endfunction()
function(getMissingShlibsErrorExtra FILE RESULT_VAR)
execute_process(COMMAND ${DPKG_EXECUTABLE} -x "${FILE}" data_${PREFIX}
ERROR_VARIABLE err_)
if(err_)
set(error_extra " Extra: Could not unpack package content: '${err}'")
else()
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_ LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/data_${PREFIX}/*")
cmake_policy(POP)
# get file info so that we can determine if file is executable or not
foreach(FILE_ IN LISTS FILE_PATHS_)
execute_process(COMMAND file "${FILE_}"
WORKING_DIRECTORY "${WDIR}"
OUTPUT_VARIABLE INSTALL_FILE_
ERROR_VARIABLE err_)
if(NOT err_)
list(APPEND deb_install_files "${INSTALL_FILE_}")
else()
list(APPEND deb_install_files_errors "'${FILE_}': '${err_}'\n")
endif()
endforeach()
set(error_extra " Extra: install files '${deb_install_files}'")
if(deb_install_files_errors)
set(error_extra "${error_extra}; errors \"${deb_install_files_errors}\"")
endif()
find_program(READELF_EXECUTABLE NAMES readelf)
if(READELF_EXECUTABLE)
set(error_extra "${error_extra}; readelf \"\n")
# Only dynamically linked ELF files are included
# Extract only file name infront of ":"
foreach(_FILE IN LISTS deb_install_files)
if(_FILE MATCHES "ELF.*shared object")
string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
execute_process(COMMAND ${READELF_EXECUTABLE} -d "${CMAKE_MATCH_1}"
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE err_
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(error_extra "${error_extra} name '${CMAKE_MATCH_1}'\n result '${result}'\n output '${output}'\n error '${err_}'\n")
endif()
endforeach()
set(error_extra "${error_extra}\"")
else()
set(error_extra "${error_extra}; error readelf missing")
endif()
endif()
set(${RESULT_VAR} "${error_extra}" PARENT_SCOPE)
endfunction()
function(verifyDebControl FILE PREFIX VERIFY_FILES)
execute_process(COMMAND ${DPKG_EXECUTABLE} --control ${FILE} control_${PREFIX}
execute_process(COMMAND ${DPKG_EXECUTABLE} --control "${FILE}" control_${PREFIX}
ERROR_VARIABLE err_)
if(err_)
@ -19,6 +84,14 @@ function(verifyDebControl FILE PREFIX VERIFY_FILES)
endif()
foreach(FILE_ IN LISTS VERIFY_FILES)
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}")
if(FILE_ STREQUAL "shlibs")
getMissingShlibsErrorExtra("${FILE}" error_extra)
endif()
message(FATAL_ERROR "Expected Debian control file does not exist: '${FILE_}'${error_extra}")
endif()
file(READ "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}" content_)
if(NOT content_ MATCHES "${${PREFIX}_${FILE_}}")
message(FATAL_ERROR "Unexpected content in for '${PREFIX}_${FILE_}'!"

View File

@ -1,5 +1,5 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "minimal*.deb")
set(EXPECTED_FILE_1 "minimal_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$")

View File

@ -1,9 +1,9 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "3")
set(EXPECTED_FILE_1 "per_component*-pkg_1.deb")
set(EXPECTED_FILE_1 "per_component-pkg_1_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")
set(EXPECTED_FILE_2 "per_component*-pkg_2.deb")
set(EXPECTED_FILE_2 "second_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")
set(EXPECTED_FILE_3 "per_component*-pkg_3.deb")
set(EXPECTED_FILE_3 "per_component-pkg_3_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_3 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")

View File

@ -0,0 +1,17 @@
set(CPACK_PACKAGE_CONTACT "someone")
set(CPACK_DEB_COMPONENT_INSTALL "ON")
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON")
set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
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")
set_target_properties(test_lib PROPERTIES SOVERSION "0.8")
install(TARGETS test_lib DESTINATION foo COMPONENT libs)
set(CPACK_PACKAGE_NAME "generate_shlibs")

View File

@ -0,0 +1,18 @@
set(CPACK_PACKAGE_CONTACT "someone")
set(CPACK_DEB_COMPONENT_INSTALL "ON")
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON")
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=")
set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
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")
set_target_properties(test_lib PROPERTIES SOVERSION "0.8")
install(TARGETS test_lib LIBRARY DESTINATION lib COMPONENT libs NAMELINK_SKIP)
set(CPACK_PACKAGE_NAME "generate_shlibs_ldconfig")

View File

@ -1,6 +1,9 @@
RunCMake.CPack is a test module that is intended for testing of package
generators that can be validated from command line.
TODO: all tests should cover all packaging types (single package, grouped and
component packaging)
-------------
Adding a test
-------------
@ -19,10 +22,29 @@ run_cpack_test(<test_name> "<generator_name>")
will be run for all listed generators.
Test consists of
- test prerequirements phase (optional)
- CMake execution phase
- CPack execution phase
- verification of generated files
test prerequirements phase (optional):
--------------------------------------
In some cases individual tests for certain generator need additional
prerequirements met.
In such cases '<generator_name>/<test_name>-Prerequirements.cmake' file
containing 'function(get_test_prerequirements found_var)' should be created.
Function should return true if all prerequirements are met.
If prerequirements are not met test will be skipped outputting
'<test_name> - SKIPPED' string. Note that this doesn't fail the entire test
group.
TODO: skipped tests should provide expected error string so test should fail
if error string is not found in the output of run test (this would add
'EXPECTED FAIL' string on success and 'ERROR' on failure).
CMake execution phase:
----------------------

View File

@ -12,3 +12,5 @@ run_cpack_test(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(INSTALL_SCRIPTS "RPM" false)
run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true)
run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true)