0030-0032.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 281 行
HTML
281 行
<HTML>
<HEAD>
<TITLE>Maximum RPM (RPM):Using RPM to Install Packages: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=02 //-->
<!-- PAGES=0017-0036 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0027-0029.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0033-0035.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-30"><P>Page 30</P></A>
<H4><A NAME="ch02_ 15">
2.4.6. --force: The Big Hammer
</A></H4>
<P>Adding --force to an install command is a way of saying "Install it anyway!" In essence, it
adds --replacepkgs and --replacefiles to the command. Like a big hammer,
--force is an irresistible force (no pun intended) that makes things happen. In fact, the only thing that will
prevent an install from proceeding when --force is used is a dependency conflict.
</P>
<P>And as with a big hammer, it pays to fully understand why you need to use
--force before actually using it.
</P>
<H4><A NAME="ch02_ 16">
2.4.7. --excludedocs: Do Not Install Documentation for
This Package
</A></H4>
<P>RPM has a number of good features. One of them is that RPM classifies the files it installs
into one of three categories:
</P>
<UL>
<LI> Config files
<LI> Files containing documentation
<LI> All other files
</UL>
<P>RPM uses the --excludedocs option to prevent files classified as documentation from
being installed. In the following example, we know that the package contains documentation,
specifically, the man page: /usr/man/man1/cdp.1. Let's see how
--excludedocs keeps it from being installed:
</P>
<!-- CODE //-->
<PRE>
# rpm -iv --excludedocs cdp-0.33-3.i386.rpm
Installing cdp-0.33-3.i386.rpm
# ls -al /usr/man/man1/cdp.1
ls: /usr/man/man1/cdp.1: No such file or directory
#
</PRE>
<!-- END CODE //-->
<P>The primary reason to use --excludedocs is to save disk space. The savings can be sizable.
For example, on an RPM-installed Linux system, there can be more than 5,000
documentation files, using nearly 50MB.
</P>
<P>If you like, you can make --excludedocs the default for all installs. To do this, simply add
the following line to /etc/rpmrc, .rpmrc in your login directory, or the file specified with the
--rcfile option:
</P>
<!-- CODE SNIP //-->
<PRE>
excludedocs: 1
</PRE>
<!-- END CODE SNIP //-->
<P>After that, every time an rpm -i command is run, it will not install any documentation
files. For more information on rpmrc files, see Appendix B, "The
rpmrc File."
</P>
<A NAME="PAGENUM-31"><P>Page 31</P></A>
<H4><A NAME="ch02_ 17">
2.4.8. --includedocs: Install Documentation for This Package
</A></H4>
<P>As the name implies, --includedocs directs RPM to install
any files marked as being documentation. This option is normally not required, unless the
rpmrc file entry excludedocs: 1 is included in the referenced
rpmrc file. Here's an example. Note that in this example,
/etc/rpmrc contains excludedocs: 1, which directs RPM not to install documentation files:
</P>
<!-- CODE //-->
<PRE>
# ls /usr/man/man1/cdp.1
ls: /usr/man/man1/cdp.1: No such file or directory
# rpm -iv cdp-0.33-3.i386.rpm
Installing cdp-0.33-3.i386.rpm
# ls /usr/man/man1/cdp.1
ls: /usr/man/man1/cdp.1: No such file or directory
#
</PRE>
<!-- END CODE //-->
<P>Here we've checked to make sure that the cdp man page did not previously exist on the
system. Then after installing the cdp package, we find that the
excludedocs: 1 in /etc/rpmrc did its job: The man page wasn't installed. Let's try it again, this time adding the --includedocs
option:
</P>
<!-- CODE //-->
<PRE>
# ls /usr/man/man1/cdp.1
ls: /usr/man/man1/cdp.1: No such file or directory
# rpm -iv --includedocs cdp-0.33-3.i386.rpm
Installing cdp-0.33-3.i386.rpm
# ls /usr/man/man1/cdp.1
-rw-r--r-- 1 root root 4550 Apr 24 22:37 /usr/man/man1/cdp.1
#
</PRE>
<!-- END CODE //-->
<P>The --includedocs option overrode the rpmrc file's
excludedocs: 1 entry, causing RPM to install the documentation file.
</P>
<H4><A NAME="ch02_ 18">
2.4.9. --prefix <path>: Relocate the Package to
<path>, if Possible
</A></H4>
<P>Some packages give the person installing them flexibility in determining where on his system they should be installed. These are known as
relocatable packages. A relocatable package
differs from a package that cannot be relocated in only one way—the definition of a default
prefix. Because of this, it takes a bit of additional effort to determine whether a package is
relocatable. But here's an RPM command that can be used to find out:
</P>
<!-- CODE SNIP //-->
<PRE>
rpm -qp --queryformat "%{defaultprefix\}\n" <packagefile>
</PRE>
<!-- END CODE SNIP //-->
<BR>
<P>
<CENTER>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
NOTE
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
You can find more about RPM's query commands in Chapter 5,
"Getting Information About Packages."
</BLOCKQUOTE></TD></TR>
</TABLE></CENTER>
</P>
<A NAME="PAGENUM-32><P>Page 32</P></A>
<P>Just replace <packagefile> with the name of the package file you want to check out. If
the package is not relocatable, you'll only see the word
(none). If, on the other hand, the command displays a path, the package is relocatable. Unless specified otherwise, every file in
the package will be installed somewhere below the path specified by the default prefix.
</P>
<P>What if you want to specify otherwise? Easy. Just use the
--prefix option. Let's give it a try:
</P>
<!-- CODE //-->
<PRE>
# rpm -qp --queryformat "%fdefaultprefixg\n" cdplayer-1.0-1.i386.rpm
/usr/local
# rpm -i --prefix /tmp/test cdplayer-1.0-1.i386.rpm
#
</PRE>
<!-- END CODE //-->
<P>Here we've used our magic query command to determine that the
cdplayer package is relocatable. It normally installs below
/usr/local, but we wanted to move it around. By
adding the --prefix option, we were able to make the package install in
/tmp/test. If we take a look there, we'll see that RPM created all the necessary directories to hold the package's files:
</P>
<!-- CODE //-->
<PRE>
# ls -lR /tmp/test/
total 2
drwxr-xr-x 2 root root 1024 Dec 16 13:21 bin/
drwxr-xr-x 3 root root 1024 Dec 16 13:21 man/
/tmp/test/bin:
total 41
-rwxr-xr-x 1 root root 40739 Oct 14 20:25 cdp*
lrwxrwxrwx 1 root root 17 Dec 16 13:21 cdplay -> /tmp/test/bin/cdp*
/tmp/test/man:
total 1 drwxr-xr-x 2 root root 1024 Dec 16 13:21 man1/
/tmp/test/man/man1:
total 5
-rwxr-xr-x 1 root root 4550 Oct 14 20:25 cdp.1*
#
</PRE>
<!-- END CODE //-->
<H4><A NAME="ch02_ 19">
2.4.10. --noscripts: Do Not Execute Pre- and Postinstall Scripts
</A></H4>
<P>Before we talk about the --noscripts option, we need to cover a bit of background. In
section 2.4.1, you saw some output from an install using the
-vv option. As you can see, there are two lines that mention preinstall and postinstall scripts. When some packages are installed,
they may require that certain programs be executed before, after, or before and after the
package's files are copied to disk.
</P>
<BR>
<P>
<CENTER>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
NOTE
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
It's possible to use RPM's query command to see if a package has pre-
or postinstall scripts. See section 5.2.2 in Chapter 5 for more information.
</BLOCKQUOTE></TD></TR>
</TABLE></CENTER>
</P>
<P>The --noscripts option prevents these scripts from being executed during an install. This is
a very dangerous thing to do! The --noscripts option is really meant for package builders to
use
</P>
<P><CENTER>
<a href="0027-0029.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0033-0035.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?