ATI Update check

This is a improvement of ati-check original written as bash script. I converted it into Perl, to teach my self writing Perl. As a matter of course I will try to improve/fix certain parts of the script to make it more compact.
Feel free to post your ideas to this script at the bottom of the page.

Version Info

  • [Apr. 3rd, 2007] Added first version of the script. Initial version.

Source Code

ati-check

#!/usr/bin/perl -w
# 
 
use strict;
 
use XML::Feed;
use Crypt::SSLeay;
use LWP::Simple qw(get getstore);
 
# ---- BEGIN: Config ----
my $DL_PATH = "/opt/drivers/fglrx";
my $DL_RSS = "http://ati.amd.com/online/rss/atilinuxdriver.rss?OTC-rssfeedlinux";
my $DL_URL = "http://ati.de/support/drivers/linux/linux-radeon.html";
# ---- END: Config ----
 
print "ATI proprietary fglrx driver update.\n";
 
my %local_fgrlx = ( 'major' => 0, 'minor' => 0, 'build' => 0);
my %remote_fglrx = ( 'major' => 0, 'minor' => 0, 'build' => 0);
my $updateAvailable = undef;
 
open(FGLRXINFO, "fglrxinfo |");
#<FGLRXINFO> =~ /OpenGL version string:.*\(([0-9]+)\.([0-9]+)\.([0-9]+)\)$/ig;
while (defined(my $line = <FGLRXINFO>)) {
  ($local_fgrlx{major}, $local_fgrlx{minor}, $local_fgrlx{build}) = (
      $line =~ /OpenGL version string:.*\(([0-9]+)\.([0-9]+)\.([0-9]+)\)$/ig
  );
  if (defined($1) and defined($2) and defined($3)) {
    last;
  }
}
close(FGLRXINFO)
  or die 'Error executing `fglrx\'';
 
print "Checking local version $local_fgrlx{major}.$local_fgrlx{minor}.$local_fgrlx{build} against... ";
$|++;
 
my $feed = XML::Feed->parse(URI->new($DL_RSS))
  or die XML::Feed->errstr;
for my $entry ($feed->entries) {
  ($remote_fglrx{major}, $remote_fglrx{minor}, $remote_fglrx{build}) = (
    $entry->title =~ /^Linux.*Driver\s([0-9]+)\.([0-9]+)\.([0-9]+)\sRelease:\s(?=x86).*/i
  );
  if (defined($1) and defined($2) and defined($3)) {
    last;
  }
}
print "remote version $remote_fglrx{major}.$remote_fglrx{minor}.$remote_fglrx{build}.\n";
 
my $rfile = "ati-driver-installer-$remote_fglrx{major}.$remote_fglrx{minor}.$remote_fglrx{build}-x86.x86_64.run";
 
my $content = get($DL_URL);
$content =~ /(http[ s]):\/\/(.*)$rfile/i;
my $URL = $1."://".$2.$rfile;
 
if ($remote_fglrx{major} > $local_fgrlx{major}) {
  $updateAvailable = 1;
} else {
  if ($remote_fglrx{minor} > $local_fgrlx{minor}) {
    $updateAvailable = 1;
  } else {
    if ($remote_fglrx{build} > $local_fgrlx{build}) {
      $updateAvailable =1;
    }
  }
}
 
if (defined($updateAvailable)) {
  print "Update available.\nDownloading `$rfile\' to $DL_PATH... ",;
  $|++;
  getstore($URL, "$DL_PATH/$rfile");
  print "DONE.\n";
} else {
  print "No update available.\n";
}
 
# vim: sts=2

Discussion

Enter your comment. Wiki syntax is allowed:
If you can't read the letters on the image, download this .wav file to get them read to you.
 
linux/scripts/perl/ati-check.txt · Last modified: 2007/08/08 22:28 (external edit)
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0