C++ CSS HTML Java JavaScript MySQL Oracle PERL PHP SQL Unix VBScript XHTML XML Сети
Platform-Dependent Conditionals
 

Platform-Dependent Conditionals

Of course, the control exerted by the excludexxx and exclusivexxx patch file or change some paths in the %files list.

version of the spec file during the actual build process.

Common Features of All Conditionals

conditionals can be nested. Finally, conditionals can span any part of the spec file.

Conditionals Are Block Structured

— in other words, the conditional begins at a certain point within the spec file and continues some number of lines until it is ended. This forms a block that will be used or ignored, depending on the platform the conditional is checking for, as well as the build platform itself.

Every conditional starts with a line beginning with the characters %if and is followed by one of four platform-related conditions. Every conditional ends with a line containing the characters %endif.

Ignoring the platform-related conditions for a moment, here's an example of a conditional block:
%ifos Linux
Summary: This is a package for the Linux operating system
%endif
            

It's a one-line block, but a block nonetheless.

There's also another style of conditional block. As before, it starts with a %if, and ends with a %endif. But there's something new in the middle:
%ifos Linux
Summary: This is a package for the Linux operating system
%else
Summary: This is a package for some other operating system
%endif
            

Here we've replaced one summary tag with another.

Conditionals Can Be Nested

Conditionals can be nested — That is, the block formed by one conditional can enclose another conditional. Here's an example:
%ifarch i386

echo "This is an i386"

%ifos Linux
echo "This is a Linux system"
%else
echo "This is not a Linux system"
%endif

%else

echo "This is not an i386"

%endif
            

In this example, the first conditional block formed by the %ifarch i386 line contains a complete %ifos — %else — %endif conditional. Therefore, if the build system was Intel-based, the %ifos conditional would be tested. If the build system was not Intel-based, the %ifos conditional would not be tested.

Conditionals Can Cross Spec File Sections

file within a conditional, if you like. But it's much better to use conditionals to insert only the appropriate platform-specific contents.

Now that we have the basics out of the way, let's take a look at each of the conditionals and see how they work.

%ifxxx

The %ifxxx conditionals are used to control the inclusion of a block, as long as the platform-dependent information is true. Here are two examples:
%ifarch i386 alpha
          

In this case, the block following the conditional would be included only if the build architecture was i386 or alpha.
%ifos Linux
          

This example would include the block following the conditional only if the operating system was Linux.

%ifnxxx

The %ifnxxx conditionals are used to control the inclusion of a block, as long as the platform-dependent information is not true. Here are two examples:
%ifnarch i386 alpha
          

In this case, the block following the conditional would be included only if the build architecture was not i386 or alpha.
%ifnos Linux
          

This example would include the block following the conditional only if the operating system was not Linux.

Главная