📄 0045-0048.html
字号:
<HTML>
<HEAD>
<TITLE>Maximum RPM (RPM):Using RPM to Upgrade 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=04 //-->
<!-- PAGES=0045-0052 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="../ch03/0044-0044.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0049-0051.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-45"><P>Page 45</P></A>
<H3><A NAME="ch04_ 1">
Chapter 4
</A></H3>
<H2>
Using RPM to Upgrade<BR> Packages
</H2>
<A NAME="PAGENUM-46"><P>Page 46</P></A>
<P>Table 4.1. Upgrade-mode command syntax and options.
</P>
<TABLE>
<TR><TD>
rpm -U (or --upgrade)
</TD><TD>
Options
</TD><TD>
file1.rpm...fileN.rpm
</TD></TR><TR><TD>
</TD><TD>
<B>Parameters</B>
</TD><TD>
</TD></TR><TR><TD>
file1.rpm...fileN.rpm
</TD><TD>
One or more RPM package files (URLs are usable)
</TD><TD>
</TD></TR><TR><TD>
</TD><TD>
<B>Upgrade-Specific Options
</TD><TD>
Section</B>
</TD></TR><TR><TD>
-h (or --hash)
</TD><TD>
Hash marks (#) during upgrade*
</TD><TD>
2.3.2
</TD></TR><TR><TD>
--oldpackage
</TD><TD>
Permit upgrading to an older package
</TD><TD>
4.3.1
</TD></TR><TR><TD>
--test
</TD><TD>
Perform upgrade tests only*
</TD><TD>
2.4.2
</TD></TR><TR><TD>
--excludedocs
</TD><TD>
Do not install documentation*
</TD><TD>
2.4.7
</TD></TR><TR><TD>
--includedocs
</TD><TD>
Install documentation*
</TD><TD>
2.4.8
</TD></TR><TR><TD>
--replacepkgs
</TD><TD>
Replace a package with a new copy of itself*
</TD><TD>
2.4.3
</TD></TR><TR><TD>
--replacefiles
</TD><TD>
Replace files owned by another package*
</TD><TD>
2.4.4
</TD></TR><TR><TD>
--force
</TD><TD>
Ignore package and file conflicts
</TD><TD>
4.3.2
</TD></TR><TR><TD>
--percent
</TD><TD>
Print percentages during upgrade*
</TD><TD>
2.4.11
</TD></TR><TR><TD>
--noscripts
</TD><TD>
Do not execute pre- and postinstall scripts
</TD><TD>
4.3.3
</TD></TR><TR><TD>
--prefix <path>
</TD><TD>
Relocate package to <path> if possible*
</TD><TD>
2.4.9
</TD></TR><TR><TD>
--ignorearch
</TD><TD>
Do not verify package architecture*
</TD><TD>
2.4.17
</TD></TR><TR><TD>
--ignoreos
</TD><TD>
Do not verify package operating system*
</TD><TD>
2.4.18
</TD></TR><TR><TD>
--nodeps
</TD><TD>
Do not check dependencies*
</TD><TD>
2.4.5
</TD></TR><TR><TD>
--ftpproxy <host>
</TD><TD>
Use <host> as the FTP proxy*
</TD><TD>
2.4.16
--ftpport <port>
</TD></TR><TR><TD>
Use <port> as the FTP port*
</TD><TD>
2.4.15
</TD><TD>
</TD></TR><TR><TD>
<B>General Options
</TD><TD>
Section</B>
</TD><TD>
-v
</TD></TR><TR><TD>
Display additional information*
</TD><TD>
2.3.1
</TD><TD>
-vv
</TD></TR><TR><TD>
Display debugging information*
</TD><TD>
2.4.1
</TD><TD>
--root <path>
</TD></TR><TR><TD>
Set alternate root to <path>*
</TD><TD>
2.4.13
</TD><TD>
--rcfile <rcfile>
</TD></TR><TR><TD>
Set alternate rpmrc file to <rcfile>*
</TD><TD>
2.4.12
</TD><TD>
--dbpath <path>
</TD></TR><TR><TD>
Use <path> to find the RPM database*
</TD><TD>
2.4.14
</TD></TR></TABLE>
<P>*This option behaves identically to the same option used with rpm -i. See Chapter 2, "Using
RPM to Install Packages," for more information on this option.
</P>
<A NAME="PAGENUM-47"><P>Page 47</P></A>
<H3><A NAME="ch04_ 2">
4.1. rpm -U: What Does It Do?
</A></H3>
<P>If there were one RPM command that could win over friends, it would be RPM's
upgrade command. After all, anyone who has ever tried to install a newer version of any software
knows what a traumatic experience it can be. With RPM, though, this process is reduced to a
single command: rpm -U. The rpm -U command
(--upgrade is equivalent) performs two distinct <BR>
operations:
</P>
<UL>
<LI> It installs the desired package.
<LI> It erases
all older versions of the package, if any exist.
</UL>
<P>If it sounds to you like rpm -U is nothing more than an
rpm -i command (see Chapter 2) followed by the appropriate number of
rpm -e commands (see Chapter 3, "Using RPM to
Erase Packages"), you'd be exactly right. In fact, we'll be referring to Chapters 2 and 3 as we
discuss rpm -U, so if you haven't at least skimmed those chapters yet, you might want to do that now.
</P>
<P>Although some people might think it's a cheap shot to claim that RPM performs an
upgrade when in fact it's just doing the equivalent of a couple other commands, in reality it's a
very smart thing to do. Carefully crafting RPM's package installation and erasure commands to
do the work required during an upgrade makes RPM more tolerant of misuse by preserving
important files even if an upgrade isn't being done.
</P>
<P>If RPM had been written with a very smart upgrade command, and the install and erase
commands couldn't handle upgrade situations at all, installing a package could overwrite a
modified configuration file. Likewise, erasing a package would also mean that config files could
be erased. Not a good situation! However, RPM's approach to upgrades makes it possible to
handle even the most tricky situation—having multiple versions of a package installed simultaneously.
</P>
<H4><A NAME="ch04_ 3">
4.1.1. Config File Magic
</A></H4>
<P>While the rpm -i and rpm -e commands each do their part to keep config files straight, it
is with rpm -U that the full power of RPM's config file handling shows through. There are
no fewer than six different scenarios that RPM takes into account when handling config files.
</P>
<P>In order to make the appropriate decisions, RPM needs information. The information used
to decide how to handle config files is a set of three large numbers known as MD5 checksums.
An MD5 checksum is produced when a file is used as the input to a complex series of
mathematical operations. The resulting checksum has a unique property in that any change to the
file's contents will result in a change to the checksum of that file. (Actually, there's a 1 in
2<SUP>128</SUP> chance a change will go undetected, but for all practical purposes, it's as close to perfect as we can
get.) Therefore, MD5 checksums are a powerful tool for quickly determining whether two
different files have the same contents.
</P>
<A NAME="PAGENUM-48"><P>Page 48</P></A>
<P>The three checksums RPM uses to determine what should be done with a config file are
</P>
<UL>
<LI> The MD5 checksum of the file when it was originally installed. We'll call this
the checksum of the original file.
<LI> The MD5 checksum of the file as it exists at upgrade time. We'll call this
the checksum of the current file.
<LI> The MD5 checksum of the corresponding file in the new package. We'll call this
the checksum of the new file.
</UL>
<P>Let's take a look at the various combinations of checksums, see what RPM will do because
of them, and discuss why. In the following examples, we'll use the letters X, Y, and Z in place
of lengthy MD5 checksums.
</P>
<B>
4.1.1.1. Original File = X, Current File = X, New File = X
</B>
<P>In this case, the file originally installed was never modified. Or, as some sticklers for detail
may note, it may have been modified, and subsequently those modifications were undone.
The file in the new version of the package is identical to the file on disk.
</P>
<P>In this case, RPM installs the new file, overwriting the original. You might be wondering
why anyone would go to the trouble of installing the new file if it's just the same as the existing
one. The reason is that aspects of the file other than its name and contents might have
changed. The file's ownership, for example, might be different in the new version.
</P>
<B>
4.1.1.2. Original File = X, Current File = X, New File = Y
</B>
<P>The original file has not been modified, but the file in the new package is different.
Perhaps the difference represents a bug fix or a new feature. It makes no difference to RPM.
</P>
<P>In this case, RPM installs the new file, overwriting the original. This makes sense.
If it didn't, RPM would never permit newer, modified versions of software to be installed! The
original file is not saved because it had not been changed. A lack of changes here means that no
site-specific modifications were made to the file.
</P>
<B>
4.1.1.3. Original File = X, Current File = Y, New File = X
</B>
<P>Here we have a file that was changed at some point. However, the new file is identical to
the existing file prior to the local modifications.
</P>
<P>In this case, RPM takes the viewpoint that since the original file and the new file are
identical, the modifications made to the original version must still be valid for the new version. It
leaves the existing, modified file in place.
</P>
<P><CENTER>
<a href="../ch03/0044-0044.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0049-0051.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -