diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-09-18 08:14:41 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-09-18 08:14:41 +0000 |
commit | fc383c6c1b3770410e0fabb27d4e02af846bc297 (patch) | |
tree | ab4367f110495ece3caf0042426de7cf597a8e42 /usr.sbin/pkg_add | |
parent | 7ebccf053fce13d43924c8f464eea9e6ff4335e8 (diff) |
new-style conflicts that respect pkgspec.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 9 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingList.pm | 8 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgCfl.pm | 21 |
3 files changed, 27 insertions, 11 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 483f106f65d..92841e1a8a1 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.24 2004/09/15 17:10:09 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.25 2004/09/18 08:14:40 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -570,6 +570,13 @@ __PACKAGE__->setKeyword('pkgcfl'); sub keyword() { "pkgcfl" } sub category() { "pkgcfl" } +package OpenBSD::PackingElement::Conflict; +our @ISA=qw(OpenBSD::PackingElement); + +__PACKAGE__->setKeyword('conflict'); +sub keyword() { "conflict" } +sub category() { "conflict" } + package OpenBSD::PackingElement::NewDepend; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm index f6f26f48359..b9c5b4c88ac 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingList.pm,v 1.23 2004/09/16 07:46:00 espie Exp $ +# $OpenBSD: PackingList.pm,v 1.24 2004/09/18 08:14:40 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -96,7 +96,7 @@ sub ConflictOnly my ($fh, $cont) = @_; local $_; while (<$fh>) { - next unless m/^\@(?:pkgcfl|option|name)\b/; + next unless m/^\@(?:pkgcfl|conflict|option|name)\b/; &$cont($_); } } @@ -134,7 +134,7 @@ sub write for my $unique_item (qw(name no-default-conflict manual-installation extrainfo arch)) { $self->{$unique_item}->write($fh) if defined $self->{$unique_item}; } - for my $listname (qw(modules pkgcfl pkgdep newdepend libdepend items)) { + for my $listname (qw(modules pkgcfl conflict pkgdep newdepend libdepend items)) { if (defined $self->{$listname}) { for my $item (@{$self->{$listname}}) { $item->write($fh); @@ -163,7 +163,7 @@ sub visit for my $unique_item (qw(name no-default-conflict manual-installation extrainfo arch)) { $self->{$unique_item}->$method(@l) if defined $self->{$unique_item}; } - for my $listname (qw(modules pkgcfl pkgdep newdepend libdepend items)) { + for my $listname (qw(modules pkgcfl conflict pkgdep newdepend libdepend items)) { if (defined $self->{$listname}) { for my $item (@{$self->{$listname}}) { $item->$method(@l); 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; |