diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-11-01 19:48:59 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-11-01 19:48:59 +0000 |
commit | aed01bd8480b6fa594c2e547dc015d6f4224c437 (patch) | |
tree | 6a395ba9d9ed772688a80c995f06483a044a0d25 | |
parent | 45b5e4bf3cdac141756ac174cab5d47fc8a1c694 (diff) |
adjust dependencies
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Update.pm | 23 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 13 |
2 files changed, 33 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm index 4c5cfb4ec5e..d12fa86869c 100644 --- a/usr.sbin/pkg_add/OpenBSD/Update.pm +++ b/usr.sbin/pkg_add/OpenBSD/Update.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Update.pm,v 1.6 2004/11/01 19:14:26 espie Exp $ +# $OpenBSD: Update.pm,v 1.7 2004/11/01 19:48:58 espie Exp $ # # Copyright (c) 2004 Marc Espie <espie@openbsd.org> # @@ -123,10 +123,11 @@ sub can_do { my ($toreplace, $replacement, $state) = @_; + my $wantlist = []; my $r = OpenBSD::RequiredBy->new($toreplace); my $okay = 1; if (-f $$r) { - my $wantlist = $r->list(); + $wantlist = $r->list(); my $done_wanted = {}; for my $wanting (@$wantlist) { next if defined $done_wanted->{$wanting}; @@ -146,7 +147,25 @@ sub can_do if ($@) { return 0; } + + $plist->{wantlist} = $wantlist; return $okay ? $plist : $okay; } + +sub adjust_dependency +{ + my ($dep, $from, $into) = @_; + + my $contents = installed_info($dep).CONTENTS; + my $plist = OpenBSD::PackingList->fromfile($contents); + my $items = []; + for my $item (@{$plist->{pkgdep}}) { + next if $item->{'name'} eq $from; + push(@$items, $item); + } + $plist->{pkgdep} = $items; + OpenBSD::PackingElement::PkgDep->add($plist, $into); + $plist->tofile($contents); +} 1; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index a202e8543a6..0c211cc8091 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.91 2004/11/01 19:21:58 espie Exp $ +# $OpenBSD: pkg_add,v 1.92 2004/11/01 19:48:58 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -517,6 +517,17 @@ sub really_add($$) if ($plist->has(DISPLAY)) { $plist->get(DISPLAY)->prepare($state); } + # and add dependencies corresponding to the replacement + if (defined $plist->{replacing}) { + require OpenBSD::RequiredBy; + require OpenBSD::Update; + + my $d = OpenBSD::RequiredBy->new($pkgname); + for my $dep (@{$plist->{replacing}->{wantlist}}) { + $d->add($dep); + OpenBSD::Update::adjust_dependency($dep, $plist->{replacing}->pkgname(), $pkgname); + } + } } # one-level dependencies tree, for nicer printouts |