summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-09-18 08:14:41 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-09-18 08:14:41 +0000
commitfc383c6c1b3770410e0fabb27d4e02af846bc297 (patch)
treeab4367f110495ece3caf0042426de7cf597a8e42 /usr.sbin/pkg_add/OpenBSD/PkgCfl.pm
parent7ebccf053fce13d43924c8f464eea9e6ff4335e8 (diff)
new-style conflicts that respect pkgspec.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/PkgCfl.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgCfl.pm21
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm b/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm
index 06a5558348a..107b7ee0fe6 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PkgCfl.pm,v 1.3 2004/09/14 22:49:36 espie Exp $
+# $OpenBSD: PkgCfl.pm,v 1.4 2004/09/18 08:14:40 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -17,7 +17,9 @@
use strict;
use warnings;
+
package OpenBSD::PkgCfl;
+use OpenBSD::PackageName;
sub glob2re
{
@@ -35,12 +37,18 @@ sub make_conflict_list($)
my $l = [];
unless (defined $plist->{'no-default-conflict'}) {
- my $stem = (OpenBSD::PackageName::splitname$plist->pkgname())[0];
- push(@$l, "^\Q$stem\E-\\d.*\$");
+ my $stem = (OpenBSD::PackageName::splitname $plist->pkgname())[0];
+ push(@$l, sub { grep { m/^\Q$stem\E-\d.*$/ } @_; });
}
if (defined $plist->{pkgcfl}) {
for my $cfl (@{$plist->{pkgcfl}}) {
- push(@$l, glob2re($cfl->{name}));
+ my $re = glob2re($cfl->{name});
+ push(@$l, sub { grep { m/$re/ } @_; });
+ }
+ }
+ if (defined $plist->{conflict}) {
+ for my $cfl (@{$plist->{conflict}}) {
+ push(@$l, sub { OpenBSD::PackageName::pkgspec_match($cfl->{name}, @_); });
}
}
bless $l, $class;
@@ -50,8 +58,9 @@ sub conflicts_with
{
my ($self, @pkgnames) = @_;
for my $cfl (@$self) {
- if (grep { m/$cfl/ } @pkgnames) {
- return grep { m/$cfl/ } @pkgnames;
+ my @l = &$cfl(@pkgnames);
+ if (@l) {
+ return @l;
}
}
return 0;