0306-0308.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 519 行
HTML
519 行
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:Getting Started with Red Hat Linux</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=0672311739 //-->
<!-- TITLE=RED HAT LINUX 2ND EDITION //-->
<!-- AUTHOR=DAVID PITTS ET AL //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS PUBLISHING //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=14 //-->
<!-- PAGES=0299-0318 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0303-0305.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0309-0311.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-306"><P>Page 306</P></A>
<P>The version mode, invoked as
</P>
<!-- CODE SNIP //-->
<PRE>
rpm --version
</PRE>
<!-- END CODE SNIP //-->
<P>prints out a line containing version information, similar to this:
</P>
<!-- CODE SNIP //-->
<PRE>
RPM version 2.3.11
</PRE>
<!-- END CODE SNIP //-->
<P>The help mode out an extensive help message and is invoked as follows:
</P>
<!-- CODE SNIP //-->
<PRE>
rpm --help
</PRE>
<!-- END CODE SNIP //-->
<P>Because the message is long, it is handy to have a large
xterm or to pipe the output to more. To get a shorter help message, just type
</P>
<!-- CODE SNIP //-->
<PRE>
rpm
</PRE>
<!-- END CODE SNIP //-->
<P>This prints out a usage message. The showrc mode
</P>
<!-- CODE SNIP //-->
<PRE>
rpm --showrc
</PRE>
<!-- END CODE SNIP //-->
<P>prints out a list of variables that can be set in the files
/etc/rpmrc and $HOME/.rpmrc. The default values are adequate for most installations.
</P>
<P>The rebuilddb option is used to rebuild the database that RPM uses to keep track of
which packages are installed on a system. It is invoked as follows:
</P>
<!-- CODE SNIP //-->
<PRE>
rpm --rebuilddb
</PRE>
<!-- END CODE SNIP //-->
<P>The database files are usually stored in
/var/lib/rpm/. In most cases the database files do
not need to be rebuilt very often.
</P>
<H4><A NAME="ch14_ 12">
Installing Packages
</A></H4>
<P>One of the major uses of RPM is to install software packages. The general syntax of an
rpm install command is
</P>
<!-- CODE SNIP //-->
<PRE>
rpm -i [options] [packages]
</PRE>
<!-- END CODE SNIP //-->
<P>where options can be one of the common options given earlier or one of the install
options covered in the following list, and
packages is the name of one or more RPM package files.
Some of the install options are as follows:
</P>
<TABLE WIDTH="360">
<TR><TD>
-v
</TD><TD>
Prints out what RPM is doing.
</TD></TR>
<TR><TD>
-h or --hash
</TD><TD>
Prints out 50 hash marks (#) as the package is installed.
</TD></TR>
<TR><TD>
--percent
</TD><TD>
Prints out percentages as files are extracted from
the package.
</TD></TR>
<TR><TD>
--test
</TD><TD>
Goes through a package install, but does not install
anything; mainly used to catch conflicts.
</TD></TR>
</TABLE>
<A NAME="PAGENUM-307"><P>Page 307</P></A>
<TABLE WIDTH+"360">
<TR><TD>
--excludedocs
</TD><TD>
Prevents the installation of files marked as
documentation, such as man pages.
</TD></TR>
<TR><TD>
--includedocs
</TD><TD>
Forces files marked as documentation to be installed;
this is the default.
</TD></TR>
<TR><TD>
--nodeps
</TD><TD>
No dependency checks are performed before installing a
package.
</TD></TR>
<TR><TD>
--replacefiles
</TD><TD>
Allows for installed files to be replaced with files from
the package being installed.
</TD></TR>
<TR><TD>
--replacepkgs
</TD><TD>
Allows for installed packages to be replaced
with the packages being installed.
</TD></TR>
<TR><TD>
--oldpackage
</TD><TD>
Allows for a newer version of an installed package to be
replaced with an older version.
</TD></TR>
<TR><TD>
--force
</TD><TD>
Forces a package to be installed.
</TD></TR>
</TABLE>
<P>When giving options to RPM, regardless of the mode, all the single-letter options can be
lumped together in one block. For example, the command
</P>
<!-- CODE SNIP //-->
<PRE>
rpm -i -v -h kernel-2.0.30-3.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>is equivalent to
</P>
<!-- CODE SNIP //-->
<PRE>
rpm -ivh kernel-2.0.30-3.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>All options starting with -- must be given separately, however.
</P>
<P>Now let's look at a couple of examples of installing RPM packages. The first example
installs vim (the improved version of vi) from the package:
</P>
<!-- CODE SNIP //-->
<PRE>
vim-4.5-2.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>This package follows the standard naming convention for RPM packages, which is</P>
<!-- CODE SNIP //-->
<PRE>
name-version-release.arch.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>where name is the package's name, version is the package's version,
release is the package's release level, arch is the hardware architecture the package is for, and
rpm is the default extension. This naming scheme is quite handy because some of the essential information about
a particular package can be determined from just looking at its name.
</P>
<P>For the vim package, say you are installing vim version 4.5, release 2 for a computer with
the i386 architecture. Let's go ahead and install this package. With the Red Hat CD-ROM on <BR>
/mnt/cdrom, the package you want is
</P>
<!-- CODE SNIP //-->
<PRE>
/mnt/cdrom/RedHat/RPMS/vim-4.5-2.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>First, cd into the appropriate directory; then to install it type the following at the prompt
(#):
</P>
<A NAME="PAGENUM-308"><P>Page 308</P></A>
<!-- CODE SNIP //-->
<PRE>
# rpm -ivh vim-4.5-2.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>As the package is installed, the output will look like the following:
</P>
<!-- CODE SNIP //-->
<PRE>
vim ################
</PRE>
<!-- END CODE SNIP //-->
<P>When the install is finished, 50 hash marks will be displayed.
</P>
<P>In this example I used the hash character (#) to indicate the root prompt because only root
can properly install packages for an entire system. If you try to install this package as a user
other than root, an error similar to the following will be generated:
</P>
<!-- CODE SNIP //-->
<PRE>
failed to open //var/lib/rpm/packages.rpm
error: cannot open //var/lib/rpm/packages.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>Now to install the X11 version of vim from the package:
</P>
<!-- CODE SNIP //-->
<PRE>
/mnt/cdrom/RedHat/RPMS/vim-X11-4.2-8.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>If you try using
</P>
<!-- CODE SNIP //-->
<PRE>
rpm -ivh vim-X11-4.2-8.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>you will get the following error:
</P>
<!-- CODE SNIP //-->
<PRE>
package vim-X11-4.2-8 is already installed
error: vim-X11-4.2-8.i386.rpm cannot be installed
</PRE>
<!-- END CODE SNIP //-->
<P>To install this package, use the --replacepkgs option:
</P>
<!-- CODE SNIP //-->
<PRE>
rpm -ivh --replacepkgs vim-X11-4.5-2.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>Occasionally, the files that one package installs conflicts with the files of a previously
installed package. If you had vim version 4.2 installed, the following message would have been
generated:
</P>
<!-- CODE SNIP //-->
<PRE>
/bin/vim conflicts with file from vim-4.2-8
/usr/share/vim/vim_tips.txt conflicts with file from vim-4.2-8
error: vim-4.5-2.i386.rpm cannot be installed
</PRE>
<!-- END CODE SNIP //-->
<P>If you wanted to install these files anyway, the
--replacefiles option could be added to the command.
</P>
<P>Another type of conflict that is sometimes encountered is a dependency conflict. This
happens when a package that is being installed requires certain other packages to function correctly.
For example, when I try to install the package
</P>
<!-- CODE SNIP //-->
<PRE>
# rpm -ivh dosemu-0.66.2-1.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>I get the following dependency errors:
</P>
<!-- CODE SNIP //-->
<PRE>
failed dependencies:
kernel >= 2.0.28 is needed by dosemu-0.66.2-1
dosemu = 0.64.1 is needed by xdosemu-0.64.1-1
</PRE>
<!-- END CODE SNIP //-->
<P><CENTER>
<a href="0303-0305.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0309-0311.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?