File:  [LON-CAPA] / loncom / build / rpmparse.pl
Revision 1.10: download - view: text, annotated - select for diffs
Thu Nov 8 00:17:09 2001 UTC (23 years, 1 month ago) by harris41
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_X, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_12_X, version_2_11_X, version_2_11_5_msu, version_2_11_5, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, version_1_99_1_tmcc, version_1_99_1, version_1_99_0_tmcc, version_1_99_0, version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_X, version_1_2_99_1, version_1_2_99_0, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, version_0_99_3, version_0_99_2, version_0_99_1, version_0_99_0, version_0_6_2, version_0_6, version_0_5_1, version_0_5, version_0_4, stable_2002_spring, stable_2002_july, stable_2002_april, stable_2001_fall, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, conference_2003, bz6209-base, bz6209, bz5969, bz5610, bz2851, STABLE, PRINT_INCOMPLETE_base, PRINT_INCOMPLETE, HEAD, GCI_3, GCI_2, GCI_1, Before_rewrite, BZ5971-printing-apage, BZ5434-fox, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
improving rpm output and comparison

#!/usr/bin/perl

my ($standard,$current,$expected)=@ARGV;

$standard=~s/[^\/\w\.]//g; # cd_rpms.txt
$current=~s/[^\/\w\.]//g; # rpm -qa --queryformat \
                          # '%{NAME}\t%{VERSION}\t%{RELEASE}\t%{BUILDTIME}'
$expected=~s/[^\/\w\.]//g; # rpm_list.txt
my %svhash;
my %sbhash;
my %chash;

my @oldrpms;
my @badversionrpms;
my @newrpms;
my @externalrpms;
my @barerpms;
my @developrpms;

my %ignore=(
	    'LON-CAPA-setup' => 1,
	    'LON-CAPA-base' => 1,
	    );

open IN, "<$standard";
while(<IN>) {
    chop;
    my ($name,$version,$release,$buildtime,$arch)=split(/\s+/);
    next if $ignore{$name};
    $download='<a href="'.
	'http://install.lon-capa.org/3.1/latestRPMS/'.$name.'-'.
	$version.'-'.$release.'.'.$arch.'.rpm'.'">[download]</a>';
    $version="$version-$release";
    $svhash{$name}=$version;
    $sbhash{$name}=$buildtime;
    $dhash{$name}=$download;
}
close IN;

open IN, "<$current";
while(<IN>) {
    chop;
    my ($name,$version,$release,$buildtime)=split(/\s+/);
    next if $ignore{$name};
    $version="$version-$release";
    $chash{$name}=1;
    if ($svhash{$name}) {
	unless ($svhash{$name} eq $version) {
	    push @badversionrpms,sprintf("$dhash{$name} %-25s %s",($name,"is version $version, should be $svhash{$name}"))."\n";
	}
	if ($sbhash{$name}<$buildtime) {
	    push @newrpms,sprintf("$dhash{$name} %-25s %s",($name,"was built ".localtime($buildtime)." when the expected build time was ".localtime($sbhash{$name})))."\n";
	}
	if ($sbhash{$name}>$buildtime) {
	    push @oldrpms,sprintf("$dhash{$name} %-25s %s",($name,"was built ".localtime($buildtime)." when the expected build time was ".localtime($sbhash{$name})))."\n";
	}
    }
    else {
	push @externalrpms,sprintf("$dhash{$name} %-25s %s",($name,"(built ".localtime($buildtime).") is an RPM not expected to ever be on a LON-CAPA system"))."\n";
    }
}
close IN;

open IN,"<$expected";
while(<IN>) {
    chop;
    next unless /^[YN] \w/;
    /(.).(.*)/;
    my $type=$1;
    my $package=$2;
    $package=~s/\-[^\-]*\-[^\-]*$//;
    next if $ignore{$package};
    if (!$chash{$package}) {
	push @barerpms,sprintf("$dhash{$package} %-25s %s",($package,"is missing and is of basic necessity to a LON-CAPA system"))."\n" if $type eq 'Y';
	push @developrpms,sprintf("$dhash{$package} %-25s %s",($package,"is missing and may be useful for a LON-CAPA system"))."\n" if $type eq 'N';
    }
}
close IN;

my $date=`date`; chop $date;
my $hostname=`hostname`; chop $hostname;
print <<END;
<html>
<head>
<title>LON-CAPA Software RPM Status Page</title>
</head>
<body>
<font size="+2">LON-CAPA Software RPM Status Page
(done on $date for $hostname)</font>
<br />Michigan State University
<br />Learning Online with CAPA
<br />Contact korte\@lon-capa.org
<ul>
<li>Important warnings</li>
<li>About this file</li>
<li>Bad RPM Versions</li>
<li>Out-of-date RPMS</li>
<li>Newer than expected RPMS</li>
<li>RPMS external to LON-CAPA</li>
<li>RPMS from the "bare minimum" set that you are missing</li>
<li>RPMS from the "development" set that you are missing</li>
</ul>
<font size="+2">Important warnings</font>
<p>
<b>Never install LON-CAPA-setup</b> on a running LON-CAPA machine.
This RPM package contains pre-installation files such as 
/etc/group and /etc/passwd.  You will lose all access to your
machine if you install this RPM.
</p>
<p>
If you are doing CVS-based upgrades of your LON-CAPA
software, then you do not need to upgrade your LON-CAPA-base
RPM.  Upgrading with the LON-CAPA-base RPM
will cause you to lose many of your system-specific
configuration settings.
</p>
<p>
DO NOT UPGRADE YOUR KERNEL UNLESS YOU KNOW WHAT YOU ARE DOING.
Kernel upgrading involves packages beginning with the word
"kernel".
</p>
<font size="+2">About this file</font>
<p>
This file is generated dynamically by <tt>make rpmstatuspost</tt>
when this command is entered in the CVS:loncom/build directory.
</p>
<p>
Managing software packages on any system, testing different
sets of software packages, tracking their dependencies, and maintaining
configuration information is an inexact science.  While the LON-CAPA
recommended set of RPMs is a tested set with no missing dependencies,
we still highly recommend that RPM upgrades are only performed
by those with significant knowledge about standard Linux operating
systems.
</p>
END
    print <<END;
<font size="+2">Differing RPM Versions</font>
<pre>
END
foreach my $rpminfo (@badversionrpms) {
    print $rpminfo;
}
print <<END;
</pre>
END
print <<END;
<font size="+2">Out-of-date RPMS</font>
<pre>
END
foreach my $rpminfo (@oldrpms) {
    print $rpminfo;
}
print <<END;
</pre>
END
print <<END;
<font size="+2">Newer than expected RPMS</font>
<pre>
END
foreach my $rpminfo (@newrpms) {
    print $rpminfo;
}
print <<END;
</pre>
END
print <<END;
<font size="+2">RPMS external to LON-CAPA</font>
<pre>
END
foreach my $rpminfo (@externalrpms) {
    print $rpminfo;
}
print <<END;
</pre>
END
print <<END;
<font size="+2">RPMS from the "bare minimum" set that you are missing</font>
<pre>
END
foreach my $rpminfo (@barerpms) {
    print $rpminfo;
}
print <<END;
</pre>
END
print <<END;
<font size="+2">RPMS from the "development" set that you are missing</font>
<pre>
END
foreach my $rpminfo (@developrpms) {
    print $rpminfo;
}
print <<END;
</pre>
END

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>