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

📄 0037-0040.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 Erase 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=03 //-->

<!-- PAGES=0037-0044 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="../ch02/0036-0036.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0041-0043.html">Next</A>

</CENTER></P>



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







<H3><A NAME="ch03_ 1">

Chapter 3

</A></H3>



<H2>



Using RPM to Erase<BR> Packages



</H2>



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





<P>Table 3.1. Erase-mode command syntax and options.

</P>



<TABLE>



<TR><TD>

rpm -e (or --erase)

</TD><TD>

Options

</TD><TD>

pkg1...pkgN

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

</TD><TD>

Parameters

</TD><TD>

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

pkg1...pkgN

</TD><TD>

One or more installed packages

</TD><TD>

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

</TD><TD>

Erase-Specific Options

</TD><TD>

Section

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

--test

</TD><TD>

Perform erase tests only

</TD><TD>

3.3.1

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

--noscripts

</TD><TD>

Do not execute pre- and postuninstall scripts

</TD><TD>

3.3.3

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

--nodeps

</TD><TD>

Do not check dependencies

</TD><TD>

3.3.2

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

</TD><TD>

General Options

</TD><TD>

Section

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

-vv

</TD><TD>

Display debugging information

</TD><TD>

3.2.1

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

--root &lt;path&gt;

</TD><TD>

Set alternate root to

&lt;path&gt;

</TD><TD>

3.3.5

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

--rcfile &lt;rcfile&gt;

</TD><TD>

Set alternate rpmrc file to

&lt;rcfile&gt;

</TD><TD>

3.3.4

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

--dbpath &lt;path&gt;

</TD><TD>

Use &lt;path&gt; to find the RPM database

</TD><TD>

3.3.6

</TD></TR></TABLE>



<H3><A NAME="ch03_ 2">

3.1. rpm -e: What Does It Do?

</A></H3>



<P>The rpm -e command (--erase is equivalent) removes, or erases, one or more packages

from the system. RPM performs a series of steps whenever it erases a package:

</P>



<OL>

<LI>          It checks the RPM database to make sure that no other packages depend on

the package being erased.

<LI>          It executes a preuninstall script (if one exists).

<LI>          It checks whether any of the package's config files have been modified. If so, it

saves copies of them.

<LI>          It reviews the RPM database to find every file listed as being part of the package,

and if a file does not belong to another package, deletes the file.

<LI>          It executes a postuninstall script (if one exists).

<LI>          It removes all traces of the package (and the files belonging to it) from the

RPM database.

</OL>



<P>That's quite a bit of activity for a single command. No wonder RPM can be such a time-saver!

</P>



<H3><A NAME="ch03_ 3">

3.2. Erasing a Package

</A></H3>



<P>The most basic erase command is

</P>

<!-- CODE SNIP //-->

<PRE>

# rpm -e eject

#

</PRE>

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



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



<P>In this case, the eject package was erased. There isn't much in the way of feedback, is

there? Could we get more if we added -v?

</P>



<!-- CODE SNIP //-->

<PRE>

# rpm -ev eject

#

</PRE>

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



<P>Still nothing. However, another option can be counted on to give a wealth of

information. You'll learn about it in the next section.

</P>



<H4><A NAME="ch03_ 4">

3.2.1. Getting More Information with -vv

</A></H4>



<P>By adding -vv to the command line, we can often get a better feel for what's going on

inside RPM. The -vv option was really meant for the RPM developers, and its output may

change, but it is a great way to gain insight into RPM's inner workings. Let's try it with

rpm -e:

</P>



<!-- CODE //-->

<PRE>

# rpm -evv eject

D: uninstalling record number 286040

D: running preuninstall script (if any)

D: removing files test = 0

D: /usr/man/man1/eject.1 - removing

D: /usr/bin/eject - removing

D: running postuninstall script (if any)

D: removing database entry

D: removing name index

D: removing group index

D: removing file index for /usr/bin/eject

D: removing file index for /usr/man/man1/eject.1

#

</PRE>

<!-- END CODE //-->



<P>Although -v had no effect on RPM's output, -vv gave us a torrent of output. But what does

it tell us?

</P>



<P>First, RPM displays the package's record number. The number is normally of use only to

people that work on RPM's database code.

</P>



<P>Next, RPM executes a preuninstall script, if one exists. This script can execute any

commands required to remove the package before any files are actually deleted.

</P>



<P>The files test = 0 line indicates that RPM is to actually erase the package. If the number

had been nonzero, RPM would only be performing a test of the package erasure. This happens

when the --test option is used. Refer to section 3.3.1 for more information on the use of the

--test option with rpm -e.

</P>



<P>The next two lines log the actual removal of the files comprising the package. Packages

with many files can result in a lot of output when using

-vv!

</P>



<P>Next, RPM executes a postuninstall script, if one exists. Like the preuninstall script, this

script is used to perform any processing required to cleanly erase the package.

Unlike the preuninstall script, however, the postuninstall script runs after all the package's files have been removed.

</P>



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





<P>Finally, the last five lines show the process RPM uses to remove every trace of the package

from its database. From the messages, we can see that the database contains some per-package

data, followed by information on every file installed by the package.

</P>



<H3><A NAME="ch03_ 5">

3.3. Additional Options

</A></H3>



<P>If you're interested in a complex command with lots of options,

rpm -e is not the place to look. There just aren't that many different ways to erase a package! But there are a few options

you should know about.

</P>



<H4><A NAME="ch03_ 6">

3.3.1. --test: Go Through the Process of Erasing the Package,

But Do Not Erase It

</A></H4>



<P>If you're a bit gun-shy about erasing a package, you can use the

--test option first to see what rpm -e would do:

</P>

<!-- CODE SNIP //-->

<PRE>

# rpm -e --test bother

removing these packages would break dependencies:

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

#

</PRE>

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



<P>It's pretty easy to see that the blather package wouldn't work very well if

bother were erased. To be fair, however, RPM wouldn't have erased the package in this example unless we used

the --nodeps option, which we'll discuss shortly.

</P>



<P>However, if there are no problems erasing the package, you won't see very much:

</P>

<!-- CODE SNIP //-->

<PRE>

# rpm -e --test eject

#

</PRE>

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



<P>We know, based on previous experience, that -v doesn't give us any additional output with rpm -e. However, we do know that -vv works wonders. Let's see what it has to say:

</P>



<!-- CODE //-->

<PRE>

# rpm -evv --test eject

D: uninstalling record number 286040

D: running preuninstall script (if any)

D: would remove files test = 1

D: /usr/man/man1/eject.1 - would remove

D: /usr/bin/eject - would remove

D: running postuninstall script (if any)

D: would remove database entry

#



</PRE>

<!-- END CODE //-->



<P>As you can see, the output is similar to that of a regular erase command using the -vv option, with the following exceptions:

</P>



<UL>

<LI>          The would remove files test =

1 line ends with a nonzero number. This is because

--test has been added. If the command hadn't included

--test, the number would have been 0, and the package would have been erased.

</UL>



<P><CENTER>

<a href="../ch02/0036-0036.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0041-0043.html">Next</A>

</CENTER></P>











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

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

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