From d055bbb75daddec96238f568e436d0c336dfa76f Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Mon, 21 May 2012 16:58:28 +0200 Subject: [PATCH] List date when package first seen to need upgrade Keeps a file in current dir with lines like bagel:xpdf 2012-05-01 to indicate that package was first seen to need upgrade on that date. When new versions arrive, the date stays the same. When the package gets updated, the noticeis removed from the file (and nothing is shown for it on the page). When a new version becomes available, notices the date again. Displays a plain '*' for packages that were pending from before we started tracking (which is today) --- aptcheck/aptcheck.pl | 53 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/aptcheck/aptcheck.pl b/aptcheck/aptcheck.pl index 2b769f2..3866de9 100755 --- a/aptcheck/aptcheck.pl +++ b/aptcheck/aptcheck.pl @@ -91,8 +91,8 @@ for my $pline ( split("\n",$restplines) ) { } } +print "got " . scalar(keys(%restrpkgs)) . " restricted packages\n" if $debug; if ( $debug >1 ) { - print "got " . scalar(keys(%restrpkgs)) . " restricted packages\n"; for $pname ( sort (keys(%restrpkgs)) ) { print " $pname " . $restrpkgs{$pname} . "\n"; } @@ -113,6 +113,30 @@ my $mantot = 0; my $normtot = 0; my %updlinks; +# Pending modification dates +my %olddates; # Read in from the file +my %newdates; # To be written in the new version of the file +my $datefilename = "aptcheck.data"; +my $dateoldfilename = "aptcheck.old"; +my $thisdate = "*"; # indicates really old stuff +if ( -f $datefilename ) { + print "Reading dates from $datefilename\n" if $debug; + open F, $datefilename or die "Could not open date file $datefilename: $!"; + while () { + chop(); + my ($pkg, $date) = split; + next unless $pkg; # skip empty lines + $olddates{$pkg} = $date; + print "Date for '$pkg' is '$date' \n" if $debug; + } + close F; + $thisdate = `date +%F`; + chomp($thisdate); +} else { + print "No datefile $datefilename found, starting from scratch\n"; +} + + my $table = "\n"; for my $hline ( split("\n",$hostlist) ) { @@ -165,6 +189,13 @@ for my $hline ( split("\n",$hostlist) ) { $det .= ""; $det .= ""; $det .= ""; + my $datekey = "$H:$restrname"; + if ( $olddates{$datekey} ) { + $newdates{$datekey} = $olddates{$datekey}; + } else { + $newdates{$datekey} = $thisdate; + } + $det .= ""; $det .= "\n"; my $key = "$restrname"; if ( !$summary{$key} ) { @@ -211,7 +242,15 @@ for my $hline ( split("\n",$hostlist) ) { $det .= " "; $det .= " "; $det .= " "; + my $datekey = "$H:$pkg"; + if ( $olddates{$datekey} ) { + $newdates{$datekey} = $olddates{$datekey}; + } else { + $newdates{$datekey} = $thisdate; + } + $det .= ""; $det .= "\n"; + } $table .= "\n"; $table .= "
  $restrname (M)". strdiff($bver,$restrinst)."". strdiff($restrinst,$bver)."" . $newdates{$datekey} . "
$cur$new" . $newdates{$datekey} . "
 
$H  \n"; @@ -240,6 +279,16 @@ for my $hline ( split("\n",$hostlist) ) { } $table .= "
\n"; +# Save the date file +`mv -f $datefilename $dateoldfilename`; +open F, ">$datefilename" or die "Could not open date file $datefilename for writing"; +for my $k (keys(%newdates) ) { + print F "$k " . $newdates{$k}. "\n"; + print "date for '$k' '" . $newdates{$k}. "'\n" if $debug; +} +close F + or die "Could not close date file $datefilename: $!"; + # Page header my $outfile = "/tmp/aptcheck.html"; open F, ">$outfile" @@ -392,6 +441,8 @@ for my $P ( sort(keys(%summary)) ) { } print F "\n"; +print F "

Packages marked with * are from the time before started to " . + "track package dates \n"; print F "

Produced " . `date`. " on " . `hostname` . " by " . `whoami` . "
\n"; -- 1.7.10.4