Ubuntu – How to create a .deb package for a Qt programme

debpackage-managementpackaging

The past few days I have been trying, without success, to create a deb package for a programme with a Qt interface. The previous steps I have done so far:

  1. Created a gpg key and registered it at Launchpad;
  2. Identified myself with the DEBEMAIL and DEBFULLNAME variables in ~/.bashrc;
  3. Checked out the source code from GitHub;
  4. Successfully built the programme (it uses qmake to generate a Makefile), identifying all its dependencies;
  5. Created a source folder including the Makefile, plus a .desktop file and an .xpm icon.
  6. Created a tarball from this folder named packagename-version.tar.gz.

With this preparatory work I have tried to follow two different guides:

  • The official Ubuntu packaging guide – it concludes successfully, but the final .deb file only includes the doc folder.

  • A more detailed guide from xpressrazor – which fails when running debuild, with the following cryptic messages:

    make: *** [build] Error 2
    dpkg-buildpackage: error: debian/rules build gave error exit status 2
    debuild: fatal error at line 1364:
    dpkg-buildpackage -rfakeroot -D -us -uc failed

These and other guides out there invariably present simple examples where the programme to package is composed by a single source file (sometimes it is only a bash script). I suspect they are too simplistic for a proper programme with an elaborate GUI. In this case, what are the precise steps from dh_make onwards?

Update I: I posted to PasteBin an anonymised version of the full debuild output.

Update II: The debuild output, now with DH_VERBOSE=1.

Best Answer

As it happens, dh can not possibly be used to package a Qt programme in the traditional way presented in most guides and tutorials out there. More specifically, the rules file must be informed of which snippets it must use to include in the final Makefile.

One way of achieving this is using the cdbs package:

sudo apt-get install cdbs

Then the rules file must be edited to include the snippets from this package:

#!/usr/bin/make -f

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

These should be the only contents in the rules file, any direct references to dh must be removed or commented out.

At this time, debuild should be operational, it can be run like:

debuild -S