Bug 857653

Summary: [RFE, PATCH] No external access to file lists and policy
Product: [Fedora] Fedora Reporter: Alec Leamas <leamas.alec>
Component: rpmAssignee: Fedora Packaging Toolset Team <packaging-team>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: ffesti, jzeleny, packaging-team, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-06-12 13:21:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch against 4.9, C and python access to fileFile, fileList and policyList
none
Updated patch
none
Updated patch none

Description Alec Leamas 2012-09-15 15:15:02 UTC
Created attachment 613273 [details]
Patch against 4.9, C and python access to fileFile, fileList and policyList

Description of problem:
When rpm-build parses the specfile, it also parses the file list and (nowadays?) also the policy. These are stored in specPackage objects attached to the spec. However, these items are not visible on the rpm.specPkg interface, neither from C nor from python. 


Version-Release number of selected component (if applicable): 
rpm-4.9.1.3-7.fc17

How reproducible:
Akways

Steps to Reproduce:
- Download and install rpm source rpm.
- python>>> import rpm
>>> ts=rpm.TransactionSet()
>>> spec=ts.parseSpec('/home/leamas/rpmbuild/SPECS/rpm.spec')
>>> dir(spec.packages[0])
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'header']

Actual results:
- The attributes fileFile, fileList and policyList are missing.

A better  result:
 - Attributes are there

Additional info:

This is related to fedora-review, which uses hand-crafted specfile parsing even though using rpmbuild's own seems like a much better option. However, this isn't possible until acces to these fields is there.

Patch sent upstream, see http://lists.rpm.org/pipermail/rpm-maint/2012-September/thread.html. However, things seems to move so slowly at rpm.org so I would prefer if enclosed patch was accepted locally here until things are resolved upstream.

Comment 1 Alec Leamas 2012-09-29 10:13:24 UTC
Created attachment 618989 [details]
Updated patch

Updated after discussion on the list [1]:
- Returning plain string instead of ARGV_t from C.
- Using single function specPkgGetSection, similar to specGetSection but working on package instead.

[1]: http://lists.rpm.org/pipermail/rpm-maint/2012-September/003222.html

Comment 2 Alec Leamas 2012-10-01 12:51:53 UTC
Created attachment 619780 [details]
Updated patch

Updated after comments from dmalcolm at redhat.com  (thanks!) about low-memory failures in python C library.

Although this patch now is safe(?), note that lower parts of the library, notably rpmstring, does not check return values from malloc/realloc so when memory is exhausted those will probably fail anyway.

Comment 3 Florian Festi 2015-06-12 13:21:05 UTC
Sorry, this got dropped somehow. We are now working our way through the back log.

Added upstream as 

05b7ac821487300f7c8924216087d9ee4347fe1d and
beecf9cf26f6095c936368094c06ea3d84bd57f6

and will be part in the upcoming rpm-4.13 release.

Comment 4 Alec Leamas 2015-06-17 11:19:04 UTC
Hm... in the meantime we now also have the %license stuff added. Probably we should allow access also to this is the same way, partly just for symmetry. I will try to have a look at it after the holidays (i. e., August).