[Popcon-developers] Bug#865748: popularity-contest: Should handle dpkg diversions
Robert Luberda
robert at debian.org
Sat Jun 24 12:57:02 UTC 2017
Package: popularity-contest
Version: 1.65
Severity: wishlist
Tags: patch
It would be nice if popularity-contest could handle diversions.
Otherwise the same file can be reported for different packages, e.g.:
$ perldoc >/dev/null 2>&1
$ /usr/sbin/popularity-contest | grep perldoc
1498305600 1498089600 perl-doc /usr/bin/perldoc
1498305600 1498089600 perl /usr/bin/perldoc
The following patch handles this by choosing the simplest approach,
namely by ignoring diverted files unless they were diverted by the
package being worked on.
--- popularity-contest.old
+++ popularity-contest
@@ -107,6 +107,16 @@
}
}
+# List files diverted by dpkg
+my %diverted;
+open DIVERSIONS, "LC_ALL=C dpkg-divert --list|";
+while (<DIVERSIONS>)
+{
+ next unless /^(?:local )?diversion of (\S+) to (?:\S+)(?: by (\S+))?\s*$/;
+ $diverted{$1} = defined $2 ? $2 : ""
+}
+close DIVERSIONS;
+
# Read dpkg database of installed packages
open PACKAGES, "dpkg-query --show --showformat='\${status} \${package}\\n'|";
while (<PACKAGES>)
@@ -127,6 +137,7 @@
&& ! m{/lib/.+-.+-.+/}
|| defined $mapped{$_} )
&& -f $_);
+ next if defined $diverted{$_} and $diverted{$_} ne $pkg;
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat;
Regards,
robert
-- System Information:
Debian Release: 9.0
APT prefers unstable
APT policy: (990, 'unstable'), (990, 'testing'), (990, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.9.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=pl_PL.UTF-8, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8), LANGUAGE=pl_PL.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages popularity-contest depends on:
ii debconf [debconf-2.0] 1.5.61
ii dpkg 1.18.24
Versions of packages popularity-contest recommends:
ii cron [cron-daemon] 3.0pl1-128+b1
ii gnupg 2.1.18-8
ii postfix [mail-transport-agent] 3.2.2-1
Versions of packages popularity-contest suggests:
ii anacron 2.3-24
-- debconf information excluded
More information about the Popcon-developers
mailing list