1 |
ccflib |
1.4 |
#! /xdata/ccflib/perl5/perlbrew/perls/perl-5.18.4/bin/perl -w |
2 |
|
|
# |
3 |
|
|
# This is required to moake it work with SAS 15 |
4 |
ccflib |
1.1 |
# |
5 |
|
|
# Find latest CCf packages. |
6 |
ccflib |
1.2 |
# |
7 |
ccflib |
1.4 |
# $Id: findlatest,v 1.3 2014/12/02 14:57:08 ccflib Exp $ |
8 |
ccflib |
1.1 |
# |
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 |
|
|
} |