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