📄 linux-rpm-usage.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><HTML><HEAD><TITLE>Josh's Linux Guide - Using RPM</TITLE> <META NAME="Author" CONTENT="Joshua Go"> <META NAME="Description" CONTENT="Basic RPM usage."> <META NAME="Keywords" CONTENT="RPM, usage, install, rebuild"></HEAD><LINK REL="stylesheet" TYPE="text/css" HREF="default.css"><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#7F007F"><H2><A NAME="0">Using RPM</A></H2><FONT SIZE="-1"><B>Created on June 27, 1998</B></FONT><BR><FONT SIZE="-1"><B>Last updated on December 31, 1999</B></FONT><BR><FONT SIZE="-1"><B>Development stage: Beta</B></FONT><P>RPM is the Red Hat Package Manager, developed by Red HatSoftware. It's a packaging format used in several Linux distributions,such as Red Hat, Mandrake, Caldera OpenLinux, and TurboLinux. The RPMhomepage is at <A HREF="http://www.rpm.org/"TARGET="_top">http://www.rpm.org</A>.</P><P>Since RPM is a package manager, you can install, remove, build,rebuild, and view your packages. In this document I will covereverything except building RPM software packages, which you<I>probably</I> won't need to do right now.</P><H3><A NAME="1">Installing RPM Packages</A></H3><P>Your Linux distribution, if it uses RPM, already installed RPMpackages. You can install additional RPMs from your CD-ROM or downloadthem from an FTP server. RPM packages end in ".rpm".</P><P>The most basic syntax for installing an RPM package is <B>rpm -ipackage-1.2.3-4.i386.rpm</B>. RPM file names usually consist of thepackage name ("package"), the version ("1.2.3"), thebuild number or patch level by Red Hat ("4"), the architectureit was built to run on, ("i386"), and the "rpm"extension.</P><P>Instead of using just "-i" in the RPM command line to installRPMs, you probably want to use "-ivh" so you can see what'sgoing on.</P><H4><A NAME="2">Forcing</A></H4><P>Sometimes you have to force a package to install, because maybe you hadit installed, but some of its files got deleted and you want to have thecomplete package again. Simply add "--force" to your RPM commandline while installing a package. If you don't, you'll probably getcomplaints that the package is already installed.</P><P>If you're forcing a package to install, your command line will thenlook something like <B>rpm -i --force package-1.2.3-4.i386.rpm</B>. Forcing a package to install <I>usually</I> won't hurt anything, but don'tuse the "--force" option all the time.</P><H4><A NAME="3">Upgrading</A></H4><P>Often, new versions of software come out, and new RPM packages arebuilt for them. That's when the "-U" flag of RPM becomes useful. That's a capital "U", not a lowercase "u".</P><P>If there's an update to the previous package we had, it would be notedin the filename. So an upgrade to "package-1.2.3-4.i386.rpm"would be something like "package-2.0.3-1.i386.rpm". To installit, the command line looks like <B>rpm -U package-2.0.3-1.i386.rpm</B>.</P><P>Like installing, you can also see more of what's going on. Instead ofjust "-U" you can use "-Uvh".</P><H4><A NAME="listfiles">Listing Files from a Package</A></H4><P>A lot of the time, it may be hard to figure out what program to runafter installing the RPM package for it. Using <B>rpm -qlpackagename</B> will give you a list of all the files that are part ofthe package. This may be useful also for finding where its defaultconfiguration file is located.</P><P>It may also help to pipe the output through <B>less</B>, if thereare a lot of files in the package. Simply type <B>rpm -ql packagename| less</B>. <B>less</B> is cool, and it is your friend.</P><H3><A NAME="4">Removing RPM Packages</A></H3><P>If you don't want to have a package around anymore, you can remove it. Use the "-e" flag for <B>rpm</B>. Let's say we want to removethe package installed by package-1.2.3-4.i386.rpm. Don't type the entirefilename. Just type something like <B>rpm -e package-1.2.3-4</B>. Even<B>rpm -e package-1.2.3</B> will work, if there aren't more RPM packagesof <B>package-1.2.3</B> lying around, which may have been installed withthe "--force" flag.</P><H4><A NAME="5">Ignoring Dependencies</A></H4><P>Many RPM packages depend on other RPM packages to run. A lot of casesare programs that need libraries to run, or programs that need otherprograms to run. It's generally a bad idea to remove packages withoutpaying attention to what depends on those packages, which RPM warns youabout on default, unless you use the "--nodeps" flag.</P><P>RPM will also complain about dependencies if you try to upgrade a bunchof packages. Upgrading also involves removing the old package, so you canuse the "--nodeps" flag with upgrading as well.</P><H3><A NAME="6">Viewing All Packages</A></H3><P>To get a simple printout of all the packages you have installed throughRPM, use the command <B>rpm -qa</B>. It's as simple as that.</P><H4><A NAME="7">Checking for a Package</A></H4><P>To see what packages you have installed, use their names to find them. For example, if we want to find all RPM packages installed that have"pack" somewhere in their names, we type <B>rpm -qa | greppack</B>.</P><P>What we're doing there is printing out all the packages but sending itto the <B>grep</B> program so that grep can search for the text string wespecified ("pack").</P><H4><A NAME="8">Viewing Package Information</A></H4><P>To find out information about our package, type <B>rpm -qipackage-1.2.3</B>. The "-q" we've been using so far stands forQuery, and the "i" stands for Information.</P><P>Here's a sample output from a package called "perl":</P><PRE>Name : perl Distribution: ManhattanVersion : 5.004 Vendor: Red Hat SoftwareRelease : 6 Build Date: Fri May 812:08:09 1998Install date: Tue Jun 16 10:36:49 1998 Build Host:porky.redhat.comGroup : Utilities/Text Source RPM:perl-5.004-6.src.rpmSize : 11696746Packager : Red Hat Software <bugs@redhat.com>Summary : Practical Extraction and Report LanguageDescription :Perl is an interpreted language optimized for scanning arbitrary textfiles, extracting information from those text files, and printing reportsbased on that information. It's also a good language for many systemmanagement tasks. The language is intended to be practical (easy to use,efficient, complete) rather than beautiful (tiny, elegant, minimal).</PRE><P>As you can see, there's a lot of good, detailed information you canfind by using <B>rpm -qi</B>.</P><H3><A NAME="9">Rebuilding an RPM from a Source RPM</A></H3><P>There are few situations that the typical user will actually<I>need</I> to rebuild RPM packages, but I had to do it when I upgraded myJPEG library. The programs that used the JPEG library wouldn't load JPEGsjust because I had a new version and they were expecting an olderversion.</P><P>I had to take the source RPM packages of those programs and use them torebuild into an RPM package. That way they would expect the correctversion of the JPEG library I had installed. One of those packages was theGIMP. I took the source RPM (gimp-1.0.0-1.src.rpm) and typed <B>rpm--rebuild gimp-1.0.0-1.src.rpm</B>. That recompiled it, re-linked it withthe new JPEG library so it would know what version to expect, and createdthree RPM packages. That's what the .src.rpm files are for: they're sourceRPMs for people who need to rebuild the package for some reason.</P><H3><A NAME="10">Related Pages</A></H3><OL><LI><A HREF="linux-software-install.html">Installing Software Packages</A></LI></OL><HR><P>Questions, comments, and suggestions should be sent to <AHREF="mailto:jgo@local.net">jgo@local.net</A> through e-mail, the <AHREF="guestbook.html">guestbook</A>, or <AHREF="help.html">help.html</A>.</P><HR><P><B><FONT SIZE="-1">Copyright © 1997-1999 <AHREF="mailto:jgo@local.net">Joshua Go (jgo@local.net)</A>. Allrights reserved. Permission to use, distribute, and copy this document ishereby granted. You may modify this document as long as credit to me isgiven.</FONT></B></P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -