RPM原来表示缩写Red Hat Package Manage,现在表示为:RPM Package Manager
RPM表示两个含义:一是.rpm格式的软件,二是package manager本身。
关于rpm的特性:摘自wiki
- RPM packages can be cryptographically verified with GPG and MD5
- Original source archive(s) (e.g. .tar.gz , .tar.bz2 ) are included in SRPMs, making verification easier
- PatchRPMs and DeltaRPMs, the RPM equivalent of a patch file, can incrementally update RPM-installed software
- Automatic build-time dependency evaluation.
软件安装流程图:
Local RPM installation database
Working behind the scenes of the package manager is the RPM database, stored in /var/lib/rpm
. It uses Berkeley DB as its back-end. It consists of a single database (Packages
) containing all of the meta information of the installed rpms. Multiple databases are created for indexing purposes, replicating data to speed up queries. The database is used to keep track of all files that are changed and created when a user (using RPM) installs a package, thus enabling the user (via RPM) to reverse the changes and remove the package later. If the database gets corrupted (which is possible if the RPM client is killed ), the index databases can be recreated with the rpm --rebuilddb
command
RPM里面包含可执行的二进制程序,这个程序和Windows的软件包中的.exe文件类似是可执行的
RPM文件命名的方式:
An RPM is delivered in a single file, normally in the format:
- <name>-<version>-<release>.<architecture>.rpm
-
-
如果是源文件的话含有src
-
-
The RPM contents also include a package label , which contains the following pieces of information:
- the software name
- the software version (the version taken from original "upstream" source of the software)
- the package release (the number of times the package has been rebuilt using the same version of the software). This field is also often used for indicating the specific distribution the package is intended for by appending strings like "mdv" (formerly, "mdk") (Mandriva Linux ), "fc4" (Fedora Core 4), "rhl9" (Red Hat Linux 9), "suse100" (SUSE Linux 10.0) etc.
- the architecture the package was built for (i386, i686, athlon, ppc, etc.)
The package label does not necessarily need to match the name of the file.
RPM软件的安装、删除、更新只有root权限才能使用;对于查询功能任何用户都可以操作;如果普通用户拥有安装目录的权限,也可以进行安装;
通过rpm 命令查询一个rpm 包是否安装了,也是要通过rpm 数据库来完成的;所以我们要经常用下面的两个命令来初始化rpm 数据库;
[root@localhost beinan]# rpm --initdb
[root@localhost beinan]# rpm --rebuilddb
查询一个已经安装的文件属于哪个rpm包:语法 rpm -qf 文件名
[root@localhost beinan]#rpm -vih file.rpm 注:这个是用来安装一个新的rpm 包;
[root@localhost beinan]#rpm -Uvh file.rpm 注:这是用来升级一个rpm 包;
删除一个rpm安装包:rpm -e *** --noscripts --nodeps
[root@localhost RPMS]# updatedb
[root@localhost RPMS]# locate 软件名或文件名通过updatedb,我们可以用 locate 来查询一些软件安装到哪里了
要查询更多的rpm的是否方法可以使用:man rpm 或者rpm --help
带src的rpm包的安装方法:方法一:
1.执行rpm -i your-package.src.rpm
2. cd /usr/src/redhat/SPECS
3. rpmbuild -bp your-package.specs 一个和你的软件包同名的specs文件
4. cd /usr/src/redhat/BUILD/your-package/ 一个和你的软件包同名的目录
5. ./configure 这一步和编译普通的源码软件一样,可以加上参数
6. make
7. make install
方法二:
1.执行rpm -i you-package.src.rpm
2. cd /usr/src/redhat/SPECS
前两步和方法一相同
3. rpmbuild -bb your-package.specs 一个和你的软件包同名的specs文件
这时,在/usr/src/redhat/RPM/i386/ (根据具体包的不同,也可能是i686,noarch等等)
在这个目录下,有一个新的rpm包,这个是编译好的二进制文件。
执行rpm -i new-package.rpm即可安装完成
rpm -qi 软件包名 查看软件包的详细信息
[root@test]# rpm -qi ibm-java-x86_64-sdk-6.0-8.1
Name : ibm-java-x86_64-sdk Relocations: /opt/ibm
Version : 6.0 Vendor: International Business Machines
Release : 8.1 Build Date: Fri 25 Jun 2010 04:32:24 AM EDT
Install Date: Sat 25 Sep 2010 01:41:34 PM EDT Build Host: arena28.hursley.ibm.com
Group : Development/Languages Source RPM: ibm-java-x86_64-sdk-6.0-8.1.src.rpm
Size : 169062799 License: Commercial
Signature : (none)
Packager : International Business Machines
URL : http://www.software.ibm.com
Summary : IBM 64-bit Linux SDK for Java v6
Description :
IBM 64-bit SDK for Linux on AMD64 architecture, Java (TM)
Technology Edition, Version 6
rpm -ql 软件包名 显示软件包中所有文件的列表。
从rpm软件包抽取文件man rpm2cpio:rpm2cpio(8) Red Hat Linux rpm2cpio(8)
NAME
rpm2cpio - Extract cpio archive from RPM Package Manager (RPM) package.
SYNOPSIS
rpm2cpio [filename]
DESCRIPTION
rpm2cpio converts the .rpm file specified as a single argument to a
cpio archive on standard out. If a â-â argument is given, an rpm stream
is read from standard in.
rpm2cpio rpm-1.1-1.i386.rpm
rpm2cpio - < glint-1.0-1.i386.rpm
[root@localhost RPMS]# rpm2cpio gaim-1.3.0-1.fc4.i386.rpm |cpio -div