hmmm, works pretty well now...
This commit is contained in:
parent
f0e8507f56
commit
1721556370
1 changed files with 79 additions and 27 deletions
|
|
@ -13,35 +13,22 @@ my @RPMPATHS=(
|
|||
"/home/ward/REDHAT73/ftp.nluug.nl/pub/os/Linux/distr/RedHat/ftp/pub/redhat/linux/updates/7.3/en/os/i386",
|
||||
"/home/ward/REDHAT73/ftp.nluug.nl/pub/os/Linux/distr/RedHat/ftp/pub/redhat/linux/updates/7.3/en/os/i686",
|
||||
"/home/ward/REDHAT73/ftp.nluug.nl/pub/os/Linux/distr/RedHat/ftp/pub/redhat/linux/updates/7.3/en/os/noarch",
|
||||
"/home/ward/REDHAT73/homemade",
|
||||
);
|
||||
|
||||
my $SSH="/usr/bin/ssh";
|
||||
|
||||
my %instrpms = ();
|
||||
my %refrpms = ();
|
||||
my %option = ();
|
||||
getopts("f:ho:pqs:", \%option);
|
||||
|
||||
if ( $option{h} ) { &help; }
|
||||
if ( $option{f} && ( ! $option{p} ) && ( ! $option{s} ) ) {
|
||||
my %refrpms = &fileread($option{f});
|
||||
} elsif ( $option{p} && ( ! $option{f} ) && ( ! $option{s} ) ) {
|
||||
my %refrpms = &pathread;
|
||||
if ( $option{o} ) {
|
||||
open(FH, ">$option{o}") or die "Couldn't open $option{o}: $!";
|
||||
print FH Dumper(\%refrpms);
|
||||
close(FH);
|
||||
}
|
||||
} elsif ( $option{s} && ( ! $option{f} ) && ( ! $option{p} ) ) {
|
||||
&serverread($option{s});
|
||||
} else {
|
||||
&help;
|
||||
}
|
||||
&cmdline;
|
||||
|
||||
# Met pathread en RPM-Perlonly-1.0.1 moet het mogelijk zijn te bepalen
|
||||
# welke RPM de nieuwste is. Hierna is het (denk ik) relatief eenvoudig
|
||||
# te bepalen op welke systemen er dus packages geupdate moeten worden...
|
||||
|
||||
sub pathread {
|
||||
my %allrpms = ();
|
||||
my %entry = ();
|
||||
my ( $line, $prefix );
|
||||
foreach $prefix ( @RPMPATHS ) {
|
||||
|
|
@ -61,7 +48,7 @@ sub pathread {
|
|||
$rpm{'EPOCH'} = 0;
|
||||
}
|
||||
#print " ARCH: $rpm{'ARCH'}\n";
|
||||
push @{$allrpms{$rpm{'NAME'}}}, ( {
|
||||
push @{$refrpms{$rpm{'NAME'}}}, ( {
|
||||
'NAME', $rpm{'NAME'},
|
||||
'BUILDTIME', $rpm{'BUILDTIME'},
|
||||
'VERSION', $rpm{'VERSION'},
|
||||
|
|
@ -76,8 +63,6 @@ sub pathread {
|
|||
}
|
||||
closedir DH;
|
||||
}
|
||||
|
||||
return %allrpms;
|
||||
}
|
||||
|
||||
sub fileread($) {
|
||||
|
|
@ -87,16 +72,50 @@ sub fileread($) {
|
|||
my $data = do { local $/; <FH>; };
|
||||
close FH;
|
||||
eval $data;
|
||||
my %allrpms = %{$VAR1};
|
||||
&outputnewest(%allrpms);
|
||||
return %allrpms;
|
||||
%refrpms = %{$VAR1};
|
||||
&outputnewest(%refrpms);
|
||||
}
|
||||
|
||||
sub serverread($) {
|
||||
my $server = shift;
|
||||
# open .... or die "Couldn't execute ....: $!";
|
||||
|
||||
# close ....;
|
||||
my $name;
|
||||
if ( $option{l} ) {
|
||||
open CH, "rpm -qa|" or die "Can't fork: $!";
|
||||
} else {
|
||||
open CH, "ssh -x $server rpm -qa|" or die "Can't fork: $!";
|
||||
}
|
||||
while ( <CH> ) {
|
||||
chomp;
|
||||
$name = $_;
|
||||
$name =~ s/(.*?)-([^-]*)-([^-]*)$/$1/;
|
||||
unless ( $option{q} ) {
|
||||
print "$_\n";
|
||||
print "$name\n";
|
||||
}
|
||||
push @{$instrpms{$name}}, $_;
|
||||
}
|
||||
close CH;
|
||||
}
|
||||
|
||||
sub comparerpms() {
|
||||
my ( $correct, $installed );
|
||||
foreach ( sort keys %instrpms ) {
|
||||
if ( exists $refrpms{$_} ) {
|
||||
$correct = @{$refrpms{$_}}[0]->{'FILENAME'};
|
||||
$correct =~ s/\.(i[36]86|noarch)(\.rpm)?$//;
|
||||
foreach $installed ( @{$instrpms{$_}} ) {
|
||||
unless ( $correct eq $installed ) {
|
||||
print "\ncorrect: $correct\n";
|
||||
print "installed: $installed\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print "\n$_ doesn't exist in reference tree\n";
|
||||
foreach my $rpm ( @{ $instrpms{$_} } ) {
|
||||
print " $rpm\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub outputnewest(@) {
|
||||
|
|
@ -147,6 +166,39 @@ sub splitname($$) {
|
|||
}
|
||||
}
|
||||
|
||||
sub cmdline {
|
||||
getopts("f:hlo:pqs:", \%option);
|
||||
|
||||
if ( $option{h} ) { &help; }
|
||||
unless ( $option{f} || $option{l} || $option{p} || $option{s} ) { &help; }
|
||||
|
||||
if (
|
||||
( $option{f} && ( $option{p} || $option{o} ) ) ||
|
||||
( $option{l} && $option{s} )
|
||||
) {
|
||||
&help;
|
||||
}
|
||||
|
||||
if ( $option{f} ) {
|
||||
&fileread($option{f});
|
||||
} elsif ( $option{p} ) {
|
||||
&pathread;
|
||||
if ( $option{o} ) {
|
||||
open(FH, ">$option{o}") or die "Couldn't open $option{o}: $!";
|
||||
print FH Dumper(\%refrpms);
|
||||
close(FH);
|
||||
}
|
||||
}
|
||||
if ( $option{l} ) {
|
||||
&serverread("localhost");
|
||||
} elsif ( $option{s} ) {
|
||||
&serverread($option{s});
|
||||
}
|
||||
if ( ( $option{f} || $option{p} ) && ( $option{l} || $option{s} ) ) {
|
||||
&comparerpms;
|
||||
}
|
||||
}
|
||||
|
||||
sub help() {
|
||||
print << "EOT";
|
||||
|
||||
|
|
@ -154,7 +206,7 @@ sub help() {
|
|||
|
||||
-f <file> Read reference rpms from file
|
||||
-h Display this help
|
||||
-l Read installed rpms from localhost
|
||||
-l Read installed rpms from localhost, overrides -s
|
||||
-o <file> Write reference rpms to file, only useful in combination with -p
|
||||
-p Read rpms from build in mirror paths
|
||||
-q Quiet down a bit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue