patch only if dependent version < x? (rpm spec)

Tom Callaway tcallawa at redhat.com
Thu Jun 2 16:13:00 UTC 2011


On 06/02/2011 12:06 PM, Richard W.M. Jones wrote:
> How about this evil untested recursive invocation of rpm?
> 
> %prep
> %configure
> 
> package=glibc
> minversion=2.13.89
> 
> if [ $(
>   rpm -q --queryformat '%{version}\n' $package |
>     cat - <(echo $minversion) |
>     sort -V |
>     head -1
>   ) = "$minversion" ]; then
> %patch0 -p1
> fi

Please don't do that. Ever. Even if in this very specific case, it is
probably safe, invoking rpm within the spec file sets a very poor
example for the thousands of other cases where it is very unsafe/unreliable.

A better way would be to leverage the .pc file for the component being
BuildRequired, although, the .pc files sometimes have the API version as
opposed to the actual version (GNOME, I'm looking at you).

Alternate ideas include:

* Checking for a versioned directory
* Looking for a version definition in a header file
* Invoking a binary from the BR that spits out version

~tom

==
Fedora Project


More information about the devel mailing list