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包是否安装:
[quote]# rpm -qa|grep ncurses4
ncurses4-5.0-5[/quote]
2、卸载rpm包
[quote]# rpm -e ncurses4-5.0-5[/quote]
3、安装rpm包
[quote]# rpm -ivh ncurses4-5.0-5.i386.rpm
Preparing... ########################################### [100%]
1:ncurses4 ########################################### [100%][/quote]

4、以升级模式安装rpm包
[quote]# rpm -Uvh /tmp/ncurses4-5.0-5.i386.rpm
Preparing... ########################################### [100%]
1:ncurses4 ########################################### [100%][/quote]
5、查看rpm包安装路径,注意这里使用的是绝对路径
[quote]# 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[/quote]

以下命令使用的是相对路径
[quote]# 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[/quote]

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

[quote]# 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[/quote]

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

这里解释一下几个参数
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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值