#! /usr/bin/perl -w
use diagnostics;
use strict;

local (*AVAILABLE, *STATUS);
open AVAILABLE, '</var/lib/dpkg/available' or
	die "Can't open available file: $!";
open STATUS, '</var/lib/dpkg/status' or die "Can't open status file: $!";

my (%available, %status);
my $package;

while (<AVAILABLE>)
{
	if (/^Package: (.*)/)
	{
		$package = $1;
	}
	elsif (/^Version: (.*)/)
	{
		$available{$package} = $1;
		undef $package;
	}
}

while (<STATUS>)
{
	if (/^Package: (.*)/)
	{
		$package = $1;
	}
	elsif (/^Version: (.*)/)
	{
		$status{$package} = $1;
		undef $package;
	}
}

close STATUS;
close AVAILABLE;

foreach my $package (sort keys %available)
{
	if (defined $status{$package})
	{
		print "!!! " if $available{$package} ne $status{$package};
		print "$package $available{$package} $status{$package}\n";
	}
}

