#!/usr/bin/perl
# Must run on a machine with madison.
use URI::Escape;
my $html=0;
if ($ARGV[0] eq 'html') {
shift;
$html=1;
}
if (! @ARGV) {
die "usage: $0 [html] list\n";
}
my %data;
my $unprop = my $unfixed = my $todos = 0;
sub record {
my ($package, $condition, $item)=@_;
if ($html) {
$condition=~s{bug #(\d+)}{bug #$1}g;
$condition=~s{unfixed}{unfixed}g;
$item=~s#((?:CAN|CVE)-\d+-\d+)#$1#g;
}
push @{$data{$package}{$condition}}, $item;
}
foreach my $list (@ARGV) {
if (-d $list) {
$list="$list/list";
}
open (IN, $list) || die "open $list: $!";
while () {
chomp;
if (/^\[/) {
($id)=m/((?:DSA|CAN|CVE)-[^\s]+) /;
}
elsif (/^((?:DSA|CAN|CVE)-[^\s]+)/) {
$id=$1;
}
elsif (/^\s+[!-]\s+(.*?)\s+(.*)$/) {
my $package=$1;
my $version=$2;
my $maddy=`madison -s testing '$package'`;
if (! length $maddy) {
next;
}
if ($version=~/unfixed/) {
record($package, $version, $id);
$unfixed++;
}
else {
my @fields = split(/\s*\|\s*/, $maddy);
my $havver=$fields[1];
my $cmp=system("dpkg --compare-versions '$havver' '>=' '$version'");
if ($cmp != 0) {
if ($html) {
$havver=''.$havver.'';
}
record($package, "$version needed, have $havver", $id);
$unprop++;
}
}
}
elsif (/\s+TODO/) {
$todos++;
}
}
}
if ($html) {
print "testing security issues\n";
print "\n";
}
foreach my $package (sort keys %data) {
foreach my $condition (sort keys %{$data{$package}}) {
print "- " if $html;
print "$package $condition for ";
my $items=0;
foreach my $item (sort @{$data{$package}{$condition}}) {
print ", " if $items > 0;
print $item;
$items++;
}
print "\n";
}
}
if ($html) {
print "
\n";
print "
\n";
print "Total holes unfixed: $unfixed
\n";
print "Total holes fixed in unstable but not testing: $unprop
\n";
print "Number of TODO lines in records: $todos
\n";
print "Last update: ".`date`."
\n";
print "\n";
}