Re: Help with python api, accessing missing "requires" fields from a .src.rpm

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

 



On 09/12/2011 06:03 AM, Thomas Dziedzic wrote:
Hello,

I'm trying to use the rpm python api and I have a question about retrieving
info from hdrFromFdno
I do hdr = hdrFromFdno(fd), and then I get back a hdr object with lots of
data.
The problem is that it seems that hdr lacks the Requires: parts of the .spec
file. Everything else seems to be there, including the BuildRequires.
The fd is for "rpm-4.8.0-16.el6.src.rpm" which I got from
http://ftp.redhat.com/pub/redhat/linux/enterprise/6Workstation/en/os/SRPMS/rpm-4.8.0-16.el6.src.rpm

hdr[rpm.RPMTAG_REQUIRES] seems to be the BuildRequires portion of the .spec

when I search for coreutils (one of the Requires packages) in the hdr by
doing: for k in hdr: if isinstance(hdr[k], collections.Iterable): if
'coreutils' in hdr[k]: print k I get nothing

This is the expected behavior: the source rpm does not carry any information about the binary package(s) that might get produced from it. The only meaningful requires for a source rpm are its build-requires really.

The information about binary packages is only present in the binary packages themselves. Some of that information can be retrieved by parsing the *spec* from an srpm, and inspecting that. For example taking the above rpm-4.8.0-16.el6.src.rpm, unpack it and then you can do:

>>> import rpm
>>> spec = rpm.spec("rpm.spec")
>>> for p in spec.packages:
...     print p.header['requires']
...
['coreutils', 'db4-utils', 'popt', 'curl', '/bin/sh']
['rpm', 'libcap(x86-64)', '/sbin/ldconfig', '/sbin/ldconfig']
['rpm', 'popt-devel(x86-64)', 'file-devel(x86-64)']
['rpm', 'elfutils', 'binutils', 'findutils', 'sed', 'grep', 'gawk', 'diffutils', 'file', 'patch', 'unzip', 'gzip', 'bzip2', 'cpio', 'lzma', 'xz', 'pkgconfig', '/usr/bin/gdb-add-index']
['rpm']
[]
['crontabs', 'logrotate', 'rpm']
[]

Do note that the headers from a parsed spec will miss lots of information: there are no file lists, no autogenerated dependencies etc. For those you need to look at the actual binary packages.

	- Panu -
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list


[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux