Description of problem: Using the rpm spec parser only a limiter number of items from the spec are accessible*. I think it would be really nice to enhance this to have a small library able to read/write spec files. * I was looking for a way to retrieve Requires and BuildRequires from a spec file using this parser but I discovered I could not.
You dont mention what language you're using to access the spec... but the dependency information is parsed into header structures which have always been accessible from C (but the librpmbuild API has been a big non-obvious mess). Also rpm -q --specfile has been able to query "all" aspects of headers for binaries (but not source headers, so buildrequires haven't been accesssible). Since rpm 4.8.x the headers for binary packages are also accessible from the python bindings. In rpm 4.9.x (now in rawhide), the librpmbuild C API has been entirely revamped providing saner interfaces to parsing spec. Additionally there's a new tool (rpmspec) for querying spec files, which allows querying source rpm headers in addition to binary rpm headers parsed from spec, and also python bindings have access to source headers too. The python bindings enhancements are likely to be backported to 4.8.x in time, but other than that I consider this fixed/rawhide as of rpm-4.9.0-0.beta1.1.fc15.
Sorry, I am using python to access the information. I will try to look at rpmspec and the python bindings by F15, I have no rawhide available at the moment. Thanks for your answer.
Ok. You can access various aspects of the spec from python already, eg this works on F13 and F14 now: >>> import rpm >>> spec = rpm.spec('net-snmp.spec') >>> for pkg in spec.packages: print pkg.header['name'] ... net-snmp net-snmp-utils net-snmp-devel net-snmp-perl net-snmp-gui net-snmp-libs net-snmp-python net-snmp-debuginfo >>> Dependencies and other data can be queried similarly (and access to source headers can be expected in 4.8.2 when that's released + pushed to Fedora)