“queryformat” option can query every piece information of a rpm package, the information tags (macros ) are returned by “rpm –querytags” command
#list top 2 rpm packages sorted by installation time
$rpm -qa | xargs -I{} rpm -q --queryformat "{} %{installtime}\n" {} | sort -rn -k2 | head -2
collectl-3.5.1-1 1317864013git-1.7.4.1-1.el5 1316484590#unfortunately the time returned is unixtime. You can convert it to human readable format by “date –d @timestring” e.g
$date -d @1317864013Thu Oct 6 12:20:13 EST 2011#but there is a shortcut “--last”
$ rpm -qa --last | head -2collectl-3.5.1-1 Thu 06 Oct 2011 12:20:13 PM ESTgit-1.7.4.1-1.el5 Tue 20 Sep 2011 12:09:50 PM EST
"rpm -qa" supports regular expression itself, rather than pipe to grep e.g “rpm -qa | grep perl”
“rpm –qa perl\*” also works. There is no improvement on speed but typing become lesser.
requires and provides
#You can check the package dependency before install the package
$ rpm -qp --requires git-1.7.6-1.el5.rf.i386.rpm..libssl.so.6…#To meet the dependency, you want to check who provides libssl.so.6
$yum whatprovides libssl.so.6openssl-0.9.8e-20.el5.i686 : The OpenSSL toolkitRepo : baseMatched from:Other : libssl.so.6#if openssl has been installed, “rpm -q –whatprovides” can also provide the answer
$rpm -q --whatprovides libssl.so.6openssl-0.9.8e-12.el5_4.6
rpm scriptlets
#query all nopre|nopost|nopreun|nopostun scripts
$rpm -q --scripts xinetdpostinstall scriptlet (using /bin/sh):if [ $1 = 1 ]; then/sbin/chkconfig --add xinetdfipreuninstall scriptlet (using /bin/sh):if [ $1 = 0 ]; then/sbin/service xinetd stop > /dev/null 2>&1/sbin/chkconfig --del xinetdfipostuninstall scriptlet (using /bin/sh):if [ $1 -ge 1 ]; then/sbin/service xinetd condrestart >/dev/null 2>&1Fi#query postinstall script only
$ rpm -q --queryformat "%{POSTIN}" xinetd
if [ $1 = 1 ]; then/sbin/chkconfig --add xinetd#Don’t run the scripts during install/remove
rpm –i –noscripts|nopre|nopost|nopreun|nopostun pkgnamerpm –e –noscripts|nopre|nopost|nopreun|nopostun pkgname
Extract rpm contents without install
Recover corrupted rpm database#use rpm2cpio to extract everything
$mkdir /tmp/epel$ cd /tmp/epel$ rpm2cpio /root/epel-release-5-4.noarch.rpm | cpio -ivd./etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL..#use rpm2cpio to extract particular file
$rpm2cpio /root/epel-release-5-4.noarch.rpm | cpio -ivd ./usr/share/doc/epel-release-5#another way is to use rpm install with alternative root
$ rpm --root /tmp/epel/ -ivh --nodeps /root/epel-release-5-4.noarch.rpm
Build RPM from source file
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.