From 2d5896530b7353496e728eb7751ef05c305287e7 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 10 May 2016 14:17:40 +0200 Subject: [PATCH 1/9] CPack/Deb generation of DEBIAN/shlibs control file DEBIAN/shlibs control file generation if the package contains libraries --- Modules/CPackDeb.cmake | 139 +++++++++++++++++++++------ Source/CPack/cmCPackDebGenerator.cxx | 38 ++++++-- 2 files changed, 143 insertions(+), 34 deletions(-) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index b41d926ff..748bf0637 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -331,6 +331,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__PACKAGE_CONTROL_EXTRA # @@ -399,6 +425,10 @@ #============================================================================= # Copyright 2007-2009 Kitware, Inc. # Copyright 2007-2009 Mathieu Malaterre +# Copyright 2014-2016 Alexander Smorkalov +# Copyright 2014-2016 Roman Donchenko +# Copyright 2014-2016 Roman Kharitonov +# Copyright 2014-2016 Ilya Lavrenov # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -423,6 +453,27 @@ if(NOT UNIX) message(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.") endif() +#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 +498,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 +552,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") @@ -726,6 +783,33 @@ function(cpack_deb_prepare_package_vars) endif() endif() + 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() + 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() + # 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}'") @@ -773,6 +857,7 @@ 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) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 0911713a9..839115e9b 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -227,6 +227,7 @@ int cmCPackDebGenerator::PackageComponentsAllInOne() } packageFiles = gl.GetFiles(); + int res = createDeb(); if (res != 1) { @@ -281,9 +282,8 @@ int cmCPackDebGenerator::PackageFiles() 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 +291,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 +403,18 @@ 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; + } cmArchiveWrite::Compress tar_compression_type = cmArchiveWrite::CompressGZip; const char* debian_compression_type = @@ -605,6 +614,21 @@ 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; + } + } + // for the other files, we use // -either the original permission on the files // -either a permission strictly defined by the Debian policies From c7f388e723b85b48a1d0d462a8f2f7d962314421 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 10 May 2016 14:25:25 +0200 Subject: [PATCH 2/9] CPack/Deb generation of postinst and postrm ldconfig files DEBIAN/postinst and DEBAIN/postrm files generation if the package installs libraries in ldconfig controlled location (/lib/, /usr/lib/) --- Modules/CPackDeb.cmake | 29 ++++++++++++++ Source/CPack/cmCPackDebGenerator.cxx | 56 ++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 748bf0637..d38751fcb 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -810,6 +810,33 @@ function(cpack_deb_prepare_package_vars) 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() + # 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}'") @@ -863,6 +890,8 @@ function(cpack_deb_prepare_package_vars) "${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() diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 839115e9b..a09a7cba2 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -416,6 +416,29 @@ int cmCPackDebGenerator::createDeb() 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 = this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE"); @@ -629,6 +652,39 @@ int cmCPackDebGenerator::createDeb() } } + // 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 From 3a55a0e72c216cfe6536e7d8e5c72e3f3e5d65b4 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 10 May 2016 14:53:19 +0200 Subject: [PATCH 3/9] CPack/Deb proper component packages file naming Proper Debian packages file naming for multi-component setup (breaks compatibility with previous versions) --- Modules/CPackDeb.cmake | 29 ++++++++++++++++++++++------ Source/CPack/cmCPackDebGenerator.cxx | 11 +++++++++-- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index d38751fcb..3e5758bd3 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -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) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index a09a7cba2..9c087136b 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -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; From 23baaf8d73ff76e1f32d8dcc7ea837943f130872 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 10 May 2016 14:31:23 +0200 Subject: [PATCH 4/9] CPack/Deb inter package dependencies In multi-component setup dependencies between packages are set (breaking change) --- Modules/CPackDeb.cmake | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 3e5758bd3..5ceb30bbf 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -698,6 +698,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 @@ -705,7 +721,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 () From 271e03f089999d01860b6fcac35505f8a539884e Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 10 May 2016 14:55:52 +0200 Subject: [PATCH 5/9] CPack/Deb per-component package architecture Allowed to set per-compoment Debian package architecture. Useful, if you distribute documentation (should have "all architecture"). --- Modules/CPackDeb.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 5ceb30bbf..227e1b1b5 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -52,6 +52,7 @@ # # # .. variable:: CPACK_DEBIAN_PACKAGE_ARCHITECTURE +# CPACK_DEBIAN__PACKAGE_ARCHITECTURE # # The Debian package architecture # @@ -654,7 +655,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) From 316dd6136721181c8b2e36b8d349d4fa15f7c4eb Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Tue, 10 May 2016 18:31:05 +0200 Subject: [PATCH 6/9] CPack/Deb proper package file naming Proper Debian packages file naming for single package setup (breaks compatibility with previous versions) --- Modules/CPackDeb.cmake | 17 +++++----- Source/CPack/cmCPackDebGenerator.cxx | 48 ++++++++++++---------------- Source/CPack/cmCPackDebGenerator.h | 2 +- 3 files changed, 29 insertions(+), 38 deletions(-) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 227e1b1b5..dc3b4133c 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -835,15 +835,6 @@ 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}) @@ -871,6 +862,14 @@ function(cpack_deb_prepare_package_vars) set(CPACK_DEBIAN_GENERATE_POSTRM 0) endif() + # Patch package file name to be in corrent debian format: + # _-_.deb + 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}") + # 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}'") diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 9c087136b..aec06b7f1 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -60,9 +60,10 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel, cmSystemTools::GetParentDirectory(toplevel) ); std::string outputFileName( - std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) - +"-"+packageName + this->GetOutputExtension() - ); + cmsys::SystemTools::LowerCase( + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))) + +"-"+packageName + this->GetOutputExtension() + ); localToplevel += "/"+ packageName; /* replace the TEMP DIRECTORY with the component one */ @@ -168,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)" @@ -190,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 @@ -204,11 +205,15 @@ int cmCPackDebGenerator::PackageComponentsAllInOne() /* replace the TEMPORARY package file name */ this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", packageFileName.c_str()); - // 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(!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, @@ -246,8 +251,6 @@ int cmCPackDebGenerator::PackageComponentsAllInOne() int cmCPackDebGenerator::PackageFiles() { - int retval = -1; - /* Are we in the component packaging case */ if (WantsComponentInstallation()) { // CASE 1 : COMPONENT ALL-IN-ONE package @@ -255,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 @@ -270,19 +273,8 @@ 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; - } - else - { - packageFiles = files; - return createDeb(); - } + return PackageComponentsAllInOne(""); } - return retval; } int cmCPackDebGenerator::createDeb() diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h index 3d945dd2a..439b7ea5f 100644 --- a/Source/CPack/cmCPackDebGenerator.h +++ b/Source/CPack/cmCPackDebGenerator.h @@ -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; From 3b648894366f86c94d4567811acb9549a81660ec Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Tue, 10 May 2016 18:33:08 +0200 Subject: [PATCH 7/9] CPack/Deb package release number in file name Debian packages file naming format must contain revision number - package release number (breaks compatibility with previous versions) --- Modules/CPackDeb.cmake | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index dc3b4133c..d93d924a8 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -50,6 +50,18 @@ # * 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__PACKAGE_ARCHITECTURE @@ -862,10 +874,14 @@ function(cpack_deb_prepare_package_vars) 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: # _-_.deb set(CPACK_OUTPUT_FILE_NAME - "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") + "${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}") From 7e940bf74ab3496b0d89a55cf7c48dc1b15bc8ce Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Tue, 10 May 2016 15:40:48 +0200 Subject: [PATCH 8/9] CPack/Deb test changes due to breaking changes New CPack/Deb tests and changes to old tests as package file names and inter component dependency detection was changed. --- ...CPackVerifyResult-components-depend1.cmake | 6 +- ...CPackVerifyResult-components-depend2.cmake | 6 +- ...VerifyResult-components-description1.cmake | 2 +- ...VerifyResult-components-description2.cmake | 2 +- ...lt-components-lintian-dpkgdeb-checks.cmake | 2 +- ...ckVerifyResult-components-shlibdeps1.cmake | 2 +- ...nCPackVerifyResult-components-source.cmake | 2 +- .../RunCPackVerifyResult-compression.cmake | 2 +- .../RunCPackVerifyResult.cmake | 2 +- Tests/RunCMake/CPack/CPackTestHelpers.cmake | 14 ++++ .../COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake | 2 +- .../CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake | 6 +- .../DEB_GENERATE_SHLIBS-ExpectedFiles.cmake | 6 ++ .../DEB_GENERATE_SHLIBS-Prerequirements.cmake | 7 ++ .../DEB_GENERATE_SHLIBS-VerifyResult.cmake | 3 + ...NERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake | 6 ++ ...RATE_SHLIBS_LDCONFIG-Prerequirements.cmake | 7 ++ ...ENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake | 7 ++ .../DEB/DEPENDENCIES-ExpectedFiles.cmake | 10 +-- .../CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake | 2 +- Tests/RunCMake/CPack/DEB/Helpers.cmake | 77 ++++++++++++++++++- .../CPack/DEB/MINIMAL-ExpectedFiles.cmake | 2 +- .../PER_COMPONENT_FIELDS-ExpectedFiles.cmake | 6 +- .../RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake | 17 ++++ .../CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake | 18 +++++ Tests/RunCMake/CPack/README.txt | 22 ++++++ Tests/RunCMake/CPack/RunCMakeTest.cmake | 2 + 27 files changed, 211 insertions(+), 29 deletions(-) create mode 100644 Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake create mode 100644 Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake create mode 100644 Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake create mode 100644 Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake create mode 100644 Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake create mode 100644 Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake index 26ab19ed3..70d6edf49 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake @@ -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") diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake index 79e5df21f..415d5360a 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake @@ -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") diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake index 6335029e6..337cc1675 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake @@ -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) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake index 3d0929649..35ca74cdd 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake @@ -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) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake index ff22f8f9f..d51650c0a 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake @@ -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) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake index 79d8f0de2..fcfc7eaee 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake @@ -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) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake index 51fa3ad81..351bf2148 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake @@ -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) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake index 2175adae9..c97ecb019 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake @@ -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) diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake index e956f17c1..5c1d67a35 100644 --- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -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") diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake index aef1086ff..7bf42f952 100644 --- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake +++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake @@ -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}) diff --git a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake index 5adca685a..62f2f9c38 100644 --- a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake @@ -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/$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake index 2ff679ae8..4531a34af 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake @@ -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$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake new file mode 100644 index 000000000..a8efb61e7 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake @@ -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\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake new file mode 100644 index 000000000..b98065a53 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake @@ -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() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake new file mode 100644 index 000000000..8ccb62825 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake @@ -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") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake new file mode 100644 index 000000000..9a9dee35e --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake @@ -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\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake new file mode 100644 index 000000000..b98065a53 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake @@ -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() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake new file mode 100644 index 000000000..d04c64136 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake @@ -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") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake index c56c670fc..c182e303d 100644 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake @@ -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\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake index 1552a36ad..6dc5906d7 100644 --- a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake @@ -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/$") diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index f490130cf..d05f11517 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -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_}'!" diff --git a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake index 9e4aa7c1d..648c866dd 100644 --- a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake @@ -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$") diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake index 1f6c11b9d..40f67309c 100644 --- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake @@ -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$") diff --git a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake new file mode 100644 index 000000000..efb0211c4 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake @@ -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") diff --git a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake new file mode 100644 index 000000000..1f7038644 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake @@ -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") diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt index ea6830448..5c86880bd 100644 --- a/Tests/RunCMake/CPack/README.txt +++ b/Tests/RunCMake/CPack/README.txt @@ -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( "") 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 '/-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 +' - 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: ---------------------- diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index ee4112d4d..2e358f054 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -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) From 4461e8bb55e502d6b7ecaf01d5397d239a984896 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Tue, 10 May 2016 20:20:38 +0200 Subject: [PATCH 9/9] CPack/Deb cpack-deb-improvements release notes --- Help/release/dev/cpack-deb-imporvements.rst | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Help/release/dev/cpack-deb-imporvements.rst diff --git a/Help/release/dev/cpack-deb-imporvements.rst b/Help/release/dev/cpack-deb-imporvements.rst new file mode 100644 index 000000000..4fd35b898 --- /dev/null +++ b/Help/release/dev/cpack-deb-imporvements.rst @@ -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__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:: + + _-_.deb + + This breaks compatibility with previous versions. + +* The :module:`CPackDeb` module learned how to set the package architecture + per-component. See :variable:`CPACK_DEBIAN__PACKAGE_ARCHITECTURE`.