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

Derek Atkins warlord@MIT.EDU
Tue, 16 May 2006 12:15:26 -0400


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.

> 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).

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

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.

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?

> Cheers,
> --leo

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord@MIT.EDU                        PGP key available