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

John Dennis jdennis at redhat.com
Fri Jan 8 17:39:40 UTC 2016


On 01/08/2016 08:22 AM, Jan Cholasta wrote:
> On 8.1.2016 14:13, Martin Basti wrote:
>>
>>
>> On 08.01.2016 14:14, Jan Cholasta wrote:
>>> On 8.1.2016 14:09, Martin Basti wrote:
>>>>
>>>>
>>>> On 08.01.2016 14:00, Martin Kosek wrote:
>>>>> On 01/08/2016 01:45 PM, Martin Basti wrote:
>>>>>> Hello all,
>>>>>>
>>>>>> fix for ticket https://fedorahosted.org/freeipa/ticket/5535
>>>>>> requires to import rpm module
>>>>>>
>>>>>> This import somehow breaks nsslib in IPA
>>>>>> https://fedorahosted.org/freeipa/ticket/5572
>>>>>>
>>>>>>
>>>>>> We have 2 ways how to fix it:
>>>>>>
>>>>>> 1) move import rpm to body of methods (attached patch)
>>>>>> We are not sure how stable is this solution.
>>>>>>
>>>>>> 2) use solution with rpmdevtools proposed here:
>>>>>> https://www.redhat.com/archives/freeipa-devel/2016-January/msg00092.html
>>>>>>
>>>>>>
>>>>>> This should be rock stable but it needs many dependencies (rpm-python
>>>>>> too, perl)
>>>>>>
>>>>>> The second way looks safer, so I would like to reimplement it, do you
>>>>>> all agree
>>>>>> or do you have better idea?
>>>>>> Feedback welcome, please ASAP.
>>>>>>
>>>>>> Martin^2
>>>>> Since it's Friday, I invested 15 minutes to practice my C skills and
>>>>> use the
>>>>> python-cffi library to call rpm rpmvercmp library call directly
>>>>> (attached):
>>>>>
>>>>> $ python rpm.py 4.2.0-15.el7 4.2.0-15.el7_2.3
>>>>> 4.2.0-15.el7 < 4.2.0-15.el7_2.3
>>>>>
>>>>> This would not introduce any additional dependency besides rpm-devel,
>>>>> right? :-)
>>>
>>> Not rpm-devel, but rpm-libs (you should dlopen "librpm.so.3").
>>>
>>>> I'm afraid that this can cause the same issue as import rpm, because
>>>> the
>>>> nsslib is used from C library
>>>
>>> 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.
>

Leaving aside the whole question of whether re-implementing rpmvercmp in 
Python is a good idea or not because of possible divergence from RPM I 
offer to you an implementation of rpmvercmp written in Python I did 
years ago. It was written based on the published documentation of how 
RPM version comparison is implemented (as close to a spec as I was able 
to find). I believe I also used the C implementation as a guide but my 
memory is fuzzy on that point. I've used it a lot and I've also cross 
checked it's results with librpm and I've never seen a differing result.

Use at your pleasure or displeasure :-)

HTH,

John


-- 
John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rpmvercmp.py
Type: text/x-python
Size: 6057 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20160108/3f0430a0/attachment.py>


More information about the Freeipa-devel mailing list