summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/CPackDeb.cmake145
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx10
2 files changed, 140 insertions, 15 deletions
diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake
index f5ca592..18acfb7 100644
--- a/Modules/CPackDeb.cmake
+++ b/Modules/CPackDeb.cmake
@@ -1,15 +1,18 @@
# - The builtin (binary) CPack Deb generator (Unix only)
# CPackDeb may be used to create Deb package using CPack.
# CPackDeb is a CPack generator thus it uses the CPACK_XXX variables
-# used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration
+# used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration.
+# CPackDeb generator should work on any linux host but it will
+# produce better deb package when Debian specific tools 'dpkg-xxx'
+# are usable on the build system.
#
-# However CPackRPM has specific features which are controlled by
-# the specifics CPACK_RPM_XXX variables.You'll find a detailed usage on
-# the wiki:
+# CPackDeb has specific features which are controlled by
+# the specifics CPACK_DEBIAN_XXX variables.You'll find a detailed usage on
+# the wiki:
# http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
# However as a handy reminder here comes the list of specific variables:
#
-# CPACK_DEBIAN_PACKAGE_NAME
+# CPACK_DEBIAN_PACKAGE_NAME
# Mandatory : YES
# Default : CPACK_PACKAGE_NAME (lower case)
# The debian package summary
@@ -19,12 +22,12 @@
# The debian package version
# CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
# Mandatory : YES
-# Default : Output of dpkg --print-architecture or i386
+# Default : Output of dpkg --print-architecture (or i386 if dpkg is not found)
# The debian package architecture
# CPACK_DEBIAN_PACKAGE_DEPENDS
# Mandatory : NO
# Default : -
-# May be used to set deb dependencies.
+# May be used to set deb dependencies.
# CPACK_DEBIAN_PACKAGE_MAINTAINER
# Mandatory : YES
# Default : CPACK_PACKAGE_CONTACT
@@ -41,6 +44,25 @@
# Mandatory : YES
# Default : 'optional'
# The debian package priority
+# CPACK_DEBIAN_PACKAGE_HOMEPAGE
+# Mandatory : NO
+# Default : -
+# The URL of the web site for this package
+# CPACK_DEBIAN_PACKAGE_SHLIBDEPS
+# Mandatory : NO
+# Default : OFF
+# May be set to ON in order to use dpkg-shlibdeps to generate
+# better package dependency list.
+# You may need set CMAKE_INSTALL_RPATH toi appropriate value
+# if you use this feature, because if you don't dpkg-shlibdeps
+# may fail to find your own shared libs.
+# See http://www.cmake.org/Wiki/CMake_RPATH_handling.
+# CPACK_DEBIAN_PACKAGE_DEBUG
+# Mandatory : NO
+# Default : -
+# May be set when invoking cpack in order to trace debug informations
+# during CPackDeb run.
+
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
@@ -69,6 +91,103 @@ IF(NOT UNIX)
MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.")
ENDIF(NOT UNIX)
+# CPACK_DEBIAN_PACKAGE_SHLIBDEPS
+# If specify OFF, only user depends are used
+IF(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
+ SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF)
+ENDIF(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
+
+IF(CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
+ # dpkg-shlibdeps is a Debian utility for generating dependency list
+ FIND_PROGRAM(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps)
+
+ # Check version of the dpkg-shlibdeps tool using CPackRPM method
+ IF(SHLIBDEPS_EXECUTABLE)
+ EXECUTE_PROCESS(COMMAND ${SHLIBDEPS_EXECUTABLE} --version
+ OUTPUT_VARIABLE _TMP_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ STRING(REGEX MATCH "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)"
+ SHLIBDEPS_EXECUTABLE_VERSION
+ ${_TMP_VERSION})
+ SET(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
+ IF(CPACK_DEBIAN_PACKAGE_DEBUG)
+ MESSAGE( "CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>")
+ ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG)
+
+ # Generating binary list - Get type of all install files
+ EXECUTE_PROCESS(COMMAND find -type f
+ COMMAND xargs file
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ OUTPUT_VARIABLE CPACK_DEB_INSTALL_FILES)
+
+ # Convert to CMake list
+ STRING(REGEX REPLACE "\n" ";" CPACK_DEB_INSTALL_FILES ${CPACK_DEB_INSTALL_FILES})
+
+ # 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})
+ ENDIF()
+ ENDFOREACH()
+
+ MESSAGE( "CPackDeb: - Generating dependency list")
+
+ # Create blank control file for running dpkg-shlibdeps
+ # There might be some other way to invoke dpkg-shlibdeps without creating this file
+ # but standard debian package should not have anything that can collide with this file or directory
+ FILE(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian)
+ FILE(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "")
+
+ # Execute dpkg-shlibdeps
+ # --ignore-missing-info : allow dpkg-shlibdeps to run even if some libs do not belong to a package
+ # -O : print to STDOUT
+ EXECUTE_PROCESS(COMMAND ${SHLIBDEPS_EXECUTABLE} --ignore-missing-info -O ${CPACK_DEB_BINARY_FILES}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ OUTPUT_VARIABLE SHLIBDEPS_OUTPUT
+ RESULT_VARIABLE SHLIBDEPS_RESULT
+ ERROR_VARIABLE SHLIBDEPS_ERROR
+ OUTPUT_STRIP_TRAILING_WHITESPACE )
+ IF(CPACK_DEBIAN_PACKAGE_DEBUG)
+ # dpkg-shlibdeps will throw some warnings if some input files are not binary
+ MESSAGE( "CPackDeb Debug: dpkg-shlibdeps warnings \n${SHLIBDEPS_ERROR}")
+ ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG)
+ IF (NOT SHLIBDEPS_RESULT EQUAL 0)
+ MESSAGE (FATAL_ERROR "CPackDeb: dpkg-shlibdeps: ${SHLIBDEPS_ERROR}")
+ ENDIF (NOT SHLIBDEPS_RESULT EQUAL 0)
+
+ #Get rid of prefix generated by dpkg-shlibdeps
+ string (REGEX REPLACE "^.*Depends=" "" CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS ${SHLIBDEPS_OUTPUT})
+
+ IF(CPACK_DEBIAN_PACKAGE_DEBUG)
+ MESSAGE( "CPackDeb Debug: Found dependency: ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
+ ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG)
+
+ # Remove blank control file
+ # Might not be safe if package actual contain file or directory named debian
+ 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 (CPACK_DEBIAN_PACKAGE_DEPENDS)
+ SET (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
+ ENDIF (CPACK_DEBIAN_PACKAGE_DEPENDS)
+
+ ELSE (SHLIBDEPS_EXECUTABLE)
+ IF(CPACK_DEBIAN_PACKAGE_DEBUG)
+ MESSAGE( "CPackDeb Debug: Using only user-provided depends because dpkg-shlibdeps is not found.")
+ ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG)
+ ENDIF(SHLIBDEPS_EXECUTABLE)
+
+ELSE (CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
+ IF(CPACK_DEBIAN_PACKAGE_DEBUG)
+ MESSAGE( "CPackDeb Debug: Using only user-provided depends")
+ ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG)
+ENDIF(CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
+
# Let's define the control file found in debian package:
# Binary package:
@@ -84,7 +203,7 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_NAME)
# Version: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_VERSION)
IF(NOT CPACK_PACKAGE_VERSION)
- MESSAGE(FATAL_ERROR "Debian package requires a package version")
+ MESSAGE(FATAL_ERROR "CPackDeb: Debian package requires a package version")
ENDIF(NOT CPACK_PACKAGE_VERSION)
SET(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
ENDIF(NOT CPACK_DEBIAN_PACKAGE_VERSION)
@@ -95,7 +214,7 @@ IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
# $ dpkg --print-architecture
FIND_PROGRAM(DPKG_CMD dpkg)
IF(NOT DPKG_CMD)
- MESSAGE(STATUS "Can not find dpkg in your path, default to i386.")
+ MESSAGE(STATUS "CPackDeb: Can not find dpkg in your path, default to i386.")
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
ENDIF(NOT DPKG_CMD)
EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
@@ -116,7 +235,7 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
# Maintainer: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
IF(NOT CPACK_PACKAGE_CONTACT)
- MESSAGE(FATAL_ERROR "Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER")
+ MESSAGE(FATAL_ERROR "CPackDeb: Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER")
ENDIF(NOT CPACK_PACKAGE_CONTACT)
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
ENDIF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
@@ -124,7 +243,7 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
# Description: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
- MESSAGE(FATAL_ERROR "Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
+ MESSAGE(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
ENDIF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
@@ -147,13 +266,13 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY )
# CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
# This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive)
-# Typical examples are:
+# Typical examples are:
# - conffiles
# - postinst
# - postrm
# - prerm"
# Usage:
-# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
+# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
# "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index cee24ef..0d95721 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -87,10 +87,12 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
// optional entries
const char* debian_pkg_dep = this->GetOption("CPACK_DEBIAN_PACKAGE_DEPENDS");
- const char* debian_pkg_rec =
+ const char* debian_pkg_rec =
this->GetOption("CPACK_DEBIAN_PACKAGE_RECOMMENDS");
- const char* debian_pkg_sug =
+ const char* debian_pkg_sug =
this->GetOption("CPACK_DEBIAN_PACKAGE_SUGGESTS");
+ const char* debian_pkg_url =
+ this->GetOption("CPACK_DEBIAN_PACKAGE_HOMEPAGE");
{ // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(ctlfilename.c_str());
@@ -111,6 +113,10 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
{
out << "Suggests: " << debian_pkg_sug << "\n";
}
+ if(debian_pkg_url)
+ {
+ out << "Homepage: " << debian_pkg_url << "\n";
+ }
unsigned long totalSize = 0;
{
std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");