If both conditions are false: 0%{?rhel} == 5 and 0%{?rhel} == 6 neither if triggers, and you get: if [ -x /sbin/new-kernel-pkg ] then fi triggering the syntax error you received. On 10/13/2012 07:52 AM, Steven Haigh wrote: > Hi all, > > I'm trying to make my kernel-xen package for EL6 also be buildable on > EL5. One of the things that EL5 doesn't have is dracut - hence the > --dracut option in new-kernel-pkg doesn't exist. > > I figured I could do some basic logic here in the %post and check the > rhel version and run the appropriate command. The code: > > if [ -x /sbin/new-kernel-pkg ] > then > %if 0%{?rhel} == 5 > /sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install > %{KRELEASE} || exit $? > %endif > %if 0%{?rhel} == 6 > /sbin/new-kernel-pkg --package kernel --mkinitrd --dracut --depmod > --install %{KRELEASE} || exit $? > %endif > fi > > When I install the package however, I get: > /var/tmp/rpm-tmp.89138: line 13: syntax error near unexpected token `fi' > /var/tmp/rpm-tmp.89138: line 13: `fi' > error: %post(kernel-xen-3.5.4-4.x86_64) scriptlet failed, exit status 2 > > It just so happens that line 13 of %post is: %if 0%{?rhel} == 5 > > Does anyone have any insight on this? My google-foo has been failing > badly on this :( > > While I apologise that this isn't specifically related to SL, it is > about creation of packages for SL6 and (eventually) SL5. >