[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Question for a lintian check



On Sat, Nov 14, 2009 at 01:52:19AM +0100, Mike Hommey wrote:
> On Fri, Nov 13, 2009 at 04:26:22PM -0800, Russ Allbery wrote:
> > Mike Hommey <mh@glandium.org> writes:
> > > On Fri, Nov 13, 2009 at 02:32:04PM -0800, Russ Allbery wrote:
> > 
> > >> I think you can get there with Lintian::Relation; you just have to do
> > >> some preprocessing.  If the package does not include that chrome.d
> > >> file, then split its Depends on comma and then, for each element, see
> > >> if iceape-browser implies that element.  If that's true, then report
> > >> your tag and suggest changing to iceweasel | iceape-browser (>= 2.0).
> > 
> > > Thanks, it works. Though I'll have to group dependencies by package name
> > > after splitting on comma (for e.g. package (>= x.y), package (<< z))
> > 
> > Ah, yes.
> > 
> > This will be two places where we could use this (the other being checking
> > for too-weak dependencies from a -dev package).  We should probably figure
> > out some good interface so that we can add this pattern to
> > Lintian::Relation.
> 
> Probably something that would just split and group the dependencies
> would be enough for both uses.
> 
> An input like:
> package-a (>= 1.0), package-b | package-c, package-a (<< 2.0)
> would return:
> ("package-a (>= 1.0), package-a (<< 2.0)", "package-b | package-c")
> 
> There might be some corner cases to consider, though.

The following works well enough for me:

# Given a package dependency string without commas, return the package 
# names only.
sub dep_packages {

        my $dep = shift;

        unless( $dep =~ /\|/) {
                $dep =~ /^\s*(\S+)/;
                return ($1);
        }

        return map { /^\s*(\S+)/; $1 } split /\s*\|\s*/, $dep;
}

# Given a comma separated list of dependencies, returns a split list,
# where dependencies upon the same package are grouped in the same item.
sub split_deps {

        my $deps = shift;

        my @deps = split /\s*,\s*/, $deps;
        my %deps;
        foreach my $dep (@deps) {
                push @{$deps{$_}}, $dep foreach (dep_packages($dep));
        }
        return map { join ", ", @{$deps{$_}} } keys %deps;
}

Mike


Reply to: