A Debian Package Management API: libapt
I had a hard time finding my way to writing tools based on libapt. Amusingly, what got me started was to use Graphviz to work out header dependencies.
1 Libraries and Packages
In fairness, this post became more about working out header dependencies than libapt itself. So just for the sake doing justice to its title, a few words about libapt. The libapt-* development libraries provide the highest-level Debian package management interface and are available in the following packages:
libapt-front-dev– the highest-level libraries;libapt-pkg-dev– high-level libraries, though not as high aslibapt-front-dev.
Sadly, I couldn't get my hands on the documentation. This gave me a hard time understanding how to get started with these libraries, and that's how I got sidetracked and started looking for a way to identify header dependencies, instead, a way which will in fact work for any headers out there.
2 Header Dependencies
I wrote a little sed expression to draw dependencies between headers, which may be a start to using a library if there's otherwise little documentation. For instance, in the case of libapt, execute the following command line in /usr/include/apt-pkg:
grep "#include <apt-pkg/" * | sed -e 's/^\([a-z0-9\.-]\+\):#include <apt-pkg\/\([a-z0-9\.-]\+\)>/"\1" -> "\2"/'This will generate a Graphviz graph which you can pass on to the dot command, that will turn it into this nice diagram:
For instance, this graph helps us see that the debfile.h may be a good starting point to get information from a .deb file. Food for thought.

