⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0024-0026.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:




<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="0021-0023.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0027-0029.html">Next</A>

</CENTER></P>



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





<P>Once again, there's not very much output. This is because the test succeeded; had there

been a problem, the output would have been a bit more interesting. In this example, there are

some problems:

</P>



<!-- CODE //-->

<PRE>

# rpm -i --test rpm-2.0.11-1.i386.rpm

/bin/rpm conflicts with file from rpm-2.3-1

/usr/bin/gendiff conflicts with file from rpm-2.3-1

/usr/bin/rpm2cpio conflicts with file from rpm-2.3-1

/usr/bin/rpmconvert conflicts with file from rpm-2.3-1

/usr/man/man8/rpm.8 conflicts with file from rpm-2.3-1

error: rpm-2.0.11-1.i386.rpm cannot be installed

#

</PRE>

<!-- END CODE //-->



<P>Note the version numbers. We're trying to install an older version of RPM (2.0.11) on top

of a newer version (2.3). RPM faithfully reported the various file conflicts and summarized

with a message saying that the install would not have proceeded, even if

--test had not been on the command line.

</P>



<P>The --test option will also catch dependency-related problems:

</P>



<!-- CODE SNIP //-->

<PRE>

# rpm -i --test blather-7.9-1.i386.rpm

failed dependencies:

bother &gt;= 3.1 is needed by blather-7.9-1

#

</PRE>

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

<BR>

<P>



<CENTER>

<TABLE BGCOLOR="#FFFF99">

<TR><TD><B>

TIP

</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

Here's a tip for all you script writers out there: RPM will return a nonzero

status if the --test option detects problems.

</BLOCKQUOTE></TD></TR>

</TABLE></CENTER>

</P>

<H4><A NAME="ch02_ 12">

2.4.3. --replacepkgs: Install the Package Even if It's

Already Installed

</A></H4>



<P>The --replacepkgs option is used to force RPM to install a package that it believes to be

installed already. This option is normally used if the installed package has been damaged

somehow and needs to be fixed up.

</P>



<P>To see how the --replacepkgs option works, let's first install some software:

</P>



<!-- CODE SNIP //-->

<PRE>

# rpm -iv cdp-0.33-2.i386.rpm

Installing cdp-0.33-2.i386.rpm

#

</PRE>

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



<P>Okay, now that we have cdp-0.33-2 installed, let's see what happens if we try to install

the same version on top of itself:

</P>



<!-- CODE //-->

<PRE>

# rpm -iv cdp-0.33-2.i386.rpm

Installing cdp-0.33-2.i386.rpm

package cdp-0.33-2 is already installed

error: cdp-0.33-2.i386.rpm cannot be installed

#

</PRE>

<!-- END CODE //-->



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





<P>That didn't go very well. Let's see what adding

--replacepkgs will do:

</P>



<!-- CODE SNIP //-->

<PRE>

# rpm -iv --replacepkgs cdp-0.33-2.i386.rpm

Installing cdp-0.33-2.i386.rpm

#

</PRE>

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



<P>Much better. The original package was replaced by a new copy of itself.

</P>



<H4><A NAME="ch02_ 13">

2.4.4. --replacefiles: Install the Package Even if It

Replaces Another Package's Files

</A></H4>



<P>While the --replacepkgs option permits a package to be installed on top of itself,

--replacefiles is used to allow a package to overwrite files belonging to a different package. Sounds

strange? Let's go over it in a bit more detail.

</P>



<P>One thing that sets RPM apart from many other package managers is that it keeps track of

all the files it installs in a database. Each file's database entry contains a variety of

information about the file, including a means of summarizing the file's contents. By using these

summaries, known as MD5 checksums, RPM can determine whether a particular file is going to be

replaced by a file with the same name but different contents. The following paragraphs give

an example.

</P>

<BR>

<P>



<CENTER>

<TABLE BGCOLOR="#FFFF99">

<TR><TD><B>

NOTE

</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

We'll get more into this aspect of RPM in Chapter 6, &quot;Using RPM to

Verify Installed Packages,&quot; when we discuss rpm

-V.

</BLOCKQUOTE></TD></TR>

</TABLE></CENTER>

</P>

<P>Package A installs a file (we'll call it

/bin/foo.bar). When Package A is installed,

foo.bar resides happily in the /bin directory. In the RPM database, there is an

entry for /bin/foo.bar, including the file's MD5 checksum.

</P>



<P>However, there is another package, B. Package B also has a file called

foo.bar that it wants to install in /bin. There can't be two files in the same directory with the same name. The files

are different; their MD5 checksums do not match. What happens if Package B is installed?

Let's find out. Here, we've installed a package:

</P>



<!-- CODE SNIP //-->

<PRE>

# rpm -iv cdp-0.33-2.i386.rpm

Installing cdp-0.33-2.i386.rpm

#

</PRE>

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



<P>Okay, no problem there. But we have another package to install. In this case, it is a new

release of the cdp package. Note that RPM's detection of file conflicts does not depend on the

two packages being related. It is strictly based on the

name of the file, the directory in which it resides, and the file's MD5 checksum. Here's what happens when we try to install the package:

</P>



<!-- CODE SNIP //-->

<PRE>

# rpm -iv cdp-0.33-3.i386.rpm

Installing cdp-0.33-3.i386.rpm

</PRE>

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





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



<!-- CODE SNIP //-->

<PRE>

/usr/bin/cdp conflicts with file from cdp-0.33-2

error: cdp-0.33-3.i386.rpm cannot be installed

#

</PRE>

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



<P>What's happening? The package cdp-0.33-2 has a file,

/usr/bin/cdp, that it installed. Sure enough, there it is. Let's note the size and creation date of the file for future reference:

</P>



<!-- CODE SNIP //-->

<PRE>

# ls -al /usr/bin/cdp

-rwxr-xr-x 1 root root 34460 Feb 25 14:27 /usr/bin/cdp

#

</PRE>

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



<P>The package we just tried to install,

cdp-0.33-3 (note the different release), also

installs a file cdp in /usr/bin. Since there is a conflict, the two packages'

cdp files must be different&#151;their checksums don't match.

Because of this, RPM won't let the second package install. But <BR>

with--replacefiles, we can force RPM to let /usr/bin/cdp from

cdp-0.33-3 replace /usr/bin/cdp from cdp-0.33-2:

</P>



<!-- CODE SNIP //-->

<PRE>

# rpm -iv --replacefiles cdp-0.33-3.i386.rpm

Installing cdp-0.33-3.i386.rpm

#

</PRE>

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



<P>Taking a closer look at the copy of

/usr/bin/cdp that was just installed, we find that they

certainly are different, both in size and creation date:

</P>



<!-- CODE SNIP //-->

<PRE>

# ls -al /usr/bin/cdp

-rwxr-xr-x 1 root root 34444 Apr 24 22:37 /usr/bin/cdp

#

</PRE>

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



<P>File conflicts should be relatively rare occurrences. They happen only when two packages

attempt to install files with the same name but different contents. There are two possible

reasons for this to happen:

</P>



<UL>

<LI>          Installing a newer version of a package without erasing the older version. A

newer version of a package is a wonderful source of file conflicts against older

versions&#151;the filenames remain the same, but the contents change. We used it in our

example because it's an easy way to show what happens when there are file conflicts.

However, it is usually a bad idea to do this as a way to upgrade packages. RPM has a

special option for this (rpm -U) that is discussed in Chapter 4.

<LI>          Installing two unrelated packages that each install a file with the same name. This

may happen because of poor package design (hence the file's residing in more than

one package) or a lack of coordination between the people building the packages.

</UL>



<B>

2.4.4.1. --replacefiles and Config Files

</B>



<P>What happens if a conflicting file is a config file that you've sweated over and worked on

until it's just right? Will issuing a

--replacefiles on a package with a conflicting config file blow

all your changes away?

</P>



<P><CENTER>

<a href="0021-0023.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0027-0029.html">Next</A>

</CENTER></P>











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

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

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