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

Sam Varshavchik mrsam at
Thu Jun 2 16:13:42 UTC 2011

Neal Becker writes:

> Sam Varshavchik wrote:
> > Neal Becker writes:
> >
> >> How can I apply a patch only if the version of a dependency is < x?
> >
> > You mean you want to specify the dependency's version in a macro, that you
> > put into Requires:? If so, just use the macro in your build script, it'll  
> be
> > expanded, and you can test its value. Bare-bones shell isn't usually
> > convenient for understanding most kinds of version number formats. You may
> > need to do something fancy.
> I mean, a patch is needed only if one of the BR versions is less than a.b.   
> So I
> want to conditionally apply a patch, based on the version of the BR.

I see.

You're going to have to figure out what version of a dependency you're  
building against. I suppose you can can "rpm -q --queryformat '%{VERSION}'  
$packagename", and get the version that way, then figure out if you want to  
apply a patch. That approach "feels" wrong. I would look at your  
dependency's files and see if its version can be retrieved from your  
dependency's installations. If your dependency uses pkgconfig, it's as  
simple as "pkg-config --version $packagename".

Once you have the version, you can apply the patch.

if <<version test goes here>>
%patchX [options]

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
Url : 

More information about the devel mailing list