1# - The builtin (binary) CPack Deb generator (Unix only) 2# CPackDeb may be used to create Deb package using CPack. 3# CPackDeb is a CPack generator thus it uses the CPACK_XXX variables 4# used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration 5# 6# However CPackRPM has specific features which are controlled by 7# the specifics CPACK_RPM_XXX variables.You'll find a detailed usage on 8# the wiki: 9# http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29 10# However as a handy reminder here comes the list of specific variables: 11# 12# CPACK_DEBIAN_PACKAGE_NAME 13# Mandatory : YES 14# Default : CPACK_PACKAGE_NAME (lower case) 15# The debian package summary 16# CPACK_DEBIAN_PACKAGE_VERSION 17# Mandatory : YES 18# Default : CPACK_PACKAGE_VERSION 19# The debian package version 20# CPACK_DEBIAN_PACKAGE_ARCHITECTURE) 21# Mandatory : YES 22# Default : Output of dpkg --print-architecture or i386 23# The debian package architecture 24# CPACK_DEBIAN_PACKAGE_DEPENDS 25# Mandatory : NO 26# Default : - 27# May be used to set deb dependencies. 28# CPACK_DEBIAN_PACKAGE_MAINTAINER 29# Mandatory : YES 30# Default : CPACK_PACKAGE_CONTACT 31# The debian package maintainer 32# CPACK_DEBIAN_PACKAGE_DESCRIPTION 33# Mandatory : YES 34# Default : CPACK_PACKAGE_DESCRIPTION_SUMMARY 35# The debian package description 36# CPACK_DEBIAN_PACKAGE_SECTION 37# Mandatory : YES 38# Default : 'devel' 39# The debian package section 40# CPACK_DEBIAN_PACKAGE_PRIORITY 41# Mandatory : YES 42# Default : 'optional' 43# The debian package priority 44 45#============================================================================= 46# Copyright 2007-2009 Kitware, Inc. 47# Copyright 2007-2009 Mathieu Malaterre <mathieu.malaterre@gmail.com> 48# 49# Distributed under the OSI-approved BSD License (the "License"); 50# see accompanying file Copyright.txt for details. 51# 52# This software is distributed WITHOUT ANY WARRANTY; without even the 53# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 54# See the License for more information. 55#============================================================================= 56# (To distributed this file outside of CMake, substitute the full 57# License text for the above reference.) 58 59# CPack script for creating Debian package 60# Author: Mathieu Malaterre 61# 62# http://wiki.debian.org/HowToPackageForDebian 63 64IF(CMAKE_BINARY_DIR) 65 MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.") 66ENDIF(CMAKE_BINARY_DIR) 67 68IF(NOT UNIX) 69 MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.") 70ENDIF(NOT UNIX) 71 72# Let's define the control file found in debian package: 73 74# Binary package: 75# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles 76 77# DEBIAN/control 78# debian policy enforce lower case for package name 79# Package: (mandatory) 80IF(NOT CPACK_DEBIAN_PACKAGE_NAME) 81 STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME) 82ENDIF(NOT CPACK_DEBIAN_PACKAGE_NAME) 83 84# Version: (mandatory) 85IF(NOT CPACK_DEBIAN_PACKAGE_VERSION) 86 IF(NOT CPACK_PACKAGE_VERSION) 87 MESSAGE(FATAL_ERROR "Debian package requires a package version") 88 ENDIF(NOT CPACK_PACKAGE_VERSION) 89 SET(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) 90ENDIF(NOT CPACK_DEBIAN_PACKAGE_VERSION) 91 92# Architecture: (mandatory) 93IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) 94 # There is no such thing as i686 architecture on debian, you should use i386 instead 95 # $ dpkg --print-architecture 96 FIND_PROGRAM(DPKG_CMD dpkg) 97 IF(NOT DPKG_CMD) 98 MESSAGE(STATUS "Can not find dpkg in your path, default to i386.") 99 SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386) 100 ENDIF(NOT DPKG_CMD) 101 EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture 102 OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE 103 OUTPUT_STRIP_TRAILING_WHITESPACE 104 ) 105ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) 106 107# have a look at GET_PROPERTY(result GLOBAL PROPERTY ENABLED_FEATURES), 108# this returns the successful FIND_PACKAGE() calls, maybe this can help 109# Depends: 110# You should set: DEBIAN_PACKAGE_DEPENDS 111# TODO: automate 'objdump -p | grep NEEDED' 112IF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS) 113 MESSAGE(STATUS "CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.") 114ENDIF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS) 115 116# Maintainer: (mandatory) 117IF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER) 118 IF(NOT CPACK_PACKAGE_CONTACT) 119 MESSAGE(FATAL_ERROR "Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER") 120 ENDIF(NOT CPACK_PACKAGE_CONTACT) 121 SET(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) 122ENDIF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER) 123 124# Description: (mandatory) 125IF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) 126 IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) 127 MESSAGE(FATAL_ERROR "Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION") 128 ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) 129 SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) 130ENDIF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) 131 132# Section: (recommended) 133IF(NOT CPACK_DEBIAN_PACKAGE_SECTION) 134 SET(CPACK_DEBIAN_PACKAGE_SECTION "devel") 135ENDIF(NOT CPACK_DEBIAN_PACKAGE_SECTION) 136 137# Priority: (recommended) 138IF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY) 139 SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") 140ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY ) 141 142# Recommends: 143# You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS 144 145# Suggests: 146# You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS 147 148# CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA 149# This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive) 150# Typical examples are: 151# - conffiles 152# - postinst 153# - postrm 154# - prerm" 155# Usage: 156# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA 157# "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm") 158 159 160# For debian source packages: 161# debian/control 162# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles 163 164# .dsc 165# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles 166 167# Builds-Depends: 168#IF(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS) 169# SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS 170# "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4" 171# ) 172#ENDIF(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS) 173 174# Description: (mandatory) 175#if(NOT CPACK_SECTION) 176# message(FATAL_ERROR "opkg package requires a package section") 177#endif(NOT CPACK_SECTION) 178 179# Package for opkg 180FIND_PROGRAM(OPKG_CMD opkg-build) 181if( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" ) 182 message("CPack: opkg-build not found. Skipping packaging") 183else( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" ) 184 SET(CPACK_OPKG_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") 185 FILE(MAKE_DIRECTORY ${CPACK_OPKG_ROOTDIR}/CONTROL) 186 set(CPACK_OPKG_CONTROL_FILE "${CPACK_OPKG_ROOTDIR}/CONTROL/control") 187 # Write controlfile 188 FILE(WRITE ${CPACK_OPKG_CONTROL_FILE} 189 "Package: ${CPACK_PACKAGE_NAME} 190Version: ${CPACK_PACKAGE_VERSION} 191Description: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} 192Architecture: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE} 193Section: ${CPACK_DEBIAN_PACKAGE_SECTION} 194Priority: optional 195Maintainer: ${CPACK_DEBIAN_PACKAGE_MAINTAINER} 196Depends: 197Provides: ${CPACK_DEBIAN_PACKAGE_PROVIDES} 198Replaces: ${CPACK_DEBIAN_PACKAGE_REPLACES} 199Conflicts: ${CPACK_DEBIAN_PACKAGE_CONFLICTS} 200Source: https://github.com/intel-iot-devkit/mraa 201#Essential: no 202") 203 204set(OPKG_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") 205 execute_process( 206 COMMAND "${OPKG_CMD}" "-o" "0" "${CPACK_PACKAGE_FILE_NAME}" "." 207 RESULT_VARIABLE _result 208 OUTPUT_VARIABLE _res_output 209 ERROR_VARIABLE _res_error 210 WORKING_DIRECTORY ${CPACK_TOPLEVEL_DIRECTORY} 211 ) 212 213 if(${_result}) 214 message("Result '${_result}'") 215 message("Output '${_res_output}'") 216 message("Error '${_res_error}'") 217 else(${_result}) 218 message("CPack: Package ${OPKG_FILE_NAME}.ipk generated.") 219 set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") 220 file(RENAME ${CPACK_TOPLEVEL_DIRECTORY}/${OPKG_FILE_NAME}.ipk ${CPACK_BINARY_DIR}/${OPKG_FILE_NAME}.ipk) 221 endif(${_result}) 222endif( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" ) 223