0309-0311.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 495 行

HTML
495
字号


<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:Getting Started with Red Hat Linux</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=0672311739 //-->

<!-- TITLE=RED HAT LINUX 2ND EDITION //-->

<!-- AUTHOR=DAVID PITTS ET AL //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS PUBLISHING //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=14 //-->

<!-- PAGES=0299-0318 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0306-0308.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0312-0316.html">Next</A>

</CENTER></P>



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









<P>This indicates two things. I need to upgrade to my kernel 2.0.28, and if I install a newer

version of dosemu, I will also need to install a newer version of

xdosemu. Although it is usually not a good idea to ignore dependency problems, using the

--nodeps option will cause RPM to ignore these errors and install the

package.

</P>









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





Upgrading Packages

</A></H4>









<P>RPM's upgrade mode provides an easy way to upgrade existing software packages to

newer versions. Upgrade mode is similar to install mode:

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -U [options] [packages]

</PRE>

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











<P>options can be any of the install options or any of the general options.

</P>









<P>Here is an example of how to upgrade packages. On my system I am currently running

emacs version 19.31, but I want to upgrade to the newer

emacs version 19.34. To upgrade, I use the following command:

</P>





<!-- CODE SNIP //-->

<PRE>

# rpm -Uvh emacs-19.34-4.i386.rpm

</PRE>

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











<P>The upgrade mode is really a combination of two operations, uninstall and install. First,

RPM uninstalls any older versions of the requested package and then installs the newer version. If

an older version of the package does not exist, RPM will simply install the requested package.

</P>









<P>An additional advantage of upgrade over manual install and uninstall is that upgrade

automatically saves configuration files. For these reasons, some people prefer to use upgrade rather

than install for all package installations.

</P>









<H4><A NAME="ch14_ 14">





Uninstalling Packages

</A></H4>









<P>The uninstall mode of RPM provides for a clean method of removing files belonging to a

software package from many locations.

</P>









<P>Many packages install files in /etc, /usr, and

/lib, so removing a package can be confusing, but with RPM an entire package can be removed as follows:

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -e [options] [package]

</PRE>

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











<P>options is one of the options listed later in this section, and

package is the name of the package to be removed. For example, if I want to remove the package for

dosemu, the command is as follows:

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -e dosemu

</PRE>

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











<P>The name specified here for the package is just the name of the package, not the name of

the file that was used to install the package. If I had asked for

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -e dosemu-0.64.1-1.i386.rpm

</PRE>

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





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













<P>the following error would have been generated:

</P>





<!-- CODE SNIP //-->

<PRE>

package dosemu-0.64.1-1.i386.rpm is not installed

</PRE>

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















<P>Another common error encountered while trying to uninstall packages is a dependency

error. This occurs when a package that is being uninstalled has files required by another package.

For example, when I try to remove dosemu from my system, I get the following error:

</P>





<!-- CODE SNIP //-->

<PRE>

removing these packages would break dependencies:

dosemu = 0.64.1 is needed by xdosemu-0.64.1-1

</PRE>

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













<P>This means that the package xdosemu would not function properly if the package

dosemu were removed. If I still wanted to remove this package, RPM could be given the

--nodeps option to make it ignore dependency errors.

</P>









<P>The other useful option is the --test option, which causes RPM to go through the motions

of removing a package without actually removing anything. Usually there is no output from

an uninstall, so the -vv option is given along with the

--test option to see what would happen during an uninstall. For example,

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -e -vv --test xdosemu

</PRE>

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















<P>produces the following output on my system:

</P>





<!-- CODE //-->

<PRE>

D: counting packages to uninstall

D: opening database in //var/lib/rpm/

D: found 1 packages to uninstall

D: uninstalling record number 1650520

D: running preuninstall script (if any)

D: would remove files test = 1

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

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

D: /usr/bin/xtermdos - would remove

D: /usr/bin/xdos - would remove

D: /usr/X11R6/lib/X11/fonts/misc/vga.pcf - would remove

D: running postuninstall script (if any)

D: script found - running from file /tmp/02695aaa

+ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin

+ export PATH

+ [ -x /usr/X11R6/bin/mkfontdir ]

+ cd /usr/X11R6/lib/X11/fonts/misc

+ /usr/X11R6/bin/mkfontdir

D: would remove database entry

</PRE>

<!-- END CODE //-->













<P>As you can see, the files that would have been removed are clearly indicated in

the output.

</P>









<H4><A NAME="ch14_ 15">





Querying Packages

</A></H4>









<P>The querying mode in RPM allows for determining the various attributes of packages.

The basic syntax for querying packages is

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -q [options] [packages]

</PRE>

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





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













<P>where options is one or more of the query options listed later in this section. The most

basic query is one similar to

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -q kernel

</PRE>

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











<P>On my system, this prints out the following line for the kernel package:

</P>





<!-- CODE SNIP //-->

<PRE>

kernel-2.0.27-5

</PRE>

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











<P>In a manner similar to uninstall, RPM's query mode uses the name of the package, not

the name of the file that the package came in, for queries.

</P>









<P>Now for a few more sample queries. If you wanted to get a list of all the files &quot;owned&quot; by

the kernel package, you can use the -l option:

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -ql kernel

</PRE>

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











<P>This outputs the following list of files on my system:

</P>





<!-- CODE SNIP //-->

<PRE>

/boot/System.map-2.0.27

/boot/module-info

/boot/vmlinuz-2.0.27

</PRE>

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













<P>In addition to getting a list of the files, you can determine their state by using the

-s option:

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -qs kernel

</PRE>

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















<P>This option gives the following information about the state of files in my kernel package:

</P>





<!-- CODE SNIP //-->

<PRE>

normal        /boot/System.map-2.0.27

normal        /boot/module-info

normal        /boot/vmlinuz-2.0.27

</PRE>

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













<P>If any of these files reported a state of

missing, there would probably be problems with the package.

</P>









<P>In addition to the state of the files in a package, the documentation files and the

configuration files can be listed. To list the documentation that comes with the

dosemu package, use the following:

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -qd dosemu

</PRE>

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















<P>This produces the following list:

</P>





<!-- CODE SNIP //-->

<PRE>

/usr/man/man1/dos.1

</PRE>

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















<P>To get the configuration files for the same package, you would use the following query:

</P>





<!-- CODE SNIP //-->

<PRE>

rpm -qc dosemu

</PRE>

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















<P>This results in the following list:

</P>





<!-- CODE SNIP //-->

<PRE>

/etc/dosemu.conf

/var/lib/dosemu/hdimage

</PRE>

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







<P><CENTER>

<a href="0306-0308.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0312-0316.html">Next</A>

</CENTER></P>









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

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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