⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0270-0272.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:




<HTML>

<HEAD>

<TITLE>Maximum RPM (RPM):Building Packages for Multiple Architectures and Operating Systems:EarthWeb Inc.-</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311054 //-->

<!-- TITLE=Maximum RPM (RPM)//-->

<!-- AUTHOR=Edward Bailey//-->

<!-- PUBLISHER=Macmillan Computer Publishing//-->

<!-- IMPRINT=Sams//-->

<!-- CHAPTER=19 //-->

<!-- PAGES=0263-0274 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0267-0269.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0273-0274.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-270"><P>Page 270</P></A>







<H4><A NAME="ch19_ 18">

19.5.1. The excludexxx Tags

</A></H4>



<P>excludexxx tags are used to direct RPM to ensure that the package does not attempt to

build on the excluded platforms. One or more platforms may be specified after the

excludexxx tags, separated by either spaces or commas. Here are two examples:

</P>



<!-- CODE SNIP //-->

<PRE>

ExcludeArch:  sparc  alpha

ExcludeOS:  Irix

</PRE>

<!-- END CODE SNIP //-->



<P>The first line prevents systems based on the Sun SPARC and Digital Alpha/AXP

architectures from attempting to build the package. The second line ensures that the package will not

be built for the Silicon Graphics operating system Irix.

</P>



<P>If a build is attempted on an excluded architecture or operating system, the following

message will be displayed, and the build will fail:

</P>



<!-- CODE SNIP //-->

<PRE>

#  rpm  -ba  cdplayer-1.0.spec

Arch  mismatch!

cdplayer-1.0.spec doesn't build on this architecture

#

</PRE>

<!-- END CODE SNIP //-->



<P>excludexxx tags are meant to explicitly prevent a finite set of architectures or operating

systems from building a package. If your goal is to ensure that a package will build on only

one architecture, you should use the exclusivexxx tags.

</P>



<H4><A NAME="ch19_ 19">

19.5.2. The exclusivexxx Tags

</A></H4>



<P>exclusivexxx tags are used to direct RPM to only build the package on the specified

platforms. These tags ensure that in the future no brand-new platform will

mistakenly attempt to build the package. RPM will build the package on the specified platforms only.

</P>



<P>The syntax of the exclusivexxx tags is identical to that of

excludexxx:

</P>



<!-- CODE SNIP //-->

<PRE>

ExclusiveArch:  sparc  alpha

ExclusiveOS:   Irix

</PRE>

<!-- END CODE SNIP //-->



<P>In the first line, the package will only build on a Sun SPARC or Digital Alpha/AXP system.

In the second, the package will only be built on the Irix operating system.

</P>



<P>exclusivexxx tags are meant to explicitly allow a finite set of architectures or operating

systems to build a package. If your goal is to ensure that a package will

not build on a specific platform, you should use the

excludexxx tag.

</P>



<H3><A NAME="ch19_ 20">

19.6. Platform-Dependent Conditionals

</A></H3>



<P>Of course, the control exerted by the

excludexxx and exclusivexxx tags over package

building is often too coarse. There may be packages, for example, that would build just fine on

another platform, if only you could substitute a platform-specific patch file or change some paths

in the %files list.

</P>



<A NAME="PAGENUM-271"><P>Page 271</P></A>







<P>The key to exerting this kind of platform-specific control in the spec file is to use RPM's

conditionals. The conditionals provide a general-purpose means of constructing a platform-<BR>

specific version of the spec file during the actual build process.

</P>



<H4><A NAME="ch19_ 21">

19.6.1. Common Features of All Conditionals

</A></H4>



<P>A few things are common to each conditional, so let's discuss them first. The first thing is

that conditionals are block structured. The second is that conditionals can be nested. Finally,

conditionals can span any part of the spec file.

</P>



<H4><A NAME="ch19_ 22">

19.6.1.1. Conditionals Are Block Structured

</A></H4>



<P>Every conditional is block structured&#151;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.

</P>



<P>Every conditional starts with a line beginning with

%if and is followed by one of four 

platform-related conditions. Every conditional ends with a line containing

%endif.

</P>



<P>Ignoring the platform-related conditions for a moment, here's an example of a conditional

block:

</P>



<!-- CODE SNIP //-->

<PRE>

%ifos Linux

Summary: This is a package for the Linux operating system

%endif

</PRE>

<!-- END CODE SNIP //-->



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

</P>



<P>There's also another style of conditional block. As before, it starts with

%if and ends with %endif. But there's something new in the middle:

</P>



<!-- CODE //-->

<PRE>

%ifos Linux

Summary: This is a package for the Linux operating system

%else

Summary: This is a package for some other operating system

%endif

</PRE>

<!-- END CODE //-->



<P>Here we've replaced one summary tag with another.

</P>



<H4><A NAME="ch19_ 23">

19.6.1.2. Conditionals Can Be Nested

</A></H4>



<P>Conditionals can be nested&#151;that is, the block formed by

one conditional can enclose another conditional. Here's an example:

</P>



<!-- CODE //-->

<PRE>

%ifarch i386



echo &quot;This is an i386&quot;



%ifos Linux

echo &quot;This is a Linux system&quot;





</PRE>

<!-- END CODE //-->



<A NAME="PAGENUM-272"><P>Page 272</P></A>



<!-- CODE //-->

<PRE>

%else

echo &quot;This is not a Linux system&quot;

%endif



%else



echo &quot;This is not an i386&quot;



%endif

</PRE>

<!-- END CODE //-->



<P>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 were Intel

based, the %ifos conditional would be tested. If the build system were not Intel based, the

%ifos conditional would not be tested.

</P>



<H4><A NAME="ch19_ 24">

19.6.1.3. Conditionals Can Cross Spec File Sections

</A></H4>



<P>The next thing each conditional has in common is that there is no limit to the number of

lines a conditional block can contain. You could enclose the entire spec file within a

conditional. But it's much better to use conditionals to insert only the appropriate platform-specific

contents.

</P>

<P>

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.

</P>



<H4><A NAME="ch19_ 25">

19.6.2. %ifxxx

</A></H4>



<P>The %ifxxx conditionals are used to control the inclusion of a block as long as the

platform-dependent information is true. Here is an example:

</P>



<!-- CODE SNIP //-->

<PRE>

%ifarch i386 alpha

</PRE>

<!-- END CODE SNIP //-->



<P>In this case, the block following the conditional would be included only if the build

architecture were i386 or alpha.

</P>



<P>Here's another example:

</P>



<!-- CODE SNIP //-->

<PRE>

%ifos Linux

</PRE>

<!-- END CODE SNIP //-->



<P>This example would include the block following the conditional only if the operating

system were Linux.

</P>



<H4><A NAME="ch19_ 26">

19.6.3. %ifnxxx

</A></H4>



<P>The %ifnxxx conditionals are used to control the inclusion of a block as long as the

platform-dependent information is not true. Here is an example:

</P>



<!-- CODE SNIP //-->

<PRE>

%ifnarch i386 alpha



</PRE>

<!-- END CODE SNIP //-->



<P><CENTER>

<a href="0267-0269.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0273-0274.html">Next</A>

</CENTER></P>











</td>
</tr>
</table>

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -