diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-08-16 12:05:59 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-08-16 12:05:59 +0000 |
commit | 8e6d45167d8aa39eebd0ac3e0e7a701f454b3105 (patch) | |
tree | 2c03caea409b6f9dfbe57e995a254597f8e4857d /usr.sbin | |
parent | 4affe0bfdd9f771fe10a6ec3a97887435029dde7 (diff) |
when you ask to update a package, you generally want to update its
dependencies as well...
so do the stem -> pkgname conversion early, and then compute the
closure of dependencies on the list of packages we asked for.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 44 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add.1 | 6 |
2 files changed, 42 insertions, 8 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 6244dac7a9b..55dfddd2a38 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.181 2005/08/16 11:25:48 espie Exp $ +# $OpenBSD: pkg_add,v 1.182 2005/08/16 12:05:58 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -518,25 +518,54 @@ sub install_package return (); } +sub compute_closure +{ + require OpenBSD::RequiredBy; + + my $old = shift; + my @todo; + my %done; + my %toupdate = map {($_, 1)} @$old; + push(@todo, keys %toupdate); + while (my $pkgname = pop @todo) { + next if $done{$pkgname}; + $done{$pkgname} = 1; + for my $dep (OpenBSD::Requiring->new($pkgname)->list()) { + next if defined $done{$dep}; + next if defined $toupdate{$dep}; + $toupdate{$dep} = 1; + push(@todo, $dep); + } + } + return keys %toupdate; +} + sub find_updates { my ($old, $new, $state) = @_; - my @cantupdate = (); - my $hash = OpenBSD::PackageName::compile_stemlist(OpenBSD::PackageLocator::distant_available()); + my @list = (); for my $pkgname (@$old) { - my $stem = $pkgname; if (OpenBSD::PackageName::is_stem($pkgname)) { my @l = OpenBSD::PackageName::findstem($pkgname, installed_packages()); if (@l == 1) { - $pkgname = $l[0]; + push(@list, $l[0]); } else { - Fatal("Ambiguous: $stem could be", join(',', @l)); + Fatal("Ambiguous: $pkgname could be", join(',', @l)); } } else { - $stem = OpenBSD::PackageName::splitstem($pkgname); + push(@list, $pkgname); } + } + unless (defined $state->{full_update} or defined $state->{forced}->{noclosure}) { + @list = compute_closure(\@list); + } + my @cantupdate = (); + my $hash = OpenBSD::PackageName::compile_stemlist(OpenBSD::PackageLocator::distant_available()); + + for my $pkgname (@list) { + my $stem = OpenBSD::PackageName::splitstem($pkgname); my @l = $hash->findstem($stem); if (@l == 0) { push(@cantupdate, $pkgname); @@ -682,6 +711,7 @@ lock_db($state->{not}); if ($opt_u) { if (@ARGV == 0) { @ARGV = sort(installed_packages()); + $state->{full_update} = 1; } my @todo = (); my @cantupdate = find_updates(\@ARGV, \@todo, $state); diff --git a/usr.sbin/pkg_add/pkg_add.1 b/usr.sbin/pkg_add/pkg_add.1 index 373493aad3f..f3edbb9ca32 100644 --- a/usr.sbin/pkg_add/pkg_add.1 +++ b/usr.sbin/pkg_add/pkg_add.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pkg_add.1,v 1.41 2005/08/16 10:37:06 espie Exp $ +.\" $OpenBSD: pkg_add.1,v 1.42 2005/08/16 12:05:58 espie Exp $ .\" .\" FreeBSD install - a package for the installation and maintenance .\" of non-core utilities. @@ -158,6 +158,10 @@ will install everything and the kitchen sink: randomly reorder the list of packages to install, and proceed after weeding out conflicts. .It Ar libdepends library specifications may not be fulfilled. +.It Ar noclosure +do not compute the closure of dependencies to figure out which packages to +update when using +.Fl u . .It Ar nonroot install even if not running as root. .It Ar pkgpath |