--- bin/epm-0.9.1 2006-07-04 15:18:32.000000000 -0400 +++ bin/epm 2006-07-04 15:16:54.000000000 -0400 @@ -344,6 +344,29 @@ return @pkgs; } +# Utility function to do --last +sub sort_mtime(@) +{ + my (@pkgs) = @_; + my @npkgs; + my %mtimes; + + for $p (@pkgs) { + my $ldbpath = "$dbpath/$p"; + + # When was this last built/installed? + # Use a unique key (not just mtime) incase two packages have + # identical mtime. + $mtimes{ (stat "$ldbpath/USE")[9] . $p } = $p; + } + + for $k (sort(keys(%mtimes))) { + unshift @npkgs, $mtimes{$k}; + } + + return @npkgs; +} + # Utility function to do -V sub verify($) { @@ -503,6 +526,11 @@ } } + # Sort package order. + if ($opt{'last'}) { + @pkgs = sort_mtime(@pkgs); + } + for my $p (@pkgs) { # Verify package if ($opt{'V'}) { verify($p); next; } @@ -661,6 +689,7 @@ 'c', # list configuration files (implies -l) 'dump', # show all verifiable information for each file # (must be used with -l, -c, or -d) + 'last', # order package listing by most recent install first 'R|requires', # list package dependencies 'scripts', # print the various [un]install scripts 'G|showgroup', # include group name in output