rpmdiff
rpmdiff (for comparing rpm versions between machines)
#!/usr/bin/perl
# rpmdiff
# Antonomasia
# The sort is included here - no need to sort rpm output.
#
#1.0 21Apr1998 New
#1.1 21Apr1998 bugfix for packagenames including '-' in name portion
#1.2 21Apr1998 silence over non-differences
#1.3 22Apr1998 non-differences reported at end
# multiple versions of same package catered for
# renamed from multidiff to rpmdiff
#############################################################
# From: "Mark R. Cervarich" (mark serge.shelfspace.com)
#
# I have 4 machines running RedHat 4.2.
#
# I've done a 'rpm -qa | sort > machinename' on each machine to get a
# sorted listing of all of the RPMs installed on each machine. Now, I'd
# like to send the 4 files to some kind of script that will compare them
# and show which are the same and which are different.
#
# I'm hoping a script like this already exists, if not, I plan on
# writing one in PERL then letting everyone know about it. If you have
# something similar to this that I might be able to modify, let me know
# before I re-invent the wheel.
#
# example (i'm using a ';' to act as a newline to save space in the
# email):
#
# machine1: ash-0.2-8; fstool-2.5-1; gpm-1.10-8; lpr-0.30-0
# machine2: bash-1.14.7-1; fstool-2.5-1; lpr-0.30-0
# machine3: ash-0.2-7; fstool-2.5-1; lpr-0.30-0
# machine4: ash-0.2-8; byacc-1.9-4; gpm-1.10-8
#
# ./thecoolscript machine1 machine2 machine3 machine4
#
# then the output would be:
#
# machine1 machine2 machine3 machine4
# ---------------------------------------------------------------
# ash-0.2-8 ash-0.2-7 ash-0.2-8
# bash-1.14.7-1
# byacc-1.9-4
# fstool-2.5-1 fstool-2.5-1 fstool-2.5-1
# gpm-1.10-8 gpm-1.10-8
# lpr-0.30-0 lpr-0.30-0 lpr-0.30-0
#
# also, does anyone have a program/script/perl regex that will separate
# the package number of a package from the package name? That
# would allow me to show different versions of the same package
# on the same line. (like what I did with ash above)
#
# thanks,
# mark
#
# Mark R. Cervarich
@fnames=@ARGV;
while (<>) {
chomp;
$tmp=$_;
s/\..*/$1/;
s/^([.*])-[0-9]+?/$1/;
$pack=$_;
#store package name in package hash
$packs{$pack}=1;
#store package version in machine-specific package hash
$hashname= "msp".$ARGV;
$$hashname{$pack}=$tmp." ".$$hashname{$pack};
}
foreach $rpm (sort keys (%packs) ) {
# new conditional bit in 1.2
$need_to_tell=0;
$old="msp".$fnames[0];
foreach $hash (@fnames) {
$tmp="msp".$hash;
# printf("$tmp $cf $old\n");
if ( ($$tmp{$rpm}) ne ($$old{$rpm}) )
{$need_to_tell=1}
$old=$tmp;
}
if (1==$need_to_tell) {
foreach $hash (@fnames) {
$tmp="msp".$hash;
printf("%s \t%s\n", $hash, $$tmp{$rpm});
}
printf("\n");
} else {
#store package name in list for later
@later=(@later,$$tmp{$rpm});
}
}
# report on the packages that are the same
foreach $rpm (@later) {printf("Same all round \t $rpm\n")}
exit(0);