[OpenAFS-devel] openafs spec-file kernel-detection

Alexander Bergolth leo@strike.wu-wien.ac.at
Tue, 16 May 2006 21:53:18 +0200


On 05/16/2006 06:15 PM, Derek Atkins wrote:
> Alexander Bergolth <leo@strike.wu-wien.ac.at> writes:
> 
>>The problem is that the kernel provides both "kernel = <version>" and
>>"kernel = <version>-<release>". On my system this is:
>>rpm -q --provides kernel-2.4.22-1.2199.nptl_52.rhfc1.at | grep 'kernel '
>>kernel = 2.4.22
>>kernel = 2.4.22-1.2199.nptl_52.rhfc1.at
>>
>>... but the second one is redundant because as soon as it provides
>>kernel = 2.4.22, this will satisfy _any_ dependency on "kernel =
>>2.4.22-<something>", so it just doesn't matter which "Requires:
>>kernel"-tag you are using, any 2.4.22 kernel will fulfill this requirements.
> 
> Just to make sure we're on the same page -- what you're saying is
> that even though the openafs RPM has:
> 
>   Requires: kernel = 2.4.22-1.2199.nptl_52.rhfc1.at
> 
> This will match a kernel RPM that has:
> 
>   Provides: kernel = 2.4.22
> 
> ??  Is that what you're saying?  If so, I think this is a bug in RPM.
> But it would certainly explain why the FC1 packages work properly.

Yes, that's it. See
http://distro.conectiva.com.br/pipermail/apt-rpm/2003-August/001951.html
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=112825
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=115954

But I think it's a wontfix. :(

>>That's why I suggested to use the "kernel-%{_target_cpu}" dependency,
>>because the (newer) kernel-rpms only provide the exact
>><version>-<release> string for this capability.
> 
> Yeah..  The kernel-%{_target_cpu} issue has come up before, but I just
> can't use it everywhere.
> 
>>>I'm fairly sure that this is fixed by your patch to openafs-kvers-is.sh
>>>so I'm not too worried about it.
>>
>>As mentioned above, any release string will be valid here.
> 
> That really just feels like a bug in RPM.
> 
> [snip]
> 
>>How about a feature-test? (Use "Requires: kernel-%{_target_cpu}" only
>>when available?)
>>
>>Something like
>>-------------------- snip! --------------------
>>if [ "$1" = "provideskernelarch" ]; then
>>  kernelrpm=`rpm -qf "$2"`
>>  if [ -n "$kernelrpm" ]; then
>>    if rpm -q --provides "$kernelrpm" |grep -q "^kernel-$3 "; then
>>      echo "kernel-$3"
>>    fi
>>  fi
>>  exit 0
>>fi
>>-------------------- snip! --------------------
>>... for openafs-kvers-is.sh, which is feeded with arguments
>>provideskernelarch, %{ksrcdir} and %{_target_cpu}?
> 
> Feature tests are possible, although sometimes annoying.  Keep in mind
> that you need to handle the case where $2 isn't provided by an RPM.
> On many platforms it isn't (e.g. FC3, except for a small handful of
> kernel releases).

I agree that creating a feature test that works fine on all distros
could be painful.

> Also, this check alone (for kernel-$3) doesn't work in all cases.  For
> example, when I build against all the kernels during an OpenAFS
> release I build against /usr/src/kernels/* (see openafs-buildall.sh)
> but those files are provided by the kernel-devel packages that provide
> a different set of targets:
> 
> [warlord@cliodev calliope]$ rpm -qf /usr/src/kernels/2.6.12-1.1372_FC3-smp-i686
> kernel-smp-devel-2.6.12-1.1372_FC3
> [warlord@cliodev calliope]$ rpm -q --provides kernel-smp-devel-2.6.12-1.1372_FC
> kernel-smp-devel-i686 = 2.6.12-1.1372_FC3
> kernel-devel-i686 = 2.6.12-1.1372_FC3smp
> kernel-devel = 2.6.12-1.1372_FC3smp
> kernel-smp-devel = 2.6.12-1.1372_FC3
>
> As you can see, the RPM that provides this doesn't provide "kernel-i686",
> but rather provides "kernel-devel-i686".  Now, I suppose we could run
> rpm twice:
> 
>   if rpm -q --provides "$kernelrpm" | grep -q "^kernel-$3 "; then
>     echo "kernel-$3"
>   elif rpm -q --provides "$kernelrpm" | greq -q "^kernel-devel-$3" ; then
>     echo "kernel-$3"
>   fi

You could check for /boot/vmlinuz-$3 but is an installed binary kernel
rpm necessary for the build process at all? Or are the corresponding
-devel packages sufficient? If they are enough, I guess we'd have to
look at the devel-rpm...

> But then of couse there's the question of which target to use for SMP
> kernels?  Do we use:
> 
>   Requires: kernel-smp-i686 = 2.6.12-1.1372_FC3
> 
> or
> 
>   Requires: kernel-i686 = 2.6.12-1.1372_FC3smp
> 
> I would think that we'd want the former, not the latter, for the same
> reason that a kernel providing kernel = 2.6.12 will match a package
> that requires kernel = 2.6.12-1.1372_FC3.

I think the latter would be necessary as the smp kernel rpms simply do
not provide any kernel-smp-i686 capability:

> rpm -qp --provides kernel-smp-2.6.16-1.2111_FC5.i686.rpm
kernel = 2.6.16
kernel-drm = 4.3.0
kernel-i686 = 2.6.16-1.2111_FC5smp
kernel-smp = 2.6.16-1.2111_FC5

Note that requiring an exact dependency match would be possible using
the kernel-i686 dependency because no kernel-rpm provides kernel-i686
without the release string.

> Also, I think we would want this test to return a boolean that answers
> the question: does this "kernel" provide the new-style %{_target_cpu}
> name, yes or no?  That would make it easier to require the proper term
> in the SPEC file, no?

Yes, using a boolean will probably be better. (I thought about using the
returned-string of e.g. kernel-i686 directly in the Requires-line but I
don't know if this works and a boolean will certainly be cleaner.)

--leo
-- 
-----------------------------------------------------------------------
Alexander.Bergolth@wu-wien.ac.at                Fax: +43-1-31336-906050
Zentrum fuer Informatikdienste - Wirtschaftsuniversitaet Wien - Austria