RPM

(0 comments)

RPM是 RedHat 公司开发的软件包工具,本文重点介绍RPM包的使用和管理方法。

Package Manage

Package Installation

  • Install a package, verbose mode, print progress hash
rpm -ivh packagename-1.0.0-kll.i386.rpm
  • Upgrade a package. Install package if not already installed.
rpm -Uvh packagename-1.0.0-kll.i386.rpm
  • Upgrade a package if it is already installed. Does nothing if package is not installed.
rpm -Fvh packagename-1.0.0-kll.i386.rpm
  • Re-Install an existing package (useful for corrupted packages)
rpm --replacepkgs -ivh packagename-1.0.0-kll.i386.rpm 
  • Resolve dependence aided option
rpm -ivh --aid packagename-1.0.0-kll.i386.rpm

Need install package rpmdb-redhat, xsane and sane-backends to use this option.

  • 重新指定软件包的默认安装位置。假设软件包的默认安装目录是/usr,将默认目录改为/opt/usr,如下所示:
rpm -ivh --prefix=/opt/usr xxx.rpm

有些软件包还会在/etc目录写文件,也可以将文件改到/usr/etc目录,如下所示:

rpm xxx.rpm --relocate=/usr=/opt/usr --relocate=/etc=/usr/etc

Uninstall (erase) a package

rpm -e packagename
rpm -e packagename-version

Package Query

  • Query if a package is installed
rpm -q packagename
  • Print information about an installed package
rpm -qi packagename
  • Print information about an rpm package file.
rpm -qip packagename-1.0.0-kll.i386.rpm
  • Print name of package that owns a file
rpm -qf /path/to/file
  • Print list of files belonging to a package
rpm -ql packagename
  • Print list of files about an rpm package file.
rpm -qlp packagename-1.0.0-i386.rpm
  • Print names of all installed packages
rpm -qa
  • Print name and size of all installed packages
rpm -qa --queryformat "%-20{name} \t %20{size}\n"
  • Print name and summary for the package called bash.
rpm -q --queryformat "%{name} \t %{summary}\n" bash
  • Read the manpages for the full listing.
rpm -V packagename

Report if package contents, time stamps, checksums have changed. Important flags include:

S File Size
M Permissions/Filetype
5 MD5 Sum
U Ownership
T Time stamp
  • verify all packages:
rpm -Va
  • 查询软件包依赖的其他软件包或库文件。
rpm -qR packagename
  • 查询软件包提供那些动态库文件。
rpm -q --provides packagename。

Maintenance

Rebuild the RPM database

rpm --rebuilddb

Source RPM

Building from Source

  • Rebuild a source RPM (RPM 4.0)
rpmbuild --rebuild packagename-1.0.0-kll.src.rpm
  • Rebuild a source RPM (RPM 3.x)
rpm --rebuild packagename-1.0.0-kll.src.rpm
  • Rebuild a package with Athlon optimizations
rpmbuild --rebuild --target=athlon packagename-1.0.0-kll.src.rpm

Target could i686 or ppc and etc.

  • Install RPM sources into ${RPMDIR}
rpm -i packagename-1.0.0-kll.src.rpm
  • Rebuild all packages, including source and binary RPMS, from a spec file
rpmbuild -ba packagename.spec
  • Rebuild a binary RPM from a spec file
rpmbuild -bb packagename.spec

编译源软件包

安装源软件包通常用于研究或修改,相关文件安装到/usr/src/redhat的子目录中。

rpm -Uvh packagename-1.0.0-1.src.rpm

直接用SPEC文件编译出新的源软件包。

rpmbuild -bs /usr/src/redhat/SPECS/packagename.spec

再次从源软件包中编译出RPM包。

rpmbuild --rebuild --target i686 /usr/src/redhat/SRPMS/packagename-1.0.0.src.rpm

RPM DB

RPM download Site

Currently unrated

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required