1 |
#! /usr/local/bin/perl |
2 |
# |
3 |
# Giuseppe Vacanti, January 2000 |
4 |
# |
5 |
# Find latest CCf packages. |
6 |
# |
7 |
# $Id# |
8 |
# |
9 |
use strict; |
10 |
use Env qw(HOME); |
11 |
|
12 |
|
13 |
my $pkgdir="$HOME/deliveries/packages"; |
14 |
|
15 |
my %pkglist = (); |
16 |
|
17 |
chdir($pkgdir) || die; |
18 |
foreach(glob("*.tgz")){ |
19 |
if(/(.*)-(\d+\.\d+)\.tgz/){ |
20 |
if(not exists $pkglist{$1}){ |
21 |
$pkglist{$1} = []; |
22 |
} |
23 |
push @{$pkglist{$1}}, $2; |
24 |
} else { |
25 |
warn("File $_ does not seem to be a CCF package.\n"); |
26 |
} |
27 |
} |
28 |
|
29 |
foreach(keys %pkglist){ |
30 |
my @topv = sort versionally @{$pkglist{$_}}; |
31 |
my $topv = shift @topv; |
32 |
print "$pkgdir/$_-$topv.tgz\n"; |
33 |
} |
34 |
|
35 |
sub versionally |
36 |
{ |
37 |
my ($a1,$a2) = split /\./, $a; |
38 |
my ($b1,$b2) = split /\./, $b; |
39 |
|
40 |
my $biga = $a1 * 1000 + $a2; |
41 |
my $bigb = $b1 * 1000 + $b2; |
42 |
|
43 |
return $bigb <=> $biga; |
44 |
} |