This patch adds a new switch, '--last', which sorts the package order just before printing to STDOUT. The packages are ordered by Build/Install time, newest first. From the rpm-4.2.1 man page: PACKAGE QUERY OPTIONS: --last Orders the package listing by install time such that the latest packages are at the top.
Created attachment 90890 [details, diff] patch to add '--last' option Please consider inclusion. This is very useful.
Thanks, I added this functionality in version 1.31. My implementation is a little different from yours, but should work nearly the same way. It uses integer comparison for the mtimes instead of string comparison to avoid magnitude bugs. + # Sort package order, by reverse mtime + if ($opt{'last'}) { + my %mtimes; + @pkgs = sort { + # When was this last built/installed? + unless (exists $mtimes{$a}) { + $mtimes{$a} = (stat "$dbpath/$a")[9]; + vverb "$a = $mtimes{$a}"; + } + unless (exists $mtimes{$b}) { + $mtimes{$b} = (stat "$dbpath/$b")[9]; + vverb "$b = $mtimes{$b}"; + } + $mtimes{$b} <=> $mtimes{$a} or $a cmp $b; + } @pkgs; + } +
Sounds good, and thanks! I use this feature in conjunction with 'sed' when determining what packages to rebuild for a new toolchain / library, since revdep-rebuild is often insufficient. Example: list all packages emerged prior to gcc 4.1.1 . I should mention that I discovered a bug in my '--last' implementation some time ago, and I do not know if the integer comparison will solve it. If the file whose datestamp is tested (environment.bz2 ?) does not exist, then that package is not listed after sorting with 'epm -qa --last', whereas an 'epm -qa' would still list that package.