[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Interfaces for dpkg/deb packages


That little example is very cool and sure do appreciate you taking the time to help me out.  I got the source code and can take if from here. Thank-you very much.

-- christopher

Michael Vogt wrote:
On Thu, Sep 15, 2005 at 02:40:06PM -0700, Christopher Crammond wrote:
I was curious as to where I might be able to find out what
non-command-line interfaces into .deb packages are available.  For
instance, is there a C interface that could pull out information such as
Name, Version, Release, etc... ?

libapt_inst (from the apt package) provides a interface in C++ and
python-apt (module apt_inst) provides a interface in python.

Attached is a example using python-apt.



#!/usr/bin/env python # some example for apt_inst import apt_pkg import apt_inst import sys def Callback(What,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor): """ callback for debExtract """ print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u"\ % (What,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor); if __name__ == "__main__": if len(sys.argv) < 2: print "need filename argumnet" sys.exit(1) file = sys.argv[1] print "Working on: %s" % file print "Displaying data.tar.gz:" apt_inst.debExtract(open(file), Callback, "data.tar.gz") print "Now extracting the control file:" control = apt_inst.debExtractControl(open(file)) sections = apt_pkg.ParseSection(control) print sections print "Maintainer is: " print sections["Maintainer"] print print "DependsOn: " depends = sections["Depends"] print apt_pkg.ParseDepends(depends)

Christopher Crammond, Software Engineer
Open Country, Inc.
650.591.8080 ext 246

Reply to: