tags 293838 patch thanks Hi,
I have made a patch against master that attempts to find file conflicts. It does not handle diverts (which will be false-positives) nor conflicts on Provides (probably it should). So far it breaks at least 5 tests (ocmal-general, 2 files ones, a menu test and one of the legacy tests), which all appears to actually have a file-conflict. Comments and corrections welcome. :) ~Niels
>From 1af0caded763dcc9e751de666a7b79440a387a7e Mon Sep 17 00:00:00 2001 From: Niels Thykier <[email protected]> Date: Sun, 20 Nov 2011 00:46:19 +0100 Subject: [PATCH 2/2] Implemented a simple file-conflict check in group-checks Signed-off-by: Niels Thykier <[email protected]> --- checks/group-checks | 50 +++++++++++++++++++++++++++++++++++++++++++++- checks/group-checks.desc | 11 ++++++++++ 2 files changed, 60 insertions(+), 1 deletions(-) diff --git a/checks/group-checks b/checks/group-checks index 13e0365..ccf6d3b 100644 --- a/checks/group-checks +++ b/checks/group-checks @@ -47,8 +47,11 @@ my @nodes = (); my %edges = (); my $sccs; my $ginfo = $group->info; +my @procs = $group->get_processables ('binary'); -foreach my $proc ($group->get_processables('binary')) { +_check_file_overlap (@procs); + +foreach my $proc (@procs) { my $deps = $ginfo->direct_dependencies ($proc); if (scalar @$deps > 0) { # it depends on another package - it can cause @@ -96,6 +99,51 @@ sub _check_priorities { } } +sub _check_file_overlap { + my (@procs) = @_; + # Sort them for stable output + my @sorted = sort { $a->pkg_name cmp $b->pkg_name } @procs; + for (my $i = 0 ; $i < scalar @sorted ; $i++) { + my $proc = $sorted[$i]; + my $pinfo = $proc->info; + for (my $j = $i ; $j < scalar @sorted ; $j++) { + my $other = $sorted[$j]; + my $oinfo = $other->info; + # poor man's "Multi-arch: same" work-around. + next if $proc->pkg_name eq $other->pkg_name; + + # $other conflicts/replaces with $proc + next if $oinfo->relation ('conflicts')->implies ($proc->pkg_name); + next if $oinfo->relation ('replaces')->implies ($proc->pkg_name); + + # $proc conflicts/replaces with $other + next if $pinfo->relation ('conflicts')->implies ($other->pkg_name); + next if $pinfo->relation ('replaces')->implies ($other->pkg_name); + + _overlap_check ($proc, $pinfo, $other, $oinfo); + } + } +} + +sub _overlap_check { + my ($a_proc, $a_info, $b_proc, $b_info) = @_; + my $b_index = $b_info->index; + foreach my $raw (@{ $a_info->sorted_index }) { + my $file; + my $a_file; + my $b_file; + next unless $raw; + $file = $raw; # copy, because we have to modifiy it + $file =~ s,/$,,o; + $b_file = $b_index->{$file} // $b_index->{"$file/"}; + if ($b_file) { + $a_file = $a_info->index->{$file} // $a_info->index->{"$file/"}; + next if $a_file->{type} eq $b_file->{type} && $a_file->{type} eq 'd'; + tag 'binaries-have-file-conflict', $a_proc->pkg_name, $b_proc->pkg_name, $file; + } + } +} + ## Encapsulate Tarjan's algorithm in an class/object to keep ## the run sub somewhat sane. package Lintian::group_checks::Graph; diff --git a/checks/group-checks.desc b/checks/group-checks.desc index b31ed54..4f71c6b 100644 --- a/checks/group-checks.desc +++ b/checks/group-checks.desc @@ -33,3 +33,14 @@ Info: The package depends on a package with lower priority than package. A full check of all dependencies built from different source packages is beyond the scope of Lintian. The depcheck service can do this. + +Tag: binaries-have-file-conflict +Severity: normal +Certainty: possible +Experimental: no +Info: The binaries appears to have overlapping files without proper + conflicts relation. + . + Note the check is completely based on the file index for the + packages. Possible known false-positives include dpkg-diverts in + maintainer scripts. -- 1.7.7.1

