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

📄 0143-0146.html

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




<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="0139-0142.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0147-0149.html">Next</A>

</CENTER></P>



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



<!-- CODE //-->

<PRE>



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

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

volume.c: In function `mix_set_volume':

volume.c:67: warning: implicit declaration of function `ioctl'

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

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

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

gcc -o cdp cdp.o color.o display.o misc.o volume.o hardware.o database.o

getline.o -I/usr/include/ncurses -L/usr/lib -lncurses

groff -Tascii -man cdp.1 | compress &gt;cdp.1.Z

+ exit 0

#

</PRE>

<!-- END CODE //-->



<P>After the command, we see RPM executing the

%prep section (which we've removed almost entirely). Next, RPM starts executing the contents of the

%build section. In our sample spec file, the

%build section looks like this:

</P>



<!-- CODE SNIP //-->

<PRE>

%build

make

</PRE>

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



<P>We see that prior to the make command, RPM changes directory into

cdplayer's top-level 

directory. RPM then starts the make, which ends with the

groff command. At this point, the execution of the

%build section has been completed. Because the -bc option was used,

RPM stops at this point.

</P>



<P>The next step in the build process would be to install the newly built software. This is done

in the %install section of the spec file. RPM can be stopped after the install has taken place

by using the -bi option.

</P>



<H4>

12.1.3. rpm -bi: Execute %prep, %build, %install

</H4>



<P>By using the -bi option, RPM is directed to stop once the software is completely built

and installed on the build system. Here's what the output of a build using the

-bi option looks like:

</P>



<!-- CODE //-->

<PRE>

# rpm -bi cdplayer-1.0.spec

* Package: cdplayer

Executing: %prep

...

+ exit 0

Executing: %build

...

+ exit 0

Executing: %install

+ cd /usr/src/redhat/BUILD

+ cd cdplayer-1.0

+ make install

chmod 755 cdp

chmod 644 cdp.1.Z

cp cdp /usr/local/bin

ln -s /usr/local/bin/cdp /usr/local/bin/cdplay

cp cdp.1 /usr/local/man/man1

+ exit 0

+ umask 022

+ echo Executing: special doc



</PRE>

<!-- END CODE //-->



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



<!-- CODE //-->

<PRE>



Executing: special doc

+ cd /usr/src/redhat/BUILD

+ cd cdplayer-1.0

+ DOCDIR=//usr/doc/cdplayer-1.0-1

+ rm -rf //usr/doc/cdplayer-1.0-1

+ mkdir -p //usr/doc/cdplayer-1.0-1

+ cp -ar README //usr/doc/cdplayer-1.0-1

+ exit 0

#

</PRE>

<!-- END CODE //-->



<P>As before, we've cut out most of the previously described sections. In this example, the  %install section looks like this:

</P>



<!-- CODE SNIP //-->

<PRE>

%install

make install

</PRE>

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



<P>After the %prep and %build sections, the

%install section is executed. Looking at the

output, we see that RPM changes directory into

cdplayer's top-level directory and issues the make 

install command, the sole command in the %install section. The output from that

point until the first exit 0 is from makefile's

install target.

</P>



<P>The remaining commands are due to the contents of the spec file's

%files list. Here's what it looks like:

</P>



<!-- CODE SNIP //-->

<PRE>

%files

%doc README

/usr/local/bin/cdp

/usr/local/bin/cdplay

/usr/local/man/man1/cdp.1

</PRE>

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



<P>The line responsible is %doc README. The %doc tag identifies the file as being

documentation. RPM handles documentation files by creating a directory in

/usr/doc and placing all documentation in it. The exit

0 at the end signifies the end of the %install section. RPM

stops due to the -bi option.

</P>



<P>The next step at which RPM's build process can be stopped is after the software's binary

package file has been created. This is done using the

-bb option.

</P>



<H4>

12.1.4. rpm -bb: Execute %prep, %build, %install, Package (bin)

</H4>



<P>As stated at the end of the previous section, RPM's

-bb option performs every step of the build process up to the point of creating the

source package file. At that point it stops, as shown here:

</P>



<!-- CODE //-->

<PRE>

# rpm -bb cdplayer-1.0.spec

* Package: cdplayer

Executing: %prep

...

+ exit 0

Executing: %build

...

+ exit 0

Executing: %install

...



</PRE>

<!-- END CODE //-->



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



<!-- CODE //-->

<PRE>



+ exit 0

Executing: special doc

...

+ exit 0

Binary Packaging: cdplayer-1.0-1

Finding dependencies...

Requires (2): libc.so.5 libncurses.so.2.0

usr/doc/cdplayer-1.0-1

usr/doc/cdplayer-1.0-1/README

usr/local/bin/cdp

usr/local/bin/cdplay

usr/local/man/man1/cdp.1

93 blocks

Generating signature: 0

Wrote: /usr/src/redhat/RPMS/i386/cdplayer-1.0-1.i386.rpm

+ umask 022

+ echo Executing: %clean

Executing: %clean

+ cd /usr/src/redhat/BUILD

+ cd cdplayer-1.0

+ exit 0

#

</PRE>

<!-- END CODE //-->



<P>After executing the %prep, %build, and %install sections and handling any special

documentation files, RPM creates a binary package file. In the sample output, we see that first RPM

performs automatic dependency checking. It does this by determining which shared libraries

are required by the executable programs contained in the package. Next, RPM actually

archives the files to be packaged, optionally signs the package file, and outputs the finished product.

</P>



<P>The last part of RPM's output looks suspiciously like a section in the spec file being

executed. In our example, there is no %clean section. If there were, however, RPM would have

executed any commands in the section. In the absence of a

%clean section, RPM simply issues the usual cd commands and exits normally.

</P>



<H4>

12.1.5. rpm -ba: Execute %prep, %build, %install, Package <BR>

(bin, src)

</H4>



<P>The -ba option directs RPM to perform all the stages in building a package. With this

one command, RPM does the following:

</P>



<OL>

<LI>          Unpacks the original sources.

<LI>          Applies patches (if desired).

<LI>          Builds the software.

<LI>          Installs the software.

<LI>          Creates the binary package file.

<LI>          Creates the source package file.

</OL>



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









<P>That's quite a bit of work for one command! Here it is, in action:

</P>



<!-- CODE //-->

<PRE>

# rpm -ba cdplayer-1.0.spec

* Package: cdplayer

Executing: %prep

...

+ exit 0

Executing: %build

...

+ exit 0

Executing: %install

...

+ exit 0

Executing: special doc

...

+ exit 0

Binary Packaging: cdplayer-1.0-1

...

Executing: %clean

...

+ exit 0

Source Packaging: cdplayer-1.0-1

cdplayer-1.0.spec

cdplayer-1.0.tgz

80 blocks

Generating signature: 0

Wrote: /usr/src/redhat/SRPMS/cdplayer-1.0-1.src.rpm

#

</PRE>

<!-- END CODE //-->



<P>As in previous examples, RPM executes the %prep,

%build, and %install sections, handles any special documentation files, creates a binary package file, and cleans up after itself.

</P>



<P>The final step in the build process is to create a source package file. As the output shows,

it consists of the spec file and the original sources. A source package may optionally include

one or more patch files, although in our example,

cdplayer requires none.

</P>



<P>At the end of a build using the -ba option, the software has been successfully built and

packaged in both binary and source form. But there are a few more build-time options we can

use. One of them is the -bl option.

</P>



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

12.1.6. rpm -bl: Check %files List

</A></H4>



<P>There's one last option that may be specified with

rpm -b, but unlike the others, which indicate the stage at which the build process is to stop, this option performs a variety of checks

on the %files list in the named spec file. When l is added to

rpm -b, the command does the following:

</P>



<UL>

<LI>          Expands the spec file's

%files list and checks that each file listed actually exists.

<LI>          Determines what shared libraries the software requires by examining every

executable file listed.

<LI>          Determines what shared

libraries are provided by the package.

</UL>



<P><CENTER>

<a href="0139-0142.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0147-0149.html">Next</A>

</CENTER></P>











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

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

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