[lang]

Present Perfect

Personal
Projects
Packages
Patches
Presents
Linux

Picture Gallery
Present Perfect

distro conditionals in spec files

Filed under: Fedora — Thomas @ 14:47

2008-08-25
14:47

Every time I have to write a spec file and do something specifically for a certain distro version (like, for example, packages were renamed or split or ...) I end up trying to remember what the last package was in which I used it to have the most up-to-date version of that macro.

And once in a while I try one and it doesn't work, for some silly reason. And these macros are always very fragile.

So, this weekend I rebuilt a package for RHEL5.2 and the spec was supposed to BuildRequire: libXv-devel for RHEL5 and onwards. But the check didn't take the 5.2 version number (with a period) into account and it failed.

So this time I decided to just create a wiki page on my wiki that I will update if I ever run into problems again, and will reference back to next time I need it. In the process I managed to simplify the macros and make them more correct, so everyone wins. And that includes you - because now you can go there too if you care! *

* Of course, if you're part of the 99.99999999% of people that doesn't write spec files for fun or money, then you probably don't!

3 Comments »

  1. I’ve always wondered about the distinction between packaging and build setup… Seems like doing the same work twice :/

    Comment by Frej Soya — 2008-08-25 @ 15:37

  2. Did you check if there’s an easier way to do this?

    If you tried to do this reliably in Mandriva by parsing /etc/mandriva-release it’d probably drive you to drink, but that’s why we have the special %{mdkver} in Mandriva, which returns the version of the system in a format that’s always easy to use. Are you sure RH / Fedora doesn’t have something similar?

    Comment by Adam Williamson — 2008-08-25 @ 15:38

  3. I rolled something similar myself using awk instead of perl. Perl is an order of magnitude slower and uses more memory than awk to do the same thing.

    %define release %(release=”`awk ‘{if ($0 ~ “CentOS release 5” || $0 ~ “Red Hat Enterprise Linux 5” ) print “el5”; else if ($0 ~ “Fedora release 9”) print “fc9″}’ /etc/redhat-release`”; if test $? != 0 ; then release=”” ; fi ; echo “$release”)

    You could make it more fedora or rhel specific, but you get the idea. Should I put this on your wikipage?

    Comment by Jeff Schroeder — 2008-08-25 @ 18:27

RSS feed for comments on this post. TrackBack URL

Leave a comment

picture