[Rpm-maint] PATCH: Python: allow access to packages & headers from spec object

Panu Matilainen pmatilai at laiskiainen.org
Sat Sep 20 10:01:48 UTC 2008


On Thu, 18 Sep 2008, Daniel P. Berrange wrote:

> I'm trying todo some automated processing & analysis of RPM specfiles
> and have found the python binding is lacking a number of key features

Yup, the bindings for build/spec parsing have been almost non-existent.

> - The 'spec' object allows access to the lists of sources, but doesn't
>   expose the RPMBUILD_ISXXXX constants
>
> - The 'spec' object does not provide access to the 'packages' objects
>   so you can't query most metadata about the spec.
>
> - None of the RPMTAG_XXX constants are defined, which makes using the
>   'header' object unpleasant.
>
> This patch addresses all these missing pieces. I'm not entirely clear on
> whether the reference counting / object lifecycle stuff is correct here
> though. It seems like there's the possibility of python garbage collecting
> the 'spec' object while there's still a live 'pkg' and/or 'header' object
> live.

Would you mind renaming the python-visible "pkg" object to something like 
"specpkg" to make it clear that these particular packages only exist in 
the spec-world as opposed to something you can install? I'd like to 
preserve the "pkg" name for "real" rpm/rpmdb package objects (for future 
plans)

Other than that (and possible refcounting issues, those are always a bit 
of a PITA and tend to require a couple of rounds to get right), looks ok 
to me.

One thing worth mentioning here is that the in-rpm python bindings are not 
going to be actively developed, new bindings to address various issues and 
misdesigns in the current ones are in the works here: 
http://devel.linux.duke.edu/gitweb/?p=rpm-python.git. See the rpm-python 
TODO to get an idea what sort of things are planned (for example the 
"package object"). Also worth noting in the new bindings is that they lack 
the build/spec part completely right now: the idea is to have a separate 
python module for that, in order to avoid dragging in librpmbuild 
dependency into the main bindings (as get used in things like installers 
where diskspace counts). Work on that would be very welcome too...

Nice to see somebody interested in this area, and better yet with patches 
:)

 	- Panu -



More information about the Rpm-maint mailing list