Creating Debian packages on your own

Slashdot it! Delicious Share on Facebook Tweet! Digg!

Satisfying Dependencies

Once you've installed the previously mentioned version 1.5 dev package on your system, the buildpackage takes its course. As with the update from version 1.3, a binary package is created without your needing to worry about details at compile time.

The many dh helper scripts combine into a powerful autopilot that compiles the source code of many programs without the manual application of the rules file. The command dh auto_configure automatically determines which build system (Autoconfigure, Cmake or Qmake) the program uses and makes the appropriate calls.

According to the dh_make developers, the success rate is around 90% for all programs. This means that you only need to run dpkg-source, dh_make, and dpkg-buildpackage with the source code and enter simple descriptions in the control file. You then automatically get a Debian package for the automatically compiled program.

That's an impressive achievement – although in practice a success rate of 90% without manual intervention might be a bit ambitious. A blind package development might not always be successful. Debugging errors implies knowing the content of the debian/ control directory and the function of the files contained therein.

Figure 4 shows the content that dh_make automatically creates in the upstream ffDiaporama source code. Fortunately, only three of the many files are absolutely necessary for building the package: control, rules, and changelog. The remaining files are meaningful for Debian policy-compliant packages [6], but play no role in building packages for your own use.

Figure 4: The dh_make tool prepares the software's source code for automatic compiling and packaging. The "debian/" control directory contains numerous template files (on the left), but only three of them (on the right) are strictly necessary.

Nitty-Gritty

I'll now compare the three relevant files in the original ffDiaporama package from the Ubuntu repository with the versions created by dh_make. They clearly show how they are used in automation, even if not all the visible changes for a successful build package process are clear.

The control file is a text file with descriptive data. Figure 5 shows the template that dh_make creates on the left, with the completed version from the Ubuntu package from Launchpad on the right. The short description (the first line after Description:) and the following multiline descriptions can easily be filled with the text from the program website. Added to it are the upstream URL and (specific to Debian) the uploader and the Git repository of the Debian package developers. Packages for home use don't need these fields; you can just replace the text between brackets on the left.

Figure 5: The "control" file contains descriptive data for package building and the subsequent binaries.

For Depends:, the automatically created control file contains only the variables ${shlibs:Depends} and ${misc:Depends} that the automatic build process completes with automatically calculated dependencies. Among them are all the shared libraries that link to the binaries contained in the package but not the standalone background programs. ffDiaporama calls FFmpeg and uses for it the ffmpeg packages as a (manual, exceptionally) registered dependency.

For your own packages, the entries under Build-Depends are unnecessary and are intended for repositories to be built on the distribution servers in a minimal environment. However, if your system provides all packages required for compiling, the buildpackage process can function even with empty Build-Depends. The build dependencies have no effect on the binary package during the build process.

Grayed out in Figure 5 on the right is a second Package: definition. Ubuntu developers divided ffDiaporama into two packages, ffdiaporama and ffdiaporama-data. For this to work, dpkg-buildpackage needs files with the names ffdiaporama.install and ffdiaporama-data.install that contain lists of files belonging to the subpackages. In this way, the distributors separate the 32-bit and the 64-bit installed system files from those used equally across platforms.

This process, however, belongs to a higher level of package building artistry. If the lines after Package: ffdiaporama-data and the .install files are missing, then a single ffdiaporama package is created that contains all files related to the program. It functions flawlessly on the architecture upon which it's built. The Debian build system (unlike RPM) then doesn't need a file list for its package content; it simply packages all the files added by make install.

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content