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

📄 linux-rpm-usage.html

📁 Linus guide, Linus guide, Linus guide,
💻 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 &quot;.rpm&quot;.</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 (&quot;package&quot;), the version (&quot;1.2.3&quot;), thebuild number or patch level by Red Hat (&quot;4&quot;), the architectureit was built to run on, (&quot;i386&quot;), and the &quot;rpm&quot;extension.</P><P>Instead of using just &quot;-i&quot; in the RPM command line to installRPMs, you probably want to use &quot;-ivh&quot; 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 &quot;--force&quot; 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 &quot;--force&quot; 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 &quot;-U&quot; flag of RPM becomes useful. That's a capital &quot;U&quot;, not a lowercase &quot;u&quot;.</P><P>If there's an update to the previous package we had, it would be notedin the filename. So an upgrade to &quot;package-1.2.3-4.i386.rpm&quot;would be something like &quot;package-2.0.3-1.i386.rpm&quot;. 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 &quot;-U&quot; you can use &quot;-Uvh&quot;.</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 &quot;-e&quot; 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 &quot;--force&quot; 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 &quot;--nodeps&quot; 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 &quot;--nodeps&quot; 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&quot;pack&quot; 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 (&quot;pack&quot;).</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 &quot;-q&quot; we've been using so far stands forQuery, and the &quot;i&quot; stands for Information.</P><P>Here's a sample output from a package called &quot;perl&quot;:</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 &copy; 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 + -