« Créer un paquet debian (.deb) d'un projet utilisant CMake » : différence entre les versions

De Linux Server Wiki
Aller à la navigation Aller à la recherche
(Page créée avec « A la source du projet en question, ouvrez le fichier <code>CMakeLists.txt</code> et ajoutez y à la fin : <pre> SET(MAJOR_VERSION 1) SET(MINOR_VERSION 0) SET(PATCH_VERSION... »)
 
Aucun résumé des modifications
Ligne 45 : Ligne 45 :
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
cpack ..
cpack ..
</pre>
Vous pouvez vérifier les fichiers présents dans l'archive .deb et les informations du paquet :
<pre>
dpkg -c package.deb
dpkg --info package.deb
</pre>
</pre>

Version du 25 juin 2017 à 12:37

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")
 
SET(CPACK_PACKAGE_DESCRIPTION "short description")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "long description bla bla bla... bah")
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_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_DEBIAN_PACKAGE_DEPENDS "kdebase-runtime (>= 4:4.2.1), kdelibs5 (>= 4:4.2.1), libc6 (>= 2.1.3), libgcc1 (>= 1:4.1.1), libplasma3, libqt4-dbus (>= 4.5.0), libqtcore4 (>= 4.5.0), libqtgui4 (>= 4.5.0), libstdc++6 (>= 4.2.1)")
 
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
SET(CPACK_DEBIAN_PACKAGE_SECTION "kde")
SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
 
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 en extrayant une archive .deb du projet (ar vx package.deb) dans le fichier control de l'archive control.tar.gz
  • CPACK_DEBIAN_PACKAGE_SECTION afin de définir la section du paquet.

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