`
itspace
  • 浏览: 960766 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Linux RPM包简介

阅读更多
安装rpm包十分便捷,省去了很多编译过程,但是很多情况下,我们需要知道rpm包解压之后文件安装路径。
首先看一下rpm包的命名规则,如有一rpm包名字为ncurses4-5.0-5.i386.rpm,
其命名规则为
<name>-<version>-<release>.<arch>.rpm

o  <name> is the name of the program or package.  The <name> is
   usually assigned by the program's author.  In our example, the
   developers decided to name their product "bash" for reasons that
   seemed amusing to them.

o  <version> identifies which edition of the software this RPM
   contains.  The <version> number is assigned by the program's
   author.  Using the <version> number allows one to determine which
   version of the author's sources were used to generate the RPM.

o  <release> provides the edition number of the RPM file itself and
   not the version of the author's source files.  An updated RPM may
   be issued to supply a patched version of the author's original
   software.  The patch need not have come from the original
   developer, so the RPM <release> gets incremented instead of the
   <version>.
  
   Remember: the <version> is controlled by the original author and
   the <release> is controlled by whomever constructed the RPM.

o  <arch> describes the contents of the RPM and tells whether this
   file contains the product source (a ".src.rpm"),
   architecture-independent files (a ".noarch.rpm"), or files which
   may only be installed on a particular host type (a ".sh.rpm" will
   work only on a STRONGHOLD embedded processor).



以下就是一些关于rpm包的一些操作命令。
1、查看rpm包是否安装:
引用
[root@hzmc tmp]# rpm -qa|grep ncurses4
ncurses4-5.0-5

2、卸载rpm包
引用
[root@hzmc tmp]# rpm -e ncurses4-5.0-5

3、安装rpm包
引用
[root@hzmc tmp]# rpm -ivh ncurses4-5.0-5.i386.rpm
Preparing...                ########################################### [100%]
   1:ncurses4               ########################################### [100%]


4、以升级模式安装rpm包
引用
[root@hzmc tmp]# rpm -Uvh /tmp/ncurses4-5.0-5.i386.rpm
Preparing...                ########################################### [100%]
   1:ncurses4               ########################################### [100%]

5、查看rpm包安装路径,注意这里使用的是绝对路径
引用
[root@hzmc tmp]# rpm -qlp ncurses4-5.0-5.i386.rpm
/usr/lib/libform.so.4
/usr/lib/libform.so.4.0
/usr/lib/libmenu.so.4
/usr/lib/libmenu.so.4.0
/usr/lib/libncurses.so.4
/usr/lib/libncurses.so.4.0
/usr/lib/libpanel.so.4
/usr/lib/libpanel.so.4.0
/usr/share/doc/ncurses4-5.0
/usr/share/doc/ncurses4-5.0/ANNOUNCE
/usr/share/doc/ncurses4-5.0/README


以下命令使用的是相对路径
引用
[root@hzmc tmp]# rpm2cpio ncurses4-5.0-5.i386.rpm|cpio -t
./usr/lib/libform.so.4
./usr/lib/libform.so.4.0
./usr/lib/libmenu.so.4
./usr/lib/libmenu.so.4.0
./usr/lib/libncurses.so.4
./usr/lib/libncurses.so.4.0
./usr/lib/libpanel.so.4
./usr/lib/libpanel.so.4.0
./usr/share/doc/ncurses4-5.0
./usr/share/doc/ncurses4-5.0/ANNOUNCE
./usr/share/doc/ncurses4-5.0/README
720 blocks


6、解压rpm包文件至某个文件夹下,这里使用的是相对路径

引用
[root@hzmc tmp]# rpm2cpio ncurses4-5.0-5.i386.rpm | cpio -ivdu
./usr/lib/libform.so.4
./usr/lib/libform.so.4.0
./usr/lib/libmenu.so.4
./usr/lib/libmenu.so.4.0
./usr/lib/libncurses.so.4
./usr/lib/libncurses.so.4.0
./usr/lib/libpanel.so.4
./usr/lib/libpanel.so.4.0
./usr/share/doc/ncurses4-5.0
./usr/share/doc/ncurses4-5.0/ANNOUNCE
./usr/share/doc/ncurses4-5.0/README
720 blocks


当然了,我们也可以解压,单个文件至某一文件夹下
引用
[root@hzmc /]#  rpm2cpio /tmp/ncurses4-5.0-5.i386.rpm | cpio -ivdu ./usr/lib/libform.so.4
./usr/lib/libform.so.4
720 blocks


这里解释一下几个参数
In this case, the options "-i", "-v", and "-d" direct cpio(1) to:

-i  Extract one or more files from an archive.  The filename(s)
    requested must match the "cpio -t" table of contents
    exactly, or a shell-like wildcard pattern.  If the destination
            file already exists, cpio(1) will refuse to overwrite it unless
            the "-u" switch is added to the command.

-d  Create any directories that precede the filename specified
    in the cpio(1) command.  If the directories already exist,
    the "-d" switch could be omitted but does no harm if it is
    always specified.

-v  Display the names of any files processed, along with the
    size of the CPIO archive file, in 512-byte blocks.  Note
    this size is not the size of the RPM package, which cpio(1)
    never sees directly.



附:trouble shooting

If your RPM database is hung or corrupted you can try to repair it with these
commands.  This process is not guaranteed to work.

You must be logged in with superuser privilege (aka
"root") for these steps.  The commands may be copied and pasted
directly into a root terminal window.


1)  Make sure there are no RPM processes left running on your system.
    Use the ps(1) command to identify them.  Use the kill(1) command
    to terminate any "rpm" processes you find; a "kill -9" may be
    necessary.

2)  Delete the lock files that RPM uses:

rm -f /var/lib/rpm/__db*

3)  If you were experiencing a hanging "rpm" command, try it again.
    If it works, you are finished.  If not, perform Step #1 and #2
    again. Then proceed to the next step.

4)  Make a backup of your RPM database:

cd /var/lib
mkdir rpm-backup
rsync -av ./rpm/. ./rpm-backup/.

5)  Rebuild your RPM database:

rpm -vv --rebuilddb > /tmp/rpmrebuilddb.log 2>&1

6)  Retry your failed RPM command.

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics