Re: Important information regarding upcoming dpkg 1.16.2 upload
Hi,
On Wed, 14 Mar 2012, Sven Joachim wrote:
> Here is a patch adding two missing newlines on output:
Thanks.
> Note that libc-bin:amd64 is actually purged, however it remains in the
> status file (note that the "Multi-Arch: foreign" field is missing):
Ok, fixed that as well by ignoring "not-installed" entries when
considering multiple instances. And I kept the advice to dpkg -P only
when it was in config-files state. Otherwise I leave it up to
the user's judgment.
Updated version attached.
Cheers,
--
Raphaël Hertzog ◈ Debian Developer
Pre-order a copy of the Debian Administrator's Handbook and help
liberate it: http://debian-handbook.info/liberation/
#!/usr/bin/perl
use Dpkg::Control;
use Dpkg::Index;
my $arch = `dpkg --print-architecture`;
chomp($arch);
my $status = Dpkg::Index->new(type => CTRL_FILE_STATUS);
$status->load("/var/lib/dpkg/status");
sub find_foreign {
my $a = shift;
return ($a ne $arch and $a ne "all");
}
sub find_installed {
return ($_[0] !~ / not-installed$/);
}
# Detect multiple instances which are not M-A: same
foreach my $foreign ($status->get("Architecture" => \&find_foreign)) {
my $pkg = $foreign->{'Package'};
my $pkgarch = $foreign->{'Package'} . ':' . $foreign->{'Architecture'};
my $ma = $foreign->{'Multi-Arch'} || 'no';
print "INFO: Foreign package detected: $pkgarch (Multi-Arch: $ma)\n";
my @pkgs = $status->get("Package" => $pkg, "Status" => \&find_installed);
if (scalar(@pkgs) > 1) {
foreach my $item (@pkgs) {
$pkgarch = $item->{'Package'} . ':' . $item->{'Architecture'};
if ($item->{'Multi-Arch'} ne "same") {
print "PROBLEM: one instance of $pkg is not Multi-Arch: same\n";
if ($item->{'Status'} =~ / config-files$/) {
print "SOLUTION: dpkg -P $pkgarch\n";
} else {
print "SOLUTION: update $pkgarch to a good version or get rid of it\n";
}
}
}
}
}
# Find broken packages
foreach my $pkg ($status->get()) {
my $ma = $pkg->{'Multi-Arch'} || '';
next if ($pkg->{'Status'} =~ m/ not-installed$/);
my $pkgarch = $pkg->{'Package'};
if ($ma eq "same") {
$pkgarch = $pkg->{'Package'} . ':' . $pkg->{'Architecture'};
}
if (! -e "/var/lib/dpkg/info/$pkgarch.list") {
print "PROBLEM: $pkgarch has missing info files\n";
print "SOLUTION: apt-get --reinstall install $pkgarch\n";
}
}
Reply to: