wiki:HowtoCDBS

Version 12 (modified by Thanatermesis, 5 years ago) ( diff )

--

/elive/images/tux-debian.png

What is

CDBS is the most easy tool in debian to create debian packages, you will need just 2-3 lines of code so that you will create your own debian packages

On this howto I will explain the basic steps to do this, but cdbs is a lot more powerful (hooks in pre-config, post-config, pre-compile, post-compile, etc etc), so for more information just follow the documented PDF as, of course, /usr/share/doc/cdbs

Dependencies

You basically only need the package cdbs, but is recommended also to install these packages: dpkg-dev devscripts

Hands on !

On this example we will create a debian package for enna under a Elive system

Download the sources of enna and create the directory debian (if is already created and has files mean that is already ready for create debian packages, or supposed to... in any case, if is created, just remove it in order to follow this howto).

On it, you need to have 2 files, control and rules

In the debian/control file has the description of the package, we can fill up with something like:

Source: enna
Section: enlightenment
Priority: optional
Maintainer: yourname <youremail@email.com>
Build-Depends: cdbs, autotools-dev, gnulib, debhelper, libplayer, gettext, libsqlite3-dev, lubcurl4-gnutls-dev, libdbus-1-dev, libx11-dev, libxml2-dev, libfreetype6-dev, libjpeg62-dev

Package: enna
Architecture: any
Depends: efl-all, libcddb2, libexif12, libhal-storage1, libhal1, libplayer, libsqlite3-0, libxml2, lightmediascanner, libxrandr2
Description: enna media player
 This is the enna media player using EFL

Note: These dependencies are a bit tricky here, the efl-all package will contain all the libs of EFL, but there's no a efl-all-dev package that will contain the rest of dependencies like libdbus, libcurl, libfreetype, etc, so just play with your own dependencies for your packages

The first block is for the source packages (so that you can apt-get source enna in the future in order to recompile it), it also contains the information about which dependencies you need to have in order to compile it. The second block is for the binary end package.

In the debian/rules file, you need to fill up with something like:

#!/usr/bin/make -f

DEB_AUTO_UPDATE_DEBIAN_CONTROL := yes

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

DEB_CONFIGURE_EXTRA_FLAGS := --disable-browser-netstreams --enable-libcddb --disable-browser-lms

The first line means that the control file will be updated automatically (it was really needed to explain this point ? anyways...), the next lines means which pieces of cdbs we want to have, like a dependency, if we don't include them, we don't have its support, like, debhelper contains all the needed things for build the package, autotools contains the needed things for compile a simple C/C++ program that has its makefiles structure and such... so, the basic needed ones. The final line includes the option of compilation.

Note: You need to made the rules file executable, so run: chmod +x debian/rules

You are almost ready, altough these are the only real needed files, you need a few last tricks... but they are almost automatic:

You need the changelog file, since we are lazy, we use the tool debchange to create/update it, see that there's a warning saying that there's no any changelog found and so on we need to use the option ---create for create a new one, so, from the directory of the source code (out of the debian dir), run: debchange --create

WARNING: It is very important that the changelog will have the CORRECT information or you can have problems by compiling the package, for example your PACKAGENAME needs to NOT be uppercase, etc, you can see examples in ls /usr/share/doc/*/changelog.Debian.gz

Your debian directory is ready, you can add a lot more of options and tricks for your package but for that, just follow the official documentation at /usr/share/doc/cdbs, im not going to write all the features because im lazy too :)

Time to build the package !

Since we are a user and no root, some commands needs to be prepend with the command fakeroot:

Before to compile you need to see if you have all the dependencies for the compilation, for that, just run the command dpkg-checkbuilddeps

It is very possible that you will need to add more dependencies, see if the build give you a compilation error and install the remaining needed dependencies, this step is a bit a pain but it is extremely important to add all the needed dependencies to the control.in file, if not, when you will apt-get source enna to compile it yourself, it will not compile.

So, the steps are:

  • Every time a new dependency is needed/found, add it to the control.in file
  • Install the dependency
  • Run the combo command: fakeroot debian/rules clean ; dpkg-checkbuilddeps && fakeroot dpkg-buildpackage -b

When you have finally builded the package, is time to build a real one (with source packages and such): run the command fakeroot dpkg-buildpackage

You have it !

Final points

Warning: If you see errors like dpkg-shlibdeps: failure: no dependency information found for /usr/lib..., this means that the equilvalent lib was not builded using a debian packager system (so, manually compiled), in other words, you should package in the debian way this package too. So it is possible that this example will not work (the EFL libs in Elive are not packaged with debian packaging tools, but with a own Elive packager tool)

You are free to edit this document in order to fix any thing, making it better, or to add a few nice tricks to know, for that just fill up a collaborator thingy at http://www.elivecd.org/Help/Collaborate

You can see some nice and small examples of CDBS in the EFL svn, for example in evas, it use it for build the packages (at least to the date of today)

Interesting Links and more Info

http://debathena.mit.edu/packaging/ file:///usr/share/debhelper/dh_make/

Note: See TracWiki for help on using the wiki.