Chceking for updates



Here's a small script which checks the versions in the garballs with the
versions on the Gnome FTP site. There are still a ton of kinks to work
out, but it makes it easy to see if something is out-of-date.

Obvious improvements would be to automatically update the garballs and
run makesum and to make it work on other FTP sites.


Cheers,
Jens
#!/usr/bin/perl -w

use strict;
use Net::FTP;
use Sort::Versions;

my $basedir = '/home/jbm/garnome-0.26.1/gnome/';
my %ignore  = ( 'Makefile' => 1, 'category.mk' => 1 );

opendir DIR, $basedir or die "Failed to read $basedir: $!\n";
my @garballs = grep { ! /^\./ } readdir DIR;
closedir DIR or die "Failed to close dir $basedir: $!\n";

my $ftp = Net::FTP->new("ftp.gnome.org", Debug => 0);
$ftp->login("anonymous",'-anonymous@');

print "Name\tGarversion\tFTP version\n";
foreach my $garball (sort @garballs) {
    next if $ignore{$garball};

    chdir $basedir . $garball;

    my $version_line = `grep "GARVERSION =" Makefile`;
    $version_line =~ /^GARVERSION = (.*)/;
    my $version = $1;
    
    next if `grep MASTER_SITES Makefile`;
    my $ftp_version = latest_version($garball);

    my $status = '';
    $status = "NOT OK" if $version ne $ftp_version;
    printf "%-21s %-10s %-10s %7s\n", $garball, $version, $ftp_version, $status;
}

sub latest_version {
    my ($name) = @_;
    
    $ftp->cwd("/pub/GNOME/sources/$name") or return 0;
    my $major_max = (sort { versioncmp($b, $a) } $ftp->ls())[0];

    $ftp->cwd("/pub/GNOME/sources/$name/$major_max") or return 0;
    my @files = $ftp->ls();

    my $max = 0;
    foreach (@files) {
	if (/^LATEST-IS-(.*)/) {
	    $max = $1;
	    last;
	}
    }
    return $max if $max;   # Already found it

    @files = grep { /tar\.(gz|bz)$/ } @files;

    foreach (@files) {
	s/^(.*-)//;
	s/(\.tar.*)$//;
    }
    $max = (sort { versioncmp($b, $a) } @files)[0];
    return $max;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]