Getting RPM to list packages by install date (tummy.com, ltd. Journal Entry)
tummy.com: we do linux

Wednesday October 31, 2007 at 23:03
Subject: Getting RPM to list packages by install date
Keywords: RPM, Technical
Posted by: Sean Reifschneider

Tonight Scott was having problems with mutt suddenly having a garbled display. One of the things we wanted to do was to display packages by installed date to see what had changed recently. This is always annoying to find because I can never remember how to get the installed time or the list of available tags. Here's how...

First of all, you can get a list of the available tags for use with "--queryformat" with "--querytags":

guin:~$ rpm --querytags | grep -i install
INSTALLTIME
INSTALLCOLOR
INSTALLTID
INSTALLPREFIX
guin:~$

I always want to call it "installdate" instead of "installtime". So:

guin:~$ rpm -qa \
>   --queryformat '%{installtime} (%{installtime:date}) %{name}\n' | \
>   sort -n | tail -5
1193758513 (Tue Oct 30 09:35:13 2007) smolt-firstboot
1193758519 (Tue Oct 30 09:35:19 2007) python-devel
1193758532 (Tue Oct 30 09:35:32 2007) subversion
1193758541 (Tue Oct 30 09:35:41 2007) subversion-perl
1193758545 (Tue Oct 30 09:35:45 2007) tkinter
guin:~$

Note that the "%{installtime:date}" specifies that the installtime should be formatted as a date string. Otherwise, it's the time_t seconds since Jan 1, 1970 (which is great for sorting, but not for reading).
(Post Reply)

Comment
Author: Kevin Fenzi
Subject: similar rpm option too...
Note that rpm has a poorly mentioned and documented option here too...

--last Orders the package listing by install time such that the latest packages are at the top.

ie, 'rpm -qa --last | less'