0139-0142.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 390 行

HTML
390
字号




<HTML>

<HEAD>

<TITLE>Maximum RPM (RPM):rpm -b Command Reference: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=12 //-->

<!-- PAGES=0139-0162 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="../ch11/0138-0138.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0143-0146.html">Next</A>

</CENTER></P>



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







<H3><A NAME="ch12_ 1">

Chapter 12

</A></H3>



<H2>



rpm -b <BR>

Command Reference



</H2>



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







<P>Table 12.1. Build-mode command syntax and options.

</P>



<TABLE>



<TR><TD>

rpm -b &lt;stage&gt;

</TD><TD>

Options

</TD><TD>

file1.spec...fileN.spec

</TD></TR><TR><TD>

</TD><TD>

&lt;stage&gt;

</TD><TD>

Section

</TD></TR><TR><TD>

p

</TD><TD>

Execute %prep

</TD><TD>

12.1.1

</TD></TR><TR><TD>

c

</TD><TD>

Execute %prep, %build

</TD><TD>

12.1.2

</TD></TR><TR><TD>

i

</TD><TD>

Execute %prep, %build, %install

</TD><TD>

12.1.3

</TD></TR><TR><TD>

b

</TD><TD>

Execute %prep, %build, %install; Package (bin)

</TD><TD>

12.1.4

</TD></TR><TR><TD>

a

</TD><TD>

Execute %prep, %build, %install; Package (bin, src)

</TD><TD>

12.1.5

</TD></TR><TR><TD>

l

</TD><TD>

Check %files list

</TD><TD>

12.1.6

</TD></TR><TR><TD>

</TD><TD>

Parameters

</TD><TD>

</TD></TR><TR><TD>

spec1...specN

</TD><TD>

One or more spec files

</TD><TD>

</TD></TR><TR><TD>

</TD><TD>

Build-Specific Options

</TD><TD>

Section

</TD></TR><TR><TD>

--short-circuit

</TD><TD>

Force build to start at particular stage (-bc, -bi only)

</TD><TD>

12.1.7

</TD></TR><TR><TD>

--test

</TD><TD>

Create, save build scripts for review

</TD><TD> 

12.1.11

</TD></TR><TR><TD>

--clean

</TD><TD>

Clean up after build

</TD><TD>

12.1.12

</TD></TR><TR><TD>

--sign

</TD><TD>

Add a digital signature to the package

</TD><TD>

12.1.10

</TD></TR><TR><TD>

--buildroot &lt;root&gt;

</TD><TD>

Execute %install using &lt;root&gt; as the root

</TD><TD>

12.1.13

</TD></TR><TR><TD>

--buildarch &lt;arch&gt;

</TD><TD>

Perform build for the &lt;arch&gt; architecture

</TD><TD>

12.1.8

</TD></TR><TR><TD>

--buildos &lt;os&gt;

</TD><TD>

Perform build for the &lt;os&gt; operating system

</TD><TD>

12.1.9

</TD></TR><TR><TD>

--timecheck &lt;secs&gt;

</TD><TD>

Print a warning if files are over &lt;secs&gt; old

</TD><TD>

12.1.14

</TD></TR><TR><TD>

</TD><TD>

General Options

</TD><TD>

Section

</TD></TR><TR><TD>

-vv

</TD><TD>

Display debugging information

</TD><TD>

12.1.15

</TD></TR><TR><TD>

--quiet

</TD><TD>

Produce as little output as possible

</TD><TD>

12.1.16

</TD></TR><TR><TD>

--rcfile &lt;rcfile&gt;

</TD><TD>

Set alternate rpmrc file to &lt;rcfile&gt;

</TD><TD>

12.1.17

</TD></TR></TABLE>



<H3><A NAME="ch12_ 2">

12.1. rpm -b: What Does It Do?

</A></H3>



<P>When RPM is invoked with the -b option, the process of building a package is started.

The rest of the command will determine exactly what is to be built and how far the build

should proceed. This chapter explores every aspect of

rpm -b.

</P>



<P>An RPM build command must have two additional pieces of information, over and above 

rpm -b:

</P>



<UL>

<LI>          The names of one or more spec

files representing software to be packaged

<LI>          The desired stage at which the build is to stop

</UL>



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











<P>As discussed in Chapter 10, &quot;The Basics of Developing with RPM,&quot; the spec file is one of

the inputs to RPM's build process. It contains the information necessary for RPM to perform

the build and package the software.

</P>



<P>RPM goes through a number of stages during a build. By specifying that the build process is

to stop at a certain stage, the package builder can monitor the build's progress, make any

changes necessary, and restart the build. Let's start by looking at the various stages that can be

specified in a build command.

</P>



<H4><A NAME="ch12_ 3">

12.1.1. rpm -bp: Execute %prep

</A></H4>



<P>The command rpm -bp directs RPM to execute the very first step in the build process.

</P>



<P>In the spec file, this step is labeled %prep. Every command in the

%prep section will be executed when the -bp option is used.

</P>



<P>Here's a simple %prep section from the spec file we used in Chapter 11, &quot;Building Packages:

A Simple Example&quot;:

</P>



<!-- CODE SNIP //-->

<PRE>

%prep

%setup

</PRE>

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



<P>This %prep section consists of a single %setup macro. When using

rpm -bp against this spec file, we can see exactly what

%setup does:

</P>



<!-- CODE //-->

<PRE>

# rpm -bp cdplayer-1.0.spec

* Package: cdplayer

+ umask 022

+ echo Executing: %prep

Executing: %prep

+ cd /usr/src/redhat/BUILD

+ cd /usr/src/redhat/BUILD

+ rm -rf cdplayer-1.0

+ gzip -dc /usr/src/redhat/SOURCES/cdplayer-1.0.tgz

+ tar -xvvf -

drwxrwxr-x root/users         0 Aug  4 22:30 1996 cdplayer-1.0/

-rw-r--r-- root/users     17982 Nov 10 01:10 1995 cdplayer-1.0/COPYING

-rw-r--r-- root/users       627 Nov 10 01:10 1995 cdplayer-1.0/ChangeLog

...

-rw-r--r-- root/users      2806 Nov 10 01:10 1995 cdplayer-1.0/volume.c

-rw-r--r-- root/users      1515 Nov 10 01:10 1995 cdplayer-1.0/volume.h

+ [ 0 -ne 0 ]

+ cd cdplayer-1.0

+ cd /usr/src/redhat/BUILD/cdplayer-1.0

+ chown -R root.root .

+ chmod -R a+rX,g-w,o-w .

+ exit 0

#

</PRE>

<!-- END CODE //-->



<P>First, RPM confirms that the cdplayer package is the subject of this build. Then it sets

the umask and starts executing the %prep section. At this point, the

%setup macro is doing its thing. It changes directory into the build area and removes any old copies of

cdplayer's build tree.

</P>



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







<P>Next, %setup unzips the sources and uses tar to create the build tree. We've removed the

complete listing of files, but be prepared to see lots of output if the software being packaged is large.

</P>



<P>Finally, %setup changes directory into cdplayer's build tree and changes ownership and

file permissions appropriately. exit 0 signifies the end of the

%prep section and, therefore, the end of the

%setup macro. Because we used the -bp option, RPM stopped at this point. Let's

see what RPM left in the build area:

</P>



<!-- CODE SNIP //-->

<PRE>

# cd /usr/src/redhat/BUILD

# ls -l

total 1

drwxr-xr-x 2 root root 1024 Aug 4 22:30 cdplayer-1.0

#

</PRE>

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



<P>There's the top-level directory. Changing directory into

cdplayer-1.0, we find that the sources are ready to be built:

</P>



<!-- CODE //-->

<PRE>

# cd cdplayer-1.0

# ls -lF

total 216

-rw-r--r--    1 root    root    17982 Nov 10  1995 COPYING

-rw-r--r--    1 root    root      627 Nov 10  1995 ChangeLog

...

-rw-r--r--    1 root    root     2806 Nov 10  1995 volume.c

-rw-r--r--    1 root    root     1515 Nov 10  1995 volume.h

#

</PRE>

<!-- END CODE //-->



<P>We can see that %setup's chown and chmod commands did what they were supposed

to&#151;the files are owned by root, with permissions set appropriately.

</P>



<P>If not stopped by the -bp option, the next step in RPM's build process would be to build

the software. RPM can also be stopped at the end of the

%build section in the spec file. This is done by using the

-bc option.

</P>



<H4><A NAME="ch12_ 4">

12.1.2. rpm -bc: Execute %prep, %build

</A></H4>



<P>When the -bc option is used during a build, RPM stops once the software has been built.

In terms of the spec file, every command in the

%build section will be executed. In the following example, we've removed the output from the

%prep section to cut down on the redundant output, but keep in mind that it is executed nonetheless:

</P>



<!-- CODE //-->

<PRE>

# rpm -bc cdplayer-1.0.spec

* Package: cdplayer

Executing: %prep

...

+ exit 0

Executing: %build

+ cd /usr/src/redhat/BUILD

+ cd cdplayer-1.0

+ make

gcc -Wall -O2 -c -I/usr/include/ncurses cdp.c

gcc -Wall -O2 -c -I/usr/include/ncurses color.c

gcc -Wall -O2 -c -I/usr/include/ncurses display.c



</PRE>

<!-- END CODE //-->



<P><CENTER>

<a href="../ch11/0138-0138.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0143-0146.html">Next</A>

</CENTER></P>











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

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

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