0021-0023.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 305 行
HTML
305 行
<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="0017-0020.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0024-0026.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-21"><P>Page 21</P></A>
<P>
not always available. Therefore, the URL may also contain a username and password
preceding the hostname:</P>
<!-- CODE SNIP //-->
<PRE>
ftp://smith:mypass@ftp.gnomovision.com/pub/rpms/foobar-1.0-1.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>However, entering a password where it can be seen by anyone looking at your screen is a
bad idea. So try this format:
</P>
<!-- CODE SNIP //-->
<PRE>
ftp://smith@ftp.gnomovision.com/pub/rpms/foobar-1.0-1.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>RPM will prompt you for your password, and you'll be in business:
</P>
<!-- CODE //-->
<PRE>
# rpm -i ftp://smith@ftp.gnomovision.com /pub/rpms/apmd-2.4-1.i386.rpm
Password for smith@ftp.gnomovision.com: mypass (not echoed)
#
</PRE>
<!-- END CODE //-->
<P>After you enter a valid password, RPM installs the package.
</P>
<P>On some systems, the FTP daemon doesn't run on the standard port 21. Normally this is
done for the sake of enhanced security. Fortunately, there is a way to specify a nonstandard port
in a URL:
</P>
<!-- CODE SNIP //-->
<PRE>
ftp://ftp.gnomovision.com:1024/pub/rpms/foobar-1.0-1.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>This URL will direct the FTP request to port 1024. The
--ftpport option is another way to specify the port. This option is discussed later in the chapter, in section 2.4.15.
</P>
<H4><A NAME="ch02_ 5">
2.2.2. A Warning Message You Might Never See
</A></H4>
<P>Depending on circumstances, the following message might be rare or very common.
While performing an ordinary install, RPM prints a warning message:
</P>
<!-- CODE SNIP //-->
<PRE>
# rpm -i cdp-0.33-100.i386.rpm
warning: /etc/cdp-config saved as /etc/cdp-config.rpmorig
#
</PRE>
<!-- END CODE SNIP //-->
<P>What does it mean? It has to do with RPM's handling of config files. In the previous
example, RPM found a file (/etc/cdp-config) that didn't belong to any RPM-installed package.
Because the cdp-0.33-100 package contains a file of the same name that is to be installed in
the same directory, there is a problem.
</P>
<P>RPM solves this the best way it can. It performs two steps:
</P>
<OL>
<LI> It renames the original file to
cdp-config.rpmorig.
<LI> It installs the new cdp-config file that came with the package.
</OL>
<P>Continuing our example, if we look in /etc, we see that this is exactly what has happened:
</P>
<!-- CODE SNIP //-->
<PRE>
# ls -al /etc/cdp*
-rw-r--r-- 1 root root 119 Jun 23 16:00 /etc/cdp-config
-rw-rw-r-- 1 root root 56 Jun 14 21:44 /etc/cdp-config.rpmorig
#
</PRE>
<!-- END CODE SNIP //-->
<A NAME="PAGENUM-22"><P>Page 22</P></A>
<P>This is the best possible solution to a tricky problem. The package is installed with a config
file that is known to work. After all, the original file may be for an older, incompatible version
of the software. However, the original file is saved so that it can be studied by the system administrator, who can decide whether the original file should be put back into service.
</P>
<H3><A NAME="ch02_ 6">
2.3. Two Handy Options
</A></H3>
<P>There are two options to rpm -i that work so well and are so useful that you might think
they should be RPM's default behavior. They aren't, but using them requires only that you type
an extra two characters, which are described in the following sections.
</P>
<H4><A NAME="ch02_ 7">
2.3.1. Getting a Bit More Feedback with -v
</A></H4>
<P>Even though rpm -i is doing many things, it's not very exciting, is it?
When performing installs, RPM is pretty quiet unless something goes wrong. However, we can ask for a bit
more output by adding -v to the command:
</P>
<!-- CODE SNIP //-->
<PRE>
# rpm -iv eject-1.2-2.i386.rpm
Installing eject-1.2-2.i386.rpm
#
</PRE>
<!-- END CODE SNIP //-->
<P>By adding -v, RPM displayed a simple status line. Using
-v is a good idea, particularly if you're going to use a single command to install more than one package:
</P>
<!-- CODE SNIP //-->
<PRE>
# rpm -iv *.rpm
Installing eject-1.2-2.i386.rpm
Installing iBCS-1.2-3.i386.rpm
Installing logrotate-1.0-1.i386.rpm
#
</PRE>
<!-- END CODE SNIP //-->
<P>In this case, there were three .rpm files in the directory. By using a simple wildcard, it's as easy to install 1 package as it is to install 100!
</P>
<H4><A NAME="ch02_ 8">
2.3.2. -h: Perfect for the Impatient
</A></H4>
<P>Sometimes a package can be quite large. Other than watching the
disk activity light flash, there's no assurance that RPM is working, and if it is, how far along it is. If you add
-h, RPM will print 50 hash marks (#) as the install proceeds:
</P>
<!-- CODE SNIP //-->
<PRE>
# rpm -ih eject-1.2-2.i386.rpm
##################################################
#
</PRE>
<!-- END CODE SNIP //-->
<P>When all 50 hash marks are printed, the package is completely installed. Using
-v with -h results in a very nice display, particularly when you're installing more than one package:
</P>
<!-- CODE //-->
<PRE>
# rpm -ivh *.rpm
eject ##################################################
iBCS ##################################################
logrotate ##################################################
#
</PRE>
<!-- END CODE //-->
<A NAME="PAGENUM-23"><P>Page 23</P></A>
<H3><A NAME="ch02_ 9">
2.4. Additional Options to rpm -i
</A></H3>
<P>Normally rpm -i, perhaps with -v and -h, is all you'll need. However, there may be times
when a basic install is not going to get the job done. Fortunately, RPM has a wealth of install
options to make the tough times a little easier. As with any other powerful tool, you should
understand these options before putting them to use. Let's take a look at them.
</P>
<H4><A NAME="ch02_ 10">
2.4.1. Getting a Lot More Information with -vv
</A></H4>
<P>Sometimes it's necessary to have even more information than we can get with
-v. By adding another v, we can start to see more of RPM's inner workings:
</P>
<!-- CODE //-->
<PRE>
# rpm -ivv eject-1.2-2.i386.rpm
D: installing eject-1.2-2.i386.rpm
Installing eject-1.2-2.i386.rpm
D: package: eject-1.2-2 files test = 0
D: running preinstall script (if any)
D: setting file owners and groups by name (not id)
D: ///usr/bin/eject owned by root (0), group root (0) mode 755
D: ///usr/man/man1/eject.1 owned by root (0), group root (0) mode 644
D: running postinstall script (if any)
#
</PRE>
<!-- END CODE //-->
<P>The lines starting with D: have been added by using
-vv. The line ending with files test = 0 means that RPM is going to install the package. If the number were nonzero, it would
mean that the --test option is present, and RPM would not perform the install. For more
information on using --test with rpm -i, see section 2.4.2.
</P>
<P>Continuing with this example, we see that RPM next executes a preinstall script (if there
is one), followed by the actual installation of the files in the package. There is one line for
each file being installed, and that line shows the filename, ownership, group membership, and
permissions (or mode) applied to the file. With larger packages, the output from
-vv can become quite lengthy! Finally, RPM runs a postinstall script, if one exists for the package. We'll
be discussing pre- and postinstall scripts in more detail in section 2.4.10.
</P>
<P>In most cases, it will not be necessary to use
-vv. It is normally used by software engineers
working on RPM itself, and the output can change without notice. However, it's a handy way to gain insights into RPM's inner workings.
</P>
<H4><A NAME="ch02_ 11">
2.4.2. --test: Perform Installation Tests Only
</A></H4>
<P>There are times when it's more appropriate to take it slow and not try to install a package
right away. RPM provides the --test option for that. As the names implies, it performs all the
checks that RPM normally does during an install, but it stops short of actually performing the
steps necessary to install the package:
</P>
<!-- CODE SNIP //-->
<PRE>
# rpm -i --test eject-1.2-2.i386.rpm
#
</PRE>
<!-- END CODE SNIP //-->
<P><CENTER>
<a href="0017-0020.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0024-0026.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?