[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Check package versions in RedHat
Hi!
I just started learning perl (it's about time), and here's my first
creation. If you have RedHat 4.1 (or 4.0) and you want to upgrade to 4.2
just by downloading the packages by FTP, you want to know which packages
from the RPMS directory have new versions. Save the output of the "dir"
command in the FTP site to a file and feed the file to this script, it
will tell you. This of course can be used for contrib packages as well,
and for anything else you can think of.
I guess that many things here can be done in half the time it takes now,
and I'll be happy to hear. It takes the script quite some time to finish.
#!/usr/bin/perl
#
# ulist, by Alex Shnitman <alexsh@linux.org.il>
#
# Given a file containing the output of the "dir" command in the RPMS
# directory of your favorite RedHat FTP mirror site, the script checks
# which packages that you have installed have been released in a new
# version.
#
# Usage:
# ulist filename
#
# Of course:
#include <disclaimer.h>
# Modifications to this script are welcome as long as you send me a copy.
#
$FILE=$ARGV[0];
open FILE or die "Usage: ulist filename\n";
while(<FILE>)
{
($j,$j,$j,$j,$size,$j,$j,$j,$file) = split;
@parts = split(/\-/,$file);
$name = join('-',@parts[0..$#parts-2]);
$majver = $parts[$#parts-1];
@parts1 = split(/\./,$parts[$#parts]);
$minver = join('.',@parts1[0..$#parts1-2]);
$f[$n++] = "$name $majver $minver $size";
}
close FILE;
$FILE="/bin/rpm -qa|";
open FILE;
printf("Name Old version New version Size\n");
printf("------------------------------------------------------------------\n");
while(<FILE>)
{
s/\n//;
@parts = split(/\-/);
$name = join('-',@parts[0..$#parts-2]);
$majver = $parts[$#parts-1];
$minver = $parts[$#parts];
foreach $line (@f)
{
@parts = split(/\ /, $line);
if($name eq $parts[0] &&
($parts[1] gt $majver ||
($parts[1] eq $majver && $parts[2] gt $minver)))
{
$ver1 = sprintf("%s-%s", $majver, $minver);
$ver2 = sprintf("%s-%s", @parts[1..2]);
printf("%-25s%-15s%-15s%s\n",
$name, $ver1, $ver2, $parts[3]);
$tpack++;
$tsize += $parts[3];
}
}
}
close FILE;
printf("------------------------------------------------------------------\n");
printf("Total packages: $tpack Total size: $tsize\n");
---------------------------------------------------------------------
Alex Shnitman <alexsh@linux.org.il> // http://alexs.home.ml.org
---------------------------------------------------------------------