Neil Bothwick <[EMAIL PROTECTED]> writes:

> On Thu, 22 Dec 2005 15:37:35 -0600, [EMAIL PROTECTED] wrote:
>
>> > genlop is really nice, I use it all the time, but I don't think it
>> > has an option to find all packages installed after a particular
>> > package. It would be a nice variation on the --date option.
>> 
>> Isn't the output in chrono order?
>
> Yes, but then you'd have to do some funky regexp stuff to find the last
> line showing gcc (in this case) and only show the lines after it. It was
> a lot easier to do this with find -newer.

Here is a pooryly coded sloppy perl script I just wrote.
Rather than get to tricky with date regex it relies on genlop output
being in chrono order. If it ever isn't I'm sunk.

It might be something you'd like, although it doesn't do any error
checking or testing etc and I've only done very limited testing:

This script expects to be run in a pipe with genlop -v --list
  (Example: genlop -v --list|RevChron.pl "/gcc-3.6")

 -------- 8< snip -----------

#!/usr/local/bin/perl -w
# Keywords: RevChron.pl - designed to manipulate genlop -v --list output,
# finding packages installed since some specific package.
# Dec 22 18:18:06 2005 4
# &&

use diagnostics;

my ($PreReg,$Regex,$OurLine,@Out,@RevOut,@RevChron,@Chron);

my $myscript;
($myscript = $0) =~ s:^.*/::;

## print usage if no cmdline arg is given or "help" is given
if(!$ARGV[0] || $ARGV[0] eq "help"){
   usage();
      exit;
}

## Compile our regex
$PreReg = shift;
$Regex = qr/$PreReg/;

## parse genlop --list output keeping a variable each
## time a line machtches our Regex (Last match will be ours)
while(<>){
  chomp;
  if(/$Regex/){
    $OurLine = $_;
  }
  push @Out, $_;
}
if(!$OurLine){ 
  print "

         No hits on your regex <$PreReg> were found ... exiting

";
  exit;
}
## Reverse the output and grab lines until we find OurLine
@RevOut = reverse @Out;
for(@RevOut){
  if($OurLine eq $_ ){
    ## grab it too
    push @RevChron,$_;
    last;
  }
  push @RevChron,$_;
}

## Reverse whats left again so its in chrono order
@Chron = reverse @RevChron;

## Print the captured lines we need.
for(@Chron){
   print "$_\n";;
}

sub usage {
  print "
  Purpose: Show packages after specific package in genlop output

  Usage:  \`genlop -v --list|$myscript REGEX '
 
          Where REGEX is a good/unique identifier for a specific package.
  Example:  \`genlop -v --list|$myscript  /gcc-3.6'
  (type \`$myscript help' for usage) 
";
};

-- 
gentoo-user@gentoo.org mailing list

Reply via email to