Ticket #14 (closed enhancement: fixed)

Opened 7 years ago

Last modified 5 years ago

[PATCH] Expose spec file headers in Python


Reported by: eswierk Assigned to: pmatilai Priority: major Milestone: rpm-4.9.0 Component: rpm Version: RPM Development Keywords: Python Cc:


Description

It's nice to let the rpm library do the dirty work of parsing a spec file, but the Python library doesn't allow extracting information from the resulting headers. The attached patch remedies this with two new spec object methods: sourceHeader and packageHeaders.

These methods return most of the same information you'd get by building the package and reading the headers from the source rpm (sourceHeader) or binary rpms (packageHeaders).

That's most, not all, because rpmbuild adds certain information to the headers when building a package, such as Provides for any .so files in a binary rpm. But for many applications, all the information you need is right there in the spec file, and these new methods give you a convenient way to access it from Python. For example:

  import rpm
  s = rpm.ts().parseSpec("foo.spec")
  print s.sourceHeader()["name"]
  print s.packageHeaders()[0]["name"]

Attachments

rpm-4.6.0-python-spec-headers.patch (2.0 kB) - added by eswierk on 12/10/08 07:24:34.
Implement spec file header methods

Change History

12/10/08 07:24:34 changed by eswierk

  • attachment rpm-4.6.0-python-spec-headers.patch added.

Implement spec file header methods

12/18/08 08:47:17 changed by pmatilai

  • status changed from new to assigned.

FYI, another patch towards the same goal was recently posted to rpm-maint list. The functionality is certainly welcome, I'll review the patches and merge either / best parts as soon as I find the time. In any case, thanks for the patch.

02/23/09 14:46:46 changed by pmatilai

  • keywords set to Python.

10/12/10 13:04:10 changed by pmatilai

  • status changed from assigned to closed.
  • resolution set to fixed.

This is finally fully implemented in HEAD. Access to binary headers through packages went in 4.8.0 but the source part was missing, some rationale behind that explained in http://lists.rpm.org/pipermail/rpm-maint/2010-October/002889.html

10/12/10 13:04:28 changed by pmatilai

  • milestone set to rpm-4.9.0.