[Freeipa-devel] import rpm causes failure during IPA caless install

John Dennis jdennis at redhat.com
Mon Jan 11 14:33:14 UTC 2016


On 01/11/2016 01:50 AM, Alexander Bokovoy wrote:
> On Mon, 11 Jan 2016, Jan Cholasta wrote:
>> On 8.1.2016 14:28, Alexander Bokovoy wrote:
>>> On Fri, 08 Jan 2016, Jan Cholasta wrote:
>>>>>> I would be surprised if NSS was used in this particular function.
>>>>>>
>>>>> I will try it
>>>>
>>>> No NSS here:
>>>> <https://github.com/rpm-software-management/rpm/blob/master/lib/rpmvercmp.c>
>>>>
>>>>
>>>>
>>>> Anyway, the function looks simple, so it might be safer to just
>>>> rewrite it to Python, with no new dependencies.
>>> Still, we need to be careful in a case where RPM team would decide to
>>> upgrade rpm version comparison algorithm. It has been fixed for quite
>>> some years (the core wasn't changed since 2008) but occasionally there
>>> are additions that expand supported formats like addition of dpkg-style
>>> versions in 2012.
>>
>> I don't think we need to care about that, as we use versioning scheme
>> compatible with the original comparison algorithm on "our" platforms.
> In that case I'd prefer John's code as it is pure Python and doesn't
> have any other dependencies.

If you do use it I just noticed a couple of places which do not use good 
Python style and isn't Py2/Py3 safe (I wrote this shortly after having 
learned Python many years ago). The following lines

     if type(component1) in (int, long):
     if type(component2) in (int, long):
     if type(component2) is str:

should be changed to

     import six

     if isinstance(component1, six.integer_types)
     if isinstance(component2, six.integer_types)
     if isinstance(component2, six.string_types)
-- 
John




More information about the Freeipa-devel mailing list