/usr/lib/cruft/explain/dpkg is in cruft 0.9.19.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #!/usr/bin/perl
# read diversions information, and create a hash: diverted_file -> diverting_package
open(DIVERT, "/var/lib/dpkg/diversions" ) || die( "Couldn't open diversions info\n");
my %diverted = ();
my $x = 0;
my $lastkey;
while(<DIVERT>) {
chomp;
if ( $x % 3 == 0 ){
$diverted{$_} = $x if ( $x % 3 == 0 );
$lastkey = $_;
}
$diverted{$lastkey} = $_ if ( $diverted{$lastkey} + 2 == $x );
$x++;
}
close DIVERT or die "Couldn't close diversions info\n";
# Decide, basing on the diverting package and the list of packages providing
# the file, whether the file should be present in the system
# If so, then print file. Otherwise, don't print anything.
sub decide($$$)
{
my $diverted = shift;
my $pkgs = shift;
my $line = shift;
if (not defined $diverted) {
# there is no diversion, so the file should be present
print $line or die $!;
} elsif (scalar @$pkgs > 1) {
# many packages provide it, and there is a diversion
# so the file should be present
print $line or die $!;
# just one package provides it, and there is a diversion
} elsif ($diverted eq $$pkgs[0]) {
# the file will be present only if it's provided by the
# same package which diverts it
print $line or die $!;
}
}
# Read the list of installed files in format:
# /var/lib/dpkg/info/<PROVIDING_PACKAGE>.list:<FILENAME>
# Look up the diversion hash created above, and print the names of files which
# should be on the system.
open(DPKG, "find /var/lib/dpkg/info -type f -name '*.list' | xargs grep -H . | sort -t: -k 2 |") or die "Couldn't open dpkg info: $!\n";
my $re = qr{^/var/lib/dpkg/info/(\S+)\.list:(.*)$};
my $lastfile = '';
my @pkgs;
while($l=<DPKG>) {
chomp $l;
$l =~ $re or warn "invalid input: \"$l\"";
my ($pkg, $file) = ($1, $2);
if ($file eq $lastfile) {
push @pkgs, $pkg;
} else {
# now all pkgs providing $file are in @pkgs
# and package diverting that file (if any) is in $diverted{$file}
decide($diverted{$lastfile}, \@pkgs, $lastfile."\n") if $lastfile;
$lastfile = $file;
@pkgs = ($pkg);
}
}
decide($diverted{$lastfile}, \@pkgs, $lastfile."\n");
close DPKG or die "Couldn't close dpkg info: $!\n";
close STDOUT or die $!;
|