how to create a debian package for script and for project that use Cmake
December 27, 2009 Leave a Comment
Create a debian package with Cmake and Cpack
thank you a some article from some article on ubuntu forums and thank to this italian website
http://toastedtech.wordpress.com
i was be able to create a nice debian package with few works.
if you have a project that use cmake you can create a package deb but even other kind of package like rpm using cpack.
Open cmake file and add to the end this
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")
now you have only to use :
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
cpack ..
dpkg -i pacchetto_.deb
cpack will create for you the debian package.
Now supposing to create a debian package if you have just create a simple script …
SUPPOSING TO CREATE A PACKAGE FOR RAI-QT 0.3.1
create a folder (you have to create like that!)
mkdir rai-qt_0.3.1_all
now create a folder where your script should be copied for example
/usr/bin
icons should be copied on
/usr/share/icons
launchers shoul be copied on
/usr/share/applications
so now create on rai-qt_0.3.1_all/usr other 3 folders
mkdir $HOME/rai-qt_0.3.1_all && mkdir $HOME/rai-qt_0.3.1_all/usr &&mkdir $HOME/rai-qt_0.3.1_all/usr/bin && mkdir $HOME/rai-qt_0.3.1_all/usr/share && mkdir $HOME/rai-qt_0.3.1_all/usr/share/icons && mkdir $HOME/rai-qt_0.3.1_all/usr/share/applications && mkdir $HOME/rai-qt_0.3.1_all/DEBIAN
Now create a file called rai-qt.desktop on $HOME/rai-qt_0.3.1_all/usr/share/applications
[Desktop Entry]
Name=Rai-qt
Comment=Script to see audio e video streaming for italian user, radio rai mediaset streaming
Comment[it]=Script per vedere streaming rai tramite vlc, mediaset è in testing.
Exec=rai-qt
Terminal=false
Type=Application
Icon=media-tape
Categories=AudioVideo;KDE
Name[it]=Rai-qt
GenericName=Rai-qt
now create a file control that you should copy on
$HOME/rai-qt_0.3.1_all/DEBIAN/control
Package: rai-qt
Version: 0.3.1
Section: AudioVideo;KDE
Priority: optional
Architecture: all
Depends: vlc, kdebase-bin
Installed-Size: 3,5k
Homepage: http://www.kde-apps.org/content/show.php/Rai-qt?content=112093
Description: A script with kdialog interface to see rai channels and radio with vlc
Maintainer: NowarDev-Team
there are a lots of option to add but here for this experiment i used only these.
Now
fakeroot dpkg -b rai-qt_0.3.1_all

