Re: [CMake] CPack DEB depends bug fix
I've patched cmake's cpack DEB generator to support dependencies between components much like RPM generator. It should fix as well the problem with deps build on top of another To take advantage of patch you have to recompile cmake: $ git clone git://cmake.org/cmake.git cd cmake $ ./configure $ git checkout v2.8.11 # use version you like $ git apply path_to_patch_file $ make # make install Patched cmake allows you to specify dependencies between components with set(CPACK_DEB_component_PACKAGE_DEPENDS somelib, mypackage-mycomponent) The contents of patch_file: From 4183e838d9c12f9324bc74b88a164d127ab2bdd2 Mon Sep 17 00:00:00 2001 From: pjanicki pawel.janicki(-a-t-)skytechnology.pl Date: Wed, 4 Sep 2013 09:53:31 +0200 Subject: [PATCH] CPack: Add support component dependencies for DEB generator --- Modules/CPackDeb.cmake | 28 ++-- Source/CPack/cmCPackDebGenerator.cxx | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 75ff3be..937127e 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -36,6 +36,7 @@ ##end ##variable # CPACK_DEBIAN_PACKAGE_DEPENDS +# CPACK_DEB_component_PACKAGE_DEPENDS # Mandatory : NO # Default : - # May be used to set deb dependencies. @@ -204,6 +205,18 @@ if(FAKEROOT_EXECUTABLE) set(CPACK_DEBIAN_FAKEROOT_EXECUTABLE ${FAKEROOT_EXECUTABLE}) endif() +unset(CPACK_DEBIAN_PACKAGE_DEPENDS_TMP) + +function(append_comma_separated TARGET_VAR VALUE) + if(VALUE) +if(${TARGET_VAR}) + set(${TARGET_VAR} ${${TARGET_VAR}}, ${VALUE} PARENT_SCOPE) +else() + set(${TARGET_VAR} ${VALUE} PARENT_SCOPE) +endif() + endif() +endfunction() + if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) # dpkg-shlibdeps is a Debian utility for generating dependency list find_program(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps) @@ -277,11 +290,7 @@ if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) file(REMOVE_RECURSE ${CPACK_TEMPORARY_DIRECTORY}/debian) # Append user depend if set -if (CPACK_DEBIAN_PACKAGE_DEPENDS) - set (CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}) -else () - set (CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}) -endif () +append_comma_separated(CPACK_DEBIAN_PACKAGE_DEPENDS_TMP ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}) else () if(CPACK_DEBIAN_PACKAGE_DEBUG) @@ -335,7 +344,14 @@ endif() # Depends: # You should set: DEBIAN_PACKAGE_DEPENDS # TODO: automate 'objdump -p | grep NEEDED' -if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS) + +if(CPACK_DEB_PACKAGE_COMPONENT) + append_comma_separated(CPACK_DEBIAN_PACKAGE_DEPENDS_TMP ${CPACK_DEB_${CPACK_DEB_PACKAGE_COMPONENT}_PACKAGE_DEPENDS}) +else() + append_comma_separated(CPACK_DEBIAN_PACKAGE_DEPENDS_TMP ${CPACK_DEBIAN_PACKAGE_DEPENDS}) +endif() + +if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS_TMP) message(STATUS CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.) endif() diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 4494e8a..fb819f4 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -315,7 +315,7 @@ int cmCPackDebGenerator::createDeb() const char* desc = this-GetOption(CPACK_DEBIAN_PACKAGE_DESCRIPTION); // optional entries - const char* debian_pkg_dep = this-GetOption(CPACK_DEBIAN_PACKAGE_DEPENDS); + const char* debian_pkg_dep = this-GetOption(CPACK_DEBIAN_PACKAGE_DEPENDS_TMP); const char* debian_pkg_rec = this-GetOption(CPACK_DEBIAN_PACKAGE_RECOMMENDS); const char* debian_pkg_sug = -- 1.8.1.4 -- View this message in context: http://cmake.3232098.n2.nabble.com/CPack-DEB-depends-bug-fix-tp7560635p7585380.html Sent from the CMake mailing list archive at Nabble.com. -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] CPack DEB depends bug fix
Hi all, I experienced problems recently trying to use the CPack DEB packager with components and wanted to share my solution (thanks partly to Eric Noulard). The problem was with dependency generation in the Debian control file using the CPACK_DEBIAN_PACKAGE_SHLIBS flag. Dependencies would be generated, however each component would be incorrectly assigned all previously processed components' dependencies on top of its own. This would occur regardless of whether the user explicitly set any (additional) dependencies via CPACK_DEBIAN_PACKAGE_DEPENDS. eg. 3 components, 1 has dependencies A, B, C, 3 2 has dependencies D, E, F, 3 3 has dependencies G relevant config: set(CPACK_COMPONENTS_IGNORE_GROUPS TRUE) set(CPACK_DEB_COMPONENT_INSTALL TRUE) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE) We have no way of expressing dependencies between components for the purposes of Debian packaging (so far as I know) so 1 and 2 depending on 3 is not achievable. That aside, if processed 1 then 2, then 3, the resultant package 1 would depend on A, B, C, package 2 (incorrectly) on A, B, C, D, E, F and package 3 (incorrectly) on A, B, C, D, E, F, G. To fix I patched the CPackDeb.cmake script as follows, introducing new per-component user-defined dependency variable CPACK_DEB_component_PACKAGE_DEPENDS, which should be used over CPACK_DEBIAN_PACKAGE_DEPENDS if components are being used. 214,218c214,226 IF (CPACK_DEBIAN_PACKAGE_DEPENDS) SET (CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}) ELSE (CPACK_DEBIAN_PACKAGE_DEPENDS) SET (CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}) ENDIF (CPACK_DEBIAN_PACKAGE_DEPENDS) --- IF(CPACK_DEB_PACKAGE_COMPONENT) IF (CPACK_DEB_${CPACK_DEB_PACKAGE_COMPONENT}_PACKAGE_DEPENDS) SET (CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}, ${CPACK_DEB_${CPACK_DEB_PACKAGE_COMPONENT}_PACKAGE_DEPENDS}) ELSE (CPACK_DEB_${CPACK_DEB_PACKAGE_COMPONENT}_PACKAGE_DEPENDS) SET (CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}) ENDIF (CPACK_DEB_${CPACK_DEB_PACKAGE_COMPONENT}_PACKAGE_DEPENDS) ELSE (CPACK_DEB_PACKAGE_COMPONENT) IF (CPACK_DEBIAN_PACKAGE_DEPENDS) SET (CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}) ELSE (CPACK_DEBIAN_PACKAGE_DEPENDS) SET (CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}) ENDIF (CPACK_DEBIAN_PACKAGE_DEPENDS) ENDIF (CPACK_DEB_PACKAGE_COMPONENT) This config then will do the trick, also allowing 1 and 2's dependency on 3 to be expressed: set(CPACK_COMPONENTS_IGNORE_GROUPS TRUE) set(CPACK_DEB_COMPONENT_INSTALL TRUE) set(CPACK_DEB_1_PACKAGE_DEPENDS myproject-3) set(CPACK_DEB_2_PACKAGE_DEPENDS myproject-3) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE) I shall submit a bug report with advised patch in the next few days. Incidentally, I did stumble across another bug with the Debian packager unable to deal with components not containing any exe or lib files. Fortunately my final project layout avoided this scenario, but you've been warned! Regards, Jess -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake