Créer un paquet debian (.deb) d'un projet utilisant CMake
Aller à la navigation
Aller à la recherche
A la source du projet en question, ouvrez le fichier CMakeLists.txt
et ajoutez y à la fin :
SET(MAJOR_VERSION 1) SET(MINOR_VERSION 0) SET(PATCH_VERSION 0) IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") INCLUDE(InstallRequiredSystemLibraries) SET(CPACK_SET_DESTDIR "on") SET(CPACK_PACKAGING_INSTALL_PREFIX "/tmp") SET(CPACK_GENERATOR "DEB") find_program(DPKG_CMD dpkg) execute_process(COMMAND "${DPKG_CMD}" --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE ) SET(CPACK_PACKAGE_DESCRIPTION "short description") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "long description ...") SET(CPACK_PACKAGE_VENDOR "Vendor") SET(CPACK_PACKAGE_CONTACT "developer ") SET(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}") SET(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}") SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}") SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") SET(CPACK_DEBIAN_PACKAGE_SECTION "net") SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libgcc1, libstdc++6, libqt5concurrent5, libqt5designer5, libqt5network5, libqt5xml5, libqt5svg5, libqt5x11extras5, libqt5multimedia5, libqt5multimedia5-plugins, libquazip5-1 | libquazip-qt5-1 | libquazip-qt5, libpython2.7-stdlib, libpythonqt-qt5") SET(CPACK_DEBIAN_PACKAGE_RECOMMENDS "sni-qt, python-crypto") SET(CPACK_DEBIAN_PACKAGE_SUGGESTS "") SET(CPACK_DEBIAN_PACKAGE_BREAKS "") SET(CPACK_DEBIAN_PACKAGE_CONFLICTS "") SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "you <you@domain.tld>") SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://upstream.tld") SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}") SET(CPACK_COMPONENTS_ALL Libraries ApplicationData) INCLUDE(CPack) ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
Vous pouvez éditer les variables :
- MAJOR_VERSION, MINOR_VERSION et PATCH_VERSION afin de générer un fichier contenant les bons numéros de version (projet_MAJOR_VERSION.MINOR_VERSION.PATCH_VERSION.deb
- CPACK_DEBIAN_PACKAGE_DEPENDS afin de matcher les dépendances du projet d'origine. Vous pouvez éventuellement retrouver les dépendances dans un paquet .deb du projet avec
dpkg --info
- CPACK_DEBIAN_PACKAGE_SECTION afin de définir la section du paquet.
- CPACK_PACKAGE_DESCRIPTION et CPACK_PACKAGE_DESCRIPTION_SUMMARY
- CPACK_PACKAGE_VENDOR et CPACK_PACKAGE_CONTACT
Les différentes variables existantes : https://cmake.org/cmake/help/latest/module/CPackDeb.html et https://cmake.org/cmake/help/latest/module/CPack.html
Pour construire le paquet :
mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=/usr .. cpack ..
Vous pouvez vérifier les fichiers présents dans l'archive .deb et les informations du paquet :
dpkg -c package.deb dpkg --info package.deb