Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 139226 - patch to add rpm '--last' option to epm-0.9.1
Summary: patch to add rpm '--last' option to epm-0.9.1
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All All
: High enhancement (vote)
Assignee: Aron Griffis (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-04 12:24 UTC by Timothy Stotts
Modified: 2006-09-08 19:40 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch to add '--last' option (epm-0.9.1-last-option.patch,1.22 KB, patch)
2006-07-04 12:25 UTC, Timothy Stotts
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.