Create debian package for script and simple project with cmake and cpack


if you have not a launchpad account and you want share with your friend your little project you can use cmake and cpack to create your package , you can do DEBIAN RPM and other package it’s very simple:

We will start with a simple example using one of my projects  so  download it here    kde apps

/home/stuff/kate-folder-service-menu-0.1.0
└── usr
    ├── bin
    │   └── ktexeditor-open-folder
    └── share
        └── kde4
            └── services
                └── ServiceMenus
                      └── kate-folder.desktop

so we have a bash script

ktexeditor-open-folder

and a service menu for dolphin

kate-folder.desktop

ok now create your /home/stuff/kate-folder-service-menu-0.1.0/CMakeLists.txt

    ##Cmake template for service menus

    cmake_minimum_required(VERSION 2.8)
    #SET THE NAME FOR YOUR SERVICE MENU
    PROJECT("kate-folder-servicemenu")
    SET (CMAKE_PROJECT_NAME "kate-folder-servicemenu")
    #search for the minimal version of kde 4.0
    find_package(KDE4 4.0.0 REQUIRED)

    include(KDE4Defaults)

    #install the service menu on the correct folder
    install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/usr/share/kde4/services/ServiceMenus/kate-folder.desktop DESTINATION
    ${SERVICES_INSTALL_DIR}/ServiceMenus )

     #install the script where you should be
     INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/usr/bin/ktexeditor-open-folder
      DESTINATION bin)

    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 "kate service menu for folders")
    SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "It's a service menu for dolphin that allow you to open folders skipping no-text files")
    SET(CPACK_PACKAGE_VENDOR "nowardev")
    SET(CPACK_PACKAGE_CONTACT "nowardev@gmail.com")
    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}")
    #demo dependencies
    #SET(CPACK_DEBIAN_PACKAGE_DEPENDS " kate , plasma-desktop, libc6 (>= 2.1.3) ")

    #dependencies for this service menu
    SET(CPACK_DEBIAN_PACKAGE_DEPENDS " kate , dolphin ")

    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")

after that you can always do

mkdir build ; cd build ; cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .. ; cpack ..

and you will get your debian package build 🙂

Kdenlive Cpack Debian compile it 2011


i want compile kdenlive with few steps!

PLEASE NOTE THIS IS NOT FOR NOOB!

Get the dependencies of kdenlive and freior

 dpkg -s kdenlive  | awk '/Depends: /{print}'

actually should be (this is kubuntu 11.04 but.. ) NOTE REMOVE KDENLIVE-DATA FROM THE LIST

kdebase-runtime, libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libgl1-mesa-glx | libgl1, libglu1-mesa | libglu1, libkdecore5 (>= 4:4.4.95), libkdeui5 (>= 4:4.5.80), libkio5 (>= 4:4.3.4), libknewstuff3-4 (>= 4:4.4.0), libknotifyconfig4 (>= 4:4.3.4), libkrossui4 (>= 4:4.3.4), libmlt++3, libmlt4, libnepomuk4 (>= 4:4.3.4), libqimageblitz4 (>= 1:0.0.4), libqjson0, libqt4-dbus (>= 4:4.6), libqt4-network (>= 4:4.6), libqt4-opengl (>= 4:4.6), libqt4-svg (>= 4:4.6), libqt4-xml (>= 4:4.6), libqtcore4 (>= 4:4.7.0~beta1), libqtgui4 (>= 4:4.6.2), libstdc++6 (>= 4.2.1), libx11-6, libxau6, libxdmcp6, libxext6, melt, libmlt-data, ffmpeg, swh-plugins, dvgrab, recordmydesktop, dvdauthor, genisoimage, xine-ui

for the frior pluing

 dpkg -s frei0r-plugins | awk '/Depends: /{print}'

you should get :

 Depends: libc6 (>= 2.4), libcv2.1, libcvaux2.1, libgavl1 (>= 1.1.0), libgcc1 (>= 1:4.1.1), libhighgui2.1, libstdc++6 (>= 4.5)

these informations will be used to modify Cmakelist

Install what you need to compile it in few steps

 sudo apt-get build-dep frei0r-plugins kdenlive melt libmlt3    libmlt++3   libmlt4   libmlt-data 

Get the source

  mkdir ~/kdenlivefolder; cd ~/kdenlivefolder ; svn co https://kdenlive.svn.sourceforge.net/svnroot/kdenlive/trunk/kdenlive  ; git clone git://git.dyne.org/frei0r.git 

Edit CMakeLists.txt for Freior

kate CMakeLists.txt

add this…


SET(MAJOR_VERSION 1)
SET(MINOR_VERSION 3)
SET(PATCH_VERSION "0+git10jun2011")

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 "miinimalistic plugin API for video effects,")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "minimalistic plugin API for video effects, plugins collection  frei0r is a minimalistic plugin API for video sources and filters. The  behavior of the effects can be controlled from the host by simple  parameters. The intent is to solve the recurring reimplementation or  adaptation issue of standard effects. It is not meant as a generic API for  all kinds of video applications.frei0r plugins are used by several projects (e.g.: LiVES, Veejay, Open Movie  Editor, FreeJ, Pure Data Visual Junk Tools, MLT framework).This package contains a collection of plugins. Homepage: http://www.piksel.org/frei0r")
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 "libc6 (>= 2.4), libcv2.1, libcvaux2.1, libgavl1 (>= 1.1.0), libgcc1 (>= 1:4.1.1), libhighgui2.1, libstdc++6 (>= 4.5)")

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")

Create the debian package

  cd frei0r ; mkdir build ; cd build ; cmake .. -DCMAKE_INSTALL_PREFIX=/usr ;cpack ..

before installing if you get some errors about :”/usr/include/frei0r.h”
please remove

sudo apt-get remove frei0r-plugins-dev

and now the same for kdenlive

Edit CMakeLists.txt for kdenlive

kate CMakeLists.txt

ADD THIS TO THE END

SET(MAJOR_VERSION 0)
SET(MINOR_VERSION 8)
SET(PATCH_VERSION "1~peace2")

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 "Video Editor made in qt")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "video editor packaged from peace ")
SET(CPACK_PACKAGE_VENDOR "Vendor")
SET(CPACK_PACKAGE_CONTACT "kdenlive developers ")
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, libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libgl1-mesa-glx | libgl1, libglu1-mesa | libglu1, libkdecore5 (>= 4:4.4.95), libkdeui5 (>= 4:4.5.80), libkio5 (>= 4:4.3.4), libknewstuff3-4 (>= 4:4.4.0), libknotifyconfig4 (>= 4:4.3.4), libkrossui4 (>= 4:4.3.4), libmlt++3, libmlt4, libnepomuk4 (>= 4:4.3.4), libqimageblitz4 (>= 1:0.0.4), libqjson0, libqt4-dbus (>= 4:4.6), libqt4-network (>= 4:4.6), libqt4-opengl (>= 4:4.6), libqt4-svg (>= 4:4.6), libqt4-xml (>= 4:4.6), libqtcore4 (>= 4:4.7.0~beta1), libqtgui4 (>= 4:4.6.2), libstdc++6 (>= 4.2.1), libx11-6, libxau6, libxdmcp6, libxext6, melt, libmlt-data, ffmpeg, swh-plugins, dvgrab, frei0r-plugins, recordmydesktop, dvdauthor, genisoimage, xine-ui")

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 create the debian package with

 cd kdenlive ; mkdir build; cd build; cmake .. -DCMAKE_INSTALL_PREFIX=/usr; cpack .. 

BEFORE INSTALLING THE PACKAGE DO

sudo apt-get purge kdenlive kdenlive-data

or you will get :
error about overwritting icons and stuff like that

now you have all the stuff

HUD kde kubuntu 12.10 alias search actions in the application menu


here there is how to compile it and i have tested on kubuntu 12.10

you can paste this code in the shell and it will do what it has to do … BUT IT WILL OPEN KATE CMakeLists.txt modify the CMakelists.txt add this stuff at the last line

code to add to CMakelists.txt , the code to paste in the shell is after this code…


SET(MAJOR_VERSION 0)
SET(MINOR_VERSION 0)
SET(PATCH_VERSION 1)

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 "Let you find and launch actions from the active application")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Krunner plugin that if activated from krunner configuration panel let you find and launch actions from the active application")
SET(CPACK_PACKAGE_VENDOR "peace")
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 "appmenu-qt (>= 0.2.6)")

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")
 

this code will install dependencies to compile
then download the code
then create some folders
then will open CMakelists file
then will create the debian package(if you have modified well the CMakelists.txt well )

 sudo apt-get install kdelibs5-dev libdbusmenu-qt-dev libqt4-dev build-essential cmake pkg-config pkg-kde-tools git-core &&cd $HOME &&git clone git://anongit.kde.org/scratch/afiestas/appmenu.git &&cd appmenu&&kate kate CMakeLists.txt &&mkdir build &&cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix) &&cpack .. 

ok now if you did well you should see the debian file (in the build directory)

so sudo dpkg -i plasma-appmenu*.deb

now login logout or run $ kbuildsycoca4 after that

do as he says here