#!/usr/bin/perl
#---------------------------------------------------------------
# Project         : Mandrake
# Module          : rpm-rebuilder
# File            : doble
# Version         : $Id: doble,v 1.5 2000/10/01 19:26:16 flepied Exp $
# Author          : Pascal Rigaud
# Created On      : Thu May 25 15:08:52 2000
#---------------------------------------------------------------
while ($ARGV[0] =~ /^-/) {
    $_ = shift;
    $glob = shift if (m/^-(g|-glob)/);
}

my @list = $glob ? glob($glob) : @ARGV;

foreach (@list) {
    next unless /\.rpm(\.log)?$/;
    ($name,$ext) = m|([^/]+)-[^-]+-[^-]+\.([^.]+)\.rpm(\.log)?$|;
    $name="$name.$ext";
    if ($name eq $last) {
        if ((stat($_))[9] < (stat($lastfile))[9]) { print "$_ "; next; }
        if ((stat($_))[9] > (stat($lastfile))[9]) { print "$lastfile "; }
        if ((stat($_))[9] == (stat($lastfile))[9]) { die "__ THIS SHOULDN't HAPPEN __ (2 different rpms with same date) $_\n" }
    } 
    $last = $name;
    $lastfile = $_;
}
print "\n";

# doble ends here
