0147-0149.html

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

HTML
274
字号




<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="0143-0146.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0150-0153.html">Next</A>

</CENTER></P>



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









<P>Why is it necessary to do all this checking? When would it be useful? Keep in mind that

the %files list must be generated manually. By using the

-bl option, the following steps are all that's necessary to create a

%files list:

</P>



<UL>

<LI>          Writing the

%files list

<LI>          Using the

-bl option to check the %files list

<LI>          Making any necessary changes to the

%files list

</UL>



<P>It may take more than one iteration through these steps, but eventually the list check will

pass. Using the -bl option to check the %files list is certainly better than starting a two-hour

package build, only to find out at the very end that the list contains a misspelled filename.

</P>



<P>Here's an example of the -bl option in action:

</P>



<!-- CODE //-->

<PRE>

# rpm -bl cdplayer-1.0.spec

Package: cdplayer

File List Check: cdplayer-1.0-1

Finding dependencies...

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

#

</PRE>

<!-- END CODE //-->



<P>It's hard to see exactly what RPM is doing from the output, but if we add

-vv, we can get a bit more information:

</P>



<!-- CODE //-->

<PRE>

# rpm -bl -vv cdplayer-1.0.spec

D: Switched to BASE package

D: Source(0) = sunsite.unc.edu:/pub/Linux/apps/sound/cds/cdplayer-1.0.tgz

D: Switching to part: 12

D: fileFile =

D: Switched to package: (null)

D: Switching to part: 2

D: fileFile =

D: Switching to part: 3

D: fileFile =

D: Switching to part: 4

D: fileFile =

D: Switching to part: 10

D: fileFile =

D: Switched to package: (null)

* Package: cdplayer

File List Check: cdplayer-1.0-1

D: ADDING: /usr/doc/cdplayer-1.0-1

D: ADDING: /usr/doc/cdplayer-1.0-1/README

D: ADDING: /usr/local/bin/cdp

D: ADDING: /usr/local/bin/cdplay

D: ADDING: /usr/local/man/man1/cdp.1

D: md5(/usr/doc/cdplayer-1.0-1/README) = 2c149b2fb1a4d65418131a19b242601c

D: md5(/usr/local/bin/cdp) = 0f2a7a2f81812c75fd01c52f456798d6

D: md5(/usr/local/bin/cdplay) = d41d8cd98f00b204e9800998ecf8427e

D: md5(/usr/local/man/man1/cdp.1) = b32cc867ae50e2bdfa4d6780b084adfa

Finding dependencies...

D: Adding require: libncurses.so.2.0

D: Adding require: libc.so.5

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

#

</PRE>

<!-- END CODE //-->



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



<P>Looking at this more verbose output, it's easy to see that there's a great deal going on. Some

of it is not directly pertinent to checking the

%files list, however. For example, the output extending from the first line to the line reading

* Package: cdplayer reflects processing that takes place during actual package building and can be ignored.

</P>



<P>Following that section is the actual %files list check. In this section, every file named in

the %files list is checked to make sure it exists. The phrase

ADDING: again reflects RPM's package building roots. When using the

-bl option, however, RPM is simply making sure the files

exist on the build system. If the --timecheck option (described a bit later, in section 12.1.14) is

present, the checks required by that option are performed here, as well.

</P>



<P>After the list check, the MD5 checksums of each file are calculated and displayed. While

this information is vital during actual package building, it is not used when using the

-bl option.

</P>



<P>Finally, RPM determines which shared libraries the listed files require. In this case, there

are only two: libc.so.5 and libncurses.so.2.0. While not strictly a part of the list-checking

process, displaying shared library dependencies can be quite helpful at this point. It can point

out possible problems, such as assuming that the target systems have a certain library installed

when, in fact, they do not.

</P>



<P>So far, we've only seen what happens when the

%files list is correct. Let's see what happens where the list has problems. In this example, we've added a bogus file to the package's

%files list:

</P>



<!-- CODE //-->

<PRE>

# rpm -bl cdplayer-1.0.spec

Package: cdplayer

File List Check: cdplayer-1.0-1

File not found: /usr/local/bin/bogus

Build failed.

#

</PRE>

<!-- END CODE //-->



<P>Reflecting more of its package building roots, rpm

-bl says that the build failed. But the bottom line is that there is no such file as

/usr/bin/bogus. In this example, we made the name obviously wrong, but in a more real-world setting, the name will more likely be a

misspelling in the %files list. Okay, let's correct the

%files list and try again:

</P>



<!-- CODE //-->

<PRE>

# rpm -bl cdplayer-1.0.spec

Package: cdplayer

File List Check: cdplayer-1.0-1

File not found: /usr/local/bin/cdplay

Build failed.

#

</PRE>

<!-- END CODE //-->



<P>Another error! In this case the file is spelled correctly, but it is not on the build system,

even though it should be. Perhaps it was deleted accidentally. In any case, let's rebuild the

software and try again:

</P>



<!-- CODE SNIP //-->

<PRE>

# rpm -bi cdplayer-1.0.spec

* Package: cdplayer

Executing: %prep

...

</PRE>

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



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



<!-- CODE //-->

<PRE>

+ exit 0

Executing: %build

...

+ exit 0

Executing: %install

...

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

...

+ exit 0

Executing: special doc

...

+ exit 0

#





# rpm -bl cdplayer-1.0.spec

Package: cdplayer

File List Check: cdplayer-1.0-1

Finding dependencies...

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

#

</PRE>

<!-- END CODE //-->



<P>Done! The moral to this story is that using rpm

-bl and fixing the error it flagged doesn't necessarily mean your

%files list is ready for prime time: Always run it again to make sure!

</P>



<H4>

12.1.7. --short-circuit: Force Build to Start at a Particular Stage

</H4>



<P>Although it sounds dangerous, the

--short-circuit option can be your friend. This option

is used during the initial development of a package.

Earlier in the chapter, we explored stopping RPM's build process at different stages. Using

--short-circuit, we can start the build process at different stages.

</P>



<P>One time that --short-circuit comes in handy is when you're trying to get software to

build properly. Just think what it would be like&#151;you're hacking away at the sources, trying a

build, getting an error, and hacking some more to fix that error. Without

--short-circuit, you'd have to do the following:

</P>



<OL>

<LI>          Make your change to the sources.

<LI>          Use tar to create a new source archive.

<LI>          Start a build with something like rpm

-bc.

<LI>          See another bug.

<LI>          Go back to step 1.

</OL>



<P>Pretty cumbersome! Since RPM's build process is designed to start with the sources in

their original tar file, unless your modifications end up in that tar file, they won't be used in the

next build. (As mentioned in Chapter 10, if the original sources need to be modified, the

modifications should be kept as a separate set of patches. However, during development, it makes

more sense to not generate patches every time a change to the original source is made.)

</P>



<P><CENTER>

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

</CENTER></P>











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

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

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