[Rpm-maint] PATCH: Accessing file and policy lists from python (and C)
Alec Leamas
leamas.alec at gmail.com
Fri Sep 21 17:13:51 UTC 2012
On 09/21/2012 01:42 PM, Panu Matilainen wrote:
> On 09/21/2012 01:59 PM, Alec Leamas wrote:
>> On 09/21/2012 07:02 AM, Panu Matilainen wrote:
>>> On 09/15/2012 05:47 PM, Alec Leamas wrote:
>>>> 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.
>>>>
>>>> Is there a particular reason these items aren't visible?
>>>
>>> It's simply because access to the flat, unpopulated file list doesn't
>>> seem useful at all to me, and not exposing something means not having
>>> to commit to an interface for it.
>>>
>>>> I have som pronlems with this related to the fedora-review tool [1],
>>>> which basically forces us to use some hand-crafted specfile parsing ,
>>>> since the file lists are needed. I would certainly prefer using
>>>> rpmlib's
>>>> own parsing for that. However, then external access to the fields
>>>> fileList, fileFile and policyList is needed. The enclosed patch
>>>> arranges
>>>> this.
>>>
>>> I'm curious: what exactly are you doing / planning to do with the file
>>> list?
>>>
>>>
>> [cut, lot's of]
>>
>> It's fedora-review... we are reviewing the packages, comparing the
>> raw, unexpanded list with various guidelines sections.
>
> I guessed that much, but what kinds of things exactly? I'm mostly just
> curious, but also wanting to see if there's something that rpm could
> help with.
Just an example, a snippet from current tests below. There are more of
these, but I doubt it makes sense to paste it here.
Yes, this is released code. But the I would very much prefer to use
rpm's parsing instead of the hand-crafted parser used today.
_init__(self, base):
GenericCheckBase.__init__(self, base)
self.url = 'http://fedoraproject.org/wiki/' \
'Packaging/Guidelines#Configuration_files'
self.text = '%config files are marked noreplace or the reason' \
' is justified.'
self.automatic = True
self.type = 'MUST'
def run(self):
rc = self.NA
extra = ''
for pkg in self.spec.packages():
for line in self.spec.get_files(pkg):
if line.startswith('%config'):
if not line.startswith('%config(noreplace)'):
extra += line
else:
rc = self.PASS
self.set_passed(self.FAIL if extra else rc, extra)
More information about the Rpm-maint
mailing list