Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 139226

Summary: patch to add rpm '--last' option to epm-0.9.1
Product: Gentoo Linux Reporter: Timothy Stotts <devel>
Component: [OLD] UnspecifiedAssignee: Aron Griffis (RETIRED) <agriffis>
Status: RESOLVED FIXED    
Severity: enhancement CC: agriffis
Priority: High    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: patch to add '--last' option

Description Timothy Stotts 2006-07-04 12:24:06 UTC
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.
Comment 1 Timothy Stotts 2006-07-04 12:25:38 UTC
Created attachment 90890 [details, diff]
patch to add '--last' option

Please consider inclusion.  This is very useful.
Comment 2 Aron Griffis (RETIRED) gentoo-dev 2006-09-08 12:47:50 UTC
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;
+    }
+
Comment 3 Timothy Stotts 2006-09-08 19:40:03 UTC
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.