« Créer un paquet debian (.deb) d'un projet utilisant CMake » : différence entre les versions
Aller à la navigation
Aller à la recherche
Aucun résumé des modifications |
Aucun résumé des modifications |
||
(9 versions intermédiaires par le même utilisateur non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
[[category:desktop]][[category:debian]] | |||
A la source du projet en question, ouvrez le fichier <code>CMakeLists.txt</code> et ajoutez y à la fin : | A la source du projet en question, ouvrez le fichier <code>CMakeLists.txt</code> et ajoutez y à la fin : | ||
<pre> | <pre> | ||
Ligne 4 : | Ligne 6 : | ||
SET(MINOR_VERSION 0) | SET(MINOR_VERSION 0) | ||
SET(PATCH_VERSION 0) | SET(PATCH_VERSION 0) | ||
IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") | IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") | ||
INCLUDE(InstallRequiredSystemLibraries) | INCLUDE(InstallRequiredSystemLibraries) | ||
SET(CPACK_SET_DESTDIR "on") | SET(CPACK_SET_DESTDIR "on") | ||
SET(CPACK_PACKAGING_INSTALL_PREFIX "/tmp") | SET(CPACK_PACKAGING_INSTALL_PREFIX "/tmp") | ||
SET(CPACK_GENERATOR "DEB") | 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 "short description") | ||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "long description | SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "long description ...") | ||
SET(CPACK_PACKAGE_VENDOR "Vendor") | SET(CPACK_PACKAGE_VENDOR "Vendor") | ||
SET(CPACK_PACKAGE_CONTACT "developer ") | SET(CPACK_PACKAGE_CONTACT "developer ") | ||
Ligne 19 : | Ligne 27 : | ||
SET(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}") | SET(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}") | ||
SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}") | SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}") | ||
SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}") | |||
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_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}") | ||
SET(CPACK_COMPONENTS_ALL Libraries ApplicationData) | SET(CPACK_COMPONENTS_ALL Libraries ApplicationData) | ||
INCLUDE(CPack) | INCLUDE(CPack) | ||
Ligne 36 : | Ligne 49 : | ||
Vous pouvez éditer les variables : | 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 | * 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 | * 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 <code>dpkg --info</code> | ||
* CPACK_DEBIAN_PACKAGE_SECTION afin de définir la [https://packages.debian.org/jessie/ section du paquet.] | * CPACK_DEBIAN_PACKAGE_SECTION afin de définir la [https://packages.debian.org/jessie/ 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 : | Pour construire le paquet : |
Dernière version du 7 juillet 2017 à 05:35
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