📄 0263-0266.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="../ch18/0260-0262.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0267-0269.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-263"><P>Page 263</P></A>
<H3><A NAME="ch19_ 1">
Chapter 19
</A></H3>
<H2>
Building Packages for <BR>Multiple Architectures and <BR>Operating Systems
</H2>
<A NAME="PAGENUM-264"><P>Page 264</P></A>
<P>While RPM certainly makes packaging software as easy as possible, it doesn't stop there.
RPM gives you the tools you need to build a package on different types of computers. More
importantly, RPM makes it possible to build packages on different types of computers using a
single spec file. Those of you who have developed software for different computers know the
importance of maintaining a single set of sources. RPM lets you continue that practice through
the package-building phase.
</P>
<P>Before we get into RPM's capabilities, let's quickly review what is involved in developing
software for different types of computer systems.
</P>
<H3><A NAME="ch19_ 2">
19.1. Architectures and Operating Systems: <BR>
A Primer
</A></H3>
<P>From a software engineering standpoint, there are only two major differences between any
two computer systems:
</P>
<UL>
<LI> The architecture
implemented by the computer's hardware
<LI> The system software running on the computer
</UL>
<P>The first difference is built into the computer. The architecture is the manner in which
the computer system was designed. It includes the number and type of registers present in
the processor, the number of machine instructions, what operations they perform, and so on.
For example, every PC today, no matter who built it, is based on the Intel x86 architecture.
</P>
<P>The second difference is more under our control. The operating system is software that
controls how the system operates. Different operating systems have different methods of
storing information on disk, different ways of implementing functions used by programs, and
different hardware requirements.
</P>
<P>As far as package building is concerned, two systems with the same architecture running
two different operating systems are as different as two systems with different architectures
running the same operating system. In the first case, the software being packaged for the different
operating systems will differ due to the differences between the operating systems. In the
second case, the software being packaged for different architectures will differ due to the
underlying differences in hardware. (This is a somewhat simplistic view of the matter; it's common
for incompatibilities to crop up between two different implementations of the same operating
system on different architectures.)
</P>
<P>RPM supports differences in architecture and operating system equally. If there is a tag,
rpmrc file entry, or conditional that is used to support architectural differences, there is a
corresponding tag, entry, or conditional that supports operating system differences.
</P>
<A NAME="PAGENUM-265"><P>Page 265</P></A>
<H4><A NAME="ch19_ 3">
19.1.1. Let's Just Call Them Platforms
</A></H4>
<P>In order to keep the duplication in this chapter to a minimum, we'll refer to a computer of
a given architecture running a given operating system as a
platform. If another system differs in either aspect, it is considered a different platform.
</P>
<P>Okay, now that we've gotten through the preliminaries, let's look at RPM's multiplatform
capabilities.
</P>
<H3><A NAME="ch19_ 4">
19.2. What Does RPM Do to Make Multiplatform Packaging Easier?
</A></H3>
<P>As we mentioned, RPM supports multiplatform package building through a set of tags,
rpmrc file entries, and conditionals. None of these tools is difficult to use. In fact, the hardest part
of multiplatform package building is figuring out how the software needs to be changed to
support different platforms.
</P>
<P>Let's take a look at each multiplatform tool RPM provides.
</P>
<H4><A NAME="ch19_ 5">
19.2.1. Automatic Detection of the Build Platform
</A></H4>
<P>The first thing necessary for easy multiplatform package building is to identify which
platform the package is to be built for. Except in the fairly esoteric case of cross-compilation, the
build platform is the platform on which the package is built. RPM does this for you
automatically, although it can be overridden at build time.
</P>
<H4><A NAME="ch19_ 6">
19.2.2. Automatic Detection of the Install Platform
</A></H4>
<P>The other important platform in package building is the platform on which the package is
to be installed. Here again, RPM does this for you, although it's possible to override this
when the package is installed.
</P>
<P>But there is more to multiplatform package building than simply being able to determine
the platform during package building and installation. The next component in
multiplatform package building is a set of platform-dependent tags.
</P>
<H4><A NAME="ch19_ 7">
19.2.3. Platform-Dependent Tags
</A></H4>
<P>RPM uses a number of tags that control which platforms can build a package. These tags
make it easier for the package builder to build multiple packages automatically since the tags
keep RPM from attempting to build packages that are incompatible with the build platform.
</P>
<A NAME="PAGENUM-266"><P>Page 266</P></A>
<H4><A NAME="ch19_ 8">
19.2.4. Platform-Dependent Conditionals
</A></H4>
<P>Whereas the platform-dependent tags provide a crude level of multiplatform control (that
is, the package will be built or not, depending on the tags and the build platform), RPM's
platform-dependent conditionals provide a much finer level of control. By using these
conditionals, it's possible to excise those parts of the spec file that are specific to another platform
and replace them with one or more lines that are compatible with the build platform.
</P>
<P>Now that you have a basic idea of RPM's multiplatform support features, let's take a more
in-depth look at each one.
</P>
<H3><A NAME="ch19_ 9">
19.3. Build and Install Platform Detection
</A></H3>
<P>As mentioned earlier, the first step to multiplatform package building is to identify the
build platform. This is done by matching information from the build system's
uname output against a number of rpmrc file entries.
</P>
<P>Normally, it's not necessary to worry too much about the following
rpmrc file entries because RPM comes with a set of entries that support all platforms that currently run RPM.
However, when adding support for new platforms, it will be necessary to use the following entries to
add support for the new build platform.
</P>
<H4><A NAME="ch19_ 10">
19.3.1. Platform-Specific rpmrc Entries
</A></H4>
<P>Normally, the file /usr/lib/rpmrc contains the following
rpmrc file entries. They can be overridden by entries in
/etc/rpmrc or ~ /.rpmrc. This is discussed more completely in
Appendix B, "The rpmrc File."
</P>
<P>Because each entry type is available in both architecture and operating system flavors, we'll
just use xxx in place of arch and os in the following descriptions.
</P>
<H4><A NAME="ch19_ 11">
19.3.1.1. xxx_canon: Define Canonical Platform Name and Number
</A></H4>
<P>The xxx_canon entry is used to convert information obtained from the system running
RPM into a canonical name and number that RPM will use internally. Here's the format:
</P>
<!-- CODE SNIP //-->
<PRE>
xxx_canon:<label>: <string> <value>
</PRE>
<!-- END CODE SNIP //-->
<P><label> is compared against information from
uname(2). If a match is found, <string> is
used by RPM as the canonical name, and
<value> is used as a unique numeric value. Here are
two examples:
</P>
<!-- CODE SNIP //-->
<PRE>
arch_canon: sun4: sparc 3
os_canon: Linux: Linux 1
</PRE>
<!-- END CODE SNIP //-->
<P><CENTER>
<a href="../ch18/0260-0262.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0267-0269.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -