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

📄 0041-0043.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="0037-0040.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0044-0044.html">Next</A>

</CENTER></P>



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



<UL>

<LI>          There is a line for each file that RPM would have removed, each one ending with would remove instead of removing.

<LI>          There is only one line at the end, which states

would remove database entry, versus the multiline output showing the cleanup of the RPM database during an actual erase.

</UL>



<P>By using --test in conjunction with -vv, it's easy to see exactly what RPM would do during an actual erase.

</P>



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

3.3.2. --nodeps: Do Not Check Dependencies Before

Erasing Package

</A></H4>



<P>It's likely that one day while erasing a package, you'll see something like this:

</P>



<!-- CODE SNIP //-->

<PRE>

# rpm -e bother

removing these packages would break dependencies:

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

#

</PRE>

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



<P>What happened? The problem is that one or more of the packages installed on your

system require the package you're trying to erase. Without it, they won't work properly. In our

example, the blather package won't work properly unless the

bother package (and more specifically, bother version 3.1 or later) is installed. Since we're trying to erase

bother, RPM aborted the erasure.

</P>



<P>Now, 99 times out of 100, this is exactly the right thing for RPM to do. After all, if the

package is needed by other packages, why try to erase it? As with everything else in life, there are

exceptions to the rule. And that is why there is a

--nodeps option.

</P>



<P>Adding the --nodeps options to an erase command directs RPM to ignore any

dependency-related problems and to erase the package. Going back to our previous example, let's add the

</P>



<P>--nodeps option to the command line and see what happens:

</P>



<!-- CODE SNIP //-->

<PRE>

# rpm -e --nodeps bother

#

</PRE>

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



<P>The package was erased without a peep. Whether the blather package will work properly

is another matter. In general, it's not a good idea to use

--nodeps to get around dependency problems. The package builders included the dependency requirements for a reason, and it's

best not to second-guess them.

</P>



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

3.3.3. --noscripts: Do Not Execute Pre- and Postuninstall Scripts

</A></H4>



<P>In section 3.2.1 we used the -vv option to see what RPM was actually doing when it erased

a package. We noted that there were two scripts, a preuninstall and a postuninstall, that

were used to execute commands required during the process of erasing a

package.

</P>



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





<P>The --noscripts option prevents these scripts from being executed during an erase. This is

a very dangerous thing to do! The --noscripts option is really meant for package builders to

use during the development of their packages. By preventing the pre- and postuninstall scripts

from running, a package builder can keep a buggy package

from bringing down his development system. After the bugs are found and eliminated, there's very little need to prevent these

scripts from running; in fact, doing so can cause problems!

</P>



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

3.3.4. --rcfile &lt;rcfile&gt;: Read

&lt;rcfile&gt; for RPM Defaults

</A></H4>



<P>The --rcfile option is used to specify a file containing default settings for RPM.

Normally, this option is not needed. By default, RPM uses

/etc/rpmrc and a file named .rpmrc located in your login directory.

</P>



<P>This option would be used if there were a need to switch between several sets of RPM

defaults. Software developers and package builders will normally be the only people using the

--rcfile option. For more information on rpmrc files, see Appendix B, &quot;The

rpmrc File.&quot;

</P>



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

3.3.5. --root &lt;path&gt;: Use &lt;path&gt; As the Root

</A></H4>



<P>Adding --root &lt;path&gt; to an erase command forces RPM to assume that the directory

specified by &lt;path&gt; is actually the root directory. The

--root option affects every aspect of the erase

process, so pre- and postuninstall scripts are run with

&lt;path&gt; as their root directory (using

chroot(2), if you must know). In addition, RPM expects its database to reside in the directory

specified by the dbpath rpmrc file entry, relative to

&lt;path&gt;.

</P>



<P>Normally this option is only used during an initial system install, or when a system has

been booted off a rescue disk and some packages need to be re-installed.

</P>



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

3.3.6. --dbpath &lt;path&gt;: Use &lt;path&gt; to Find the RPM Database

</A></H4>



<P>In order for RPM to do its work, it needs access to an RPM database. Normally, this

database exists in the directory specified by the

rpmrc file entry, dbpath. By default, dbpath is set to

/var/lib/rpm.

</P>



<P>Although the dbpath entry can be modified in the appropriate

rpmrc file, the --dbpath option is probably a better choice when the database path needs to be changed

temporarily. An example of a time the --dbpath option would come in handy is when it's necessary to examine

an RPM database copied from another system. Granted, it's not a common occurrence, but

it's difficult to handle any other way.

</P>



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





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

3.4. rpm -e and Config Files

</A></H3>



<P>If you've made changes to a configuration file that was originally installed by RPM, your

changes won't be lost if you erase the package. Say, for example, that we've made changes to

/etc/skel/.bashrc (a config file), which was installed as part of the

etcskel package. Later, we remove etcskel:

</P>



<!-- CODE SNIP //-->

<PRE>

# rpm -e etcskel

#

</PRE>

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



<P>But if we take a look in /etc/skel, here's what we see:

</P>



<!-- CODE //-->

<PRE>

# ls -al

total 5

drwxr-xr-x 3 root root 1024 Jun 17 22:01 .

drwxr-xr-x 8 root root 2048 Jun 17 19:01 ..

-rw-r--r-- 1 root root 152 Jun 17 21:54 .bashrc.rpmsave

drwxr-xr-x 2 root root 1024 May 13 13:18 .xfm

#

</PRE>

<!-- END CODE //-->



<P>Sure enough, .bashrc.rpmsave is a copy of your modified

.bashrc file! Remember, however, that this feature only works with config files. Not sure how to determine which files RPM

thinks are config files? Chapter 5, &quot;Getting Information About Packages,&quot; specifically section

5.2.2, shows you how.

</P>



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

3.5. Watch Out!

</A></H3>



<P>RPM takes most of the work out of removing software from your system, and that's great.

But of course there's a downside. RPM also makes it easy to erase packages that are critical to

your system's continued operation. Here are some examples of packages not to erase:

</P>



<UL>

<LI>          RPM: RPM will happily uninstall itself. No problem, though. You'll just re-install

it with rpm -i&#133;.Oops!

<LI>          Bash: The Bourne-again shell may not be the shell you use, but certain parts of

many Linux systems (such as the scripts executed during system startup and shutdown) use /bin/sh, which is a symbolic link to /bin/bash. No

/bin/bash, no /bin/sh. No

/bin/sh, no system!

</UL>



<P>In many cases, RPM's dependency processing will prevent inadvertent erasures from

causing massive problems. However, if you're not sure, use

rpm -q to get more information about the package you'd like to erase. (See Chapter 5 for more information on

rpm -q.)

</P>



<P><CENTER>

<a href="0037-0040.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0044-0044.html">Next</A>

</CENTER></P>











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

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

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