Re: ITP: dpkg-python

2000-09-09 Thread Jason Gunthorpe

On 9 Sep 2000, Milan Zamazal wrote:

> Unless anybody else is interested, I plan to pick up the Python part of
> dpkg-scriptlib and make it a separate (and maintained:-) package.  I

You may want to just let it die.. I have finished the first half of my
work on making a python-apt wrapper which includes at least these modules
from scriptlib:

  ar (*)
  tar (*)
  dpkg_index (afaik, though I'm not sure what it is used for)
  dpkg_message
  dpkg_newformat
  dpkg_packages
  dpkg_util (md5 like there is built in)
  dpkg_version 
* - Only a small portion right now (most useful..), but
more will come as the need arises
Being a simple wrapper around libapt-pkg all of the above are quite fast, 
and very well tested..

I did not set out to implement dpkg-scriptlib (this is just a weird
coincidence that it overlaps so much) so the names and signatures are
different, but a little compatibility layer would be trivial to add. 

The following are dead remains of an old project that never took off
(I think):
  dpkg_certdb
  dpkg_certificate
  dpkg_certserver
  dpkg_debsums
  dpkg_filedb
  dpkg_lint
  dpkg_log
  dpkg_oldformat (this is just really really old)
  dpkg_verify

And this are support for stuff of the above..
  filter
  outstr
  strfile
  subfile

The pgp stuff is dead pretty much, gpg is the program of choice and I have
a nice module for using it in my LDAP stuff (if anyone wants it).

Here is a simple example for some of the functions:
>>> import apt_pkg,apt_inst;
>>> Foo = 
>>> apt_pkg.ParseSection(apt_inst.debExtractControl(open("/tmp/dpkg-python_0.1-3.0.deb","r")))
>>> print Foo.keys()
['Package', 'Version', 'Section', 'Priority', 'Architecture', 'Depends',
'Installed-Size', 'Maintainer', 'Description', 'Source']
>>> print apt_pkg.ParseDepends(Foo["Depends"]);
[[('python-base', '1.5-1', '>=')], [('dpkg', '1.4.0.8', '>=')]]
>>> print apt_pkg.RewriteSection(Foo,apt_pkg.RewritePackageOrder,[]);
Package: dpkg-python
Priority: extra
Section: devel
Installed-Size: 93
Maintainer: Debian QA Group <[EMAIL PROTECTED]>
Source: dpkg-scriptlib
Version: 0.1-3.0
Depends: python-base (>= 1.5-1), dpkg (>= 1.4.0.8)
Architecture: all
Description: Python interface modules for dpkg
 Contains Python modules for dpkg, the Debian package management
 system.  These are currently skeletal, but should eventually provide
 access to all low-level dpkg functions from within python, as well as
 a number of higher-level routines.
 
Jason




Re: ITP: dpkg-python

2000-09-13 Thread Jason Gunthorpe

On Thu, 14 Sep 2000, [ISO-8859-1] "Jürgen A. Erhard" wrote:

> Jason> You may want to just let it die.. I have finished the first
> Jason> half of my work on making a python-apt wrapper which
> Jason> includes at least these modules from scriptlib:
> 
> This looks certainly better than dpkg-python...

Well, it is what APT runs on, and I've always thought APT's source was
pretty reasonable :>
 
> But, please rename those dpkg_* modules.  I'd like

I was mearly listing the equivilents from the current dpkg-python. What I
have done is simply put everything under the apt_pkg module - this is
cheap since it is a binary module.
 
> (Underscores are ugly...)

I usually use -'s for apt-pkg, but python thinks that means minus I think.
 
> [...]
> 
> Jason> Here is a simple example for some of the functions:
>  import apt_pkg,apt_inst;
>  Foo = 
> apt_pkg.ParseSection(apt_inst.debExtractControl(open("/tmp/dpkg-python_0.1-3.0.deb","r")))
>  print Foo.keys()
> Jason> ['Package', 'Version', 'Section', 'Priority', 'Architecture', 
> 'Depends',
> Jason> 'Installed-Size', 'Maintainer', 'Description', 'Source']
>  print apt_pkg.ParseDepends(Foo["Depends"]);
> Jason> [[('python-base', '1.5-1', '>=')], [('dpkg', '1.4.0.8', '>=')]]
>  print apt_pkg.RewriteSection(Foo,apt_pkg.RewritePackageOrder,[]);
> Jason> Package: dpkg-python
> Jason> Priority: extra
> [...]
> 
> *Very* nice indeed... now if only we could take a closer look (apt-get
>  install python-apt, that is ;-)

CVS apt has packages (aliencode branch) - but I have not produced suitable
documentation or completed the bindings I want to have. Without a good
grounding in C++ you may have problems clearly understanding the Python
binary module. 

Jason