Recent Posts

Archives

Topics


« | Main | »

Apport integration

By insanity | December 25, 2009

So for the last day or two I have been attempting to add support for bug reports from within the application.  In the spirit of open-source, I have searched around and found that Apport seems to be heavily used in Ubuntu, and has clean integration with http://bugs.launchpad.net/, which is my chosen bug tracking system for these projects.

Unfortunately, in the other spirit of open-source, the simple documentation is lacking a bit, so this blog post will hopefully help pave the way for people who might follow in my footsteps.

Intended Use

Basically, within one of the applications, I desired to have a link available in a menu that simply says “Report a problem”, which then submits a prefilled report to a bug tracking system including important information such as which version is being run, OS details etc.  My experience with Ubuntu has taught me that Apport is an ideal system that already supports the intended use-case, and is integrated into some existing apps in the same way that I’m looking for.

UbuntuOne Apport Configuration

The existing documentation that I referenced most heavily was found at https://wiki.ubuntu.com/Apport and https://wiki.ubuntu.com/Apport/DeveloperHowTo.  The first thing that struck me was that there seems to be no simple uses cases for what I thought would have been a reasonably commonly required use case, i.e., how to integrate with an app being released from a launchpad-hosted ppa.  The existing apport configuration makes apport-bug prevent reports being generated for non-Ubuntu packages (i.e., packages that are not in the main Ubuntu repositories).  This creates a hassle if releasing from a private or team ppa.

Fortunately, through browsing /etc/apport/ I found that the ubuntuone-client already uses apport with a non-genuine Ubuntu package.  This is done by placing a config file in /etc/apport/crashdb.conf.d, and an apport hook in /usr/share/apport/package-hooks/source_ubuntuone-client.py.

Basic Configuration

So, from all this, the most simple example I can come up with is the following.  To configure Apport to behave with an application, the following steps are required.

1. Configure the CrashDb

Place a CrashDb config file in /etc/apport/crashdb.conf.d called <package-name>-crashdb.conf (note: you can actually called it whatever you want… but for sanity’s sake I’d keep it as package-name ;) ).  Inside this file place something similar to the following:

<package-name> = {
 'impl' : 'launchpad',
 'project' : '<package-name>',
 'bug_pattern_base' : None,
}

2. Install an apport hook to specify the CrashDb

Place a file in /usr/share/apport/package-hooks called <package-name>.py or source_<package-name>.py.  This file should contain the following, which simply  sets the CrashDb to use the correct configuration:

import apport

def add_info(report):
 """add report info"""

 if not apport.packaging.is_distro_package(report['Package'].split()[0]):
 report['ThirdParty'] = 'True'
 # replace <package-name> with the crashdb config defined in the previous step
 report['CrashDB'] = '<package-name>'

Testing the settings…

Assuming all has been correctly set up, you should now be able to report bugs against the custom package by entering the following command in a terminal (or using alt+f2):

ubuntu-bug <package-name>

This will open up a window allowing you to send a report.  If you click submit, you should be taken to launchpad, with a new bug being logged against the specified application.

Topics: General, Linux, Programming | 2 Comments »

2 Responses to “Apport integration”

  1. Flimm Says:
    January 30th, 2010 at 12:45 am

    Thanks, that was very helpful.

  2. Severin Says:
    February 5th, 2010 at 7:28 am

    This guide is exactly what I’ve been looking for. Thanks alot!

    Too bad that due to a bug introduced in Apport 1.10, the described approach won’t work anymore because the hook is called to late and thus Apport will always report that the package is not a “genuine” distro package (because ‘CrashDB’ hasn’t been set yet).

    I just reported the bug to the Apport developers: https://bugs.edge.launchpad.net/ubuntu/+source/apport/+bug/517272

Comments