diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-11-27 14:02:51 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-11-27 14:02:51 +0000 |
commit | 0290d1a059c8f3bddcc05459e4cc70c0968e620b (patch) | |
tree | 0564e126c60cd568e27dcd2e3c10db5de77ddb4c /usr.sbin/pkg_add | |
parent | 9074f1b2989f67cdc3997d4c5dbfed824146c1e2 (diff) |
if the package is already installed, check whether updating it makes sense:
look at the context in which both packages were built. If dependencies differ,
then this is a sensible update.
While we're there, try harder to build a conflict list for .libs-* packages.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Update.pm | 62 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 4 |
2 files changed, 61 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm index 1ea98ed3e84..5763c348147 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.34 2004/11/18 21:56:03 espie Exp $ +# $OpenBSD: Update.pm,v 1.35 2004/11/27 14:02:50 espie Exp $ # # Copyright (c) 2004 Marc Espie <espie@openbsd.org> # @@ -48,6 +48,10 @@ sub unmark_lib { } +sub build_context +{ +} + package OpenBSD::PackingElement::FileBase; use File::Temp qw/tempfile/; @@ -173,6 +177,25 @@ sub unmark_lib delete $libs->{"$libname"}; } +package OpenBSD::PackingElement::Wantlib; +sub build_context +{ + my ($self, $hash) = @_; + $hash->{$self->{name}} = 1; +} + +package OpenBSD::PackingElement::Depend; +sub build_context +{ + my ($self, $hash) = @_; + $hash->{$self->{def}} = 1; +} + +package OpenBSD::PackingElement::PkgDep; +sub build_context +{ +} + package OpenBSD::PackingElement::NewDepend; use OpenBSD::Error; sub validate_depend @@ -267,9 +290,27 @@ sub split_libs my $items = []; my $splitted = OpenBSD::PackingList->new(); + OpenBSD::PackingElement::Name->add($splitted, ".libs-".$plist->pkgname()); - # we conflict with the package we just removed... - OpenBSD::PackingElement::Conflict->add($splitted, $plist->pkgname()); + if (defined $plist->{conflict}) { + for my $item (@{$plist->{conflict}}) { + $item->clone()->add_object($splitted); + } + } + if (defined $plist->{pkgcfl}) { + for my $item (@{$plist->{pkgcfl}}) { + $item->clone()->add_object($splitted); + } + } + if (defined $plist->{'no-default-conflict'}) { + # we conflict with the package we just removed... + OpenBSD::PackingElement::Conflict->add($splitted, $plist->pkgname()); + } else { + require OpenBSD::PackageName; + + my $stem = OpenBSD::PackageName::splitstem($plist->pkgname()); + OpenBSD::PackingElement::Conflict->add($splitted, $stem."-*"); + } for my $item (@{$plist->{items}}) { if ($item->isa("OpenBSD::PackingElement::Lib") && @@ -381,4 +422,19 @@ sub adjust_dependency $l->delete($from); $l->add($into); } + +sub is_needed +{ + my ($plist, $state) = @_; + my $new_context = {}; + $plist->visit('build_context', $new_context); + my $oplist = OpenBSD::PackingList->from_installation($plist->pkgname()); + my $old_context = {}; + $oplist->visit('build_context', $old_context); + my $n = join(',', sort keys %$new_context); + my $o = join(',', sort keys %$old_context); + print "Comparing full signature $o vs. $n\n" if $state->{very_verbose}; + return join(',', sort keys %$new_context) ne + join(',', sort keys %$old_context); +} 1; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index b88ff675a78..e9d60950a27 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.129 2004/11/23 22:58:02 espie Exp $ +# $OpenBSD: pkg_add,v 1.130 2004/11/27 14:02:50 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -538,7 +538,7 @@ sub install_package my $plist = $handle->{plist}; - if (is_installed($plist->pkgname()) && !$state->{forced}->{installed}) { + if (is_installed($plist->pkgname()) && !$state->{forced}->{installed} && !OpenBSD::Update::is_needed($plist, $state)) { $handle->close(); return (); } |