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

Richard W.M. Jones rjones at redhat.com
Thu Jun 2 16:06:54 UTC 2011


On Thu, Jun 02, 2011 at 11:48:35AM -0400, Neal Becker wrote:
> 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.

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

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/


More information about the devel mailing list