diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2010-01-11 12:49:54 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2010-01-11 12:49:54 +0000 |
commit | 5335d2ca823a26d9626fbf5e15979969378e5363 (patch) | |
tree | 8b3008b70aca8397b16c6e565c5c15692ce99fe1 /usr.sbin | |
parent | 68fe9973cc3d493b1d8e4ea267893c83820d01c3 (diff) |
allow installation to proceed even without -r if it's an actual update
(all markers match, conflict and pkgpath, and the pkgname is newer if it's
the same stem/flavor combo)
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 0fe125a0706..64c077d5d39 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.466 2010/01/11 12:25:38 espie Exp $ +# $OpenBSD: pkg_add,v 1.467 2010/01/11 12:49:53 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # @@ -284,6 +284,41 @@ sub mark_as_manual_install } } +sub updates +{ + my ($n, $plist) = @_; + if (!$n->location->update_info->match_pkgpath($plist)) { + return 0; + } + if (!$n->plist->conflict_list->conflicts_with($plist->pkgname)) { + return 0; + } + my $r = OpenBSD::PackageName->from_string($n->pkgname)->compare( + OpenBSD::PackageName->from_string($plist->pkgname)); + if (defined $r && $r < 0) { + return 0; + } + return 1; +} + +sub is_an_update_from +{ + my ($set, @conflicts) = @_; +LOOP: for my $c (@conflicts) { + next if $c =~ m/^\.libs\d*\-/; + next if $c =~ m/^partial\-/; + my $plist = OpenBSD::PackingList->from_installation($c, \&OpenBSD::PackingList::UpdateInfoOnly); + return 0 unless defined $plist; + for my $n ($set->newer) { + if (updates($n, $plist)) { + next LOOP; + } + } + return 0; + } + return 1; +} + sub install_issues { my ($set, $state) = @_; @@ -294,10 +329,12 @@ sub install_issues if (!$state->{allow_replacing}) { if (grep { !/^.libs\d*\-/ && !/^partial\-/ } @conflicts) { - $state->errsay("Can't install ", $set->print, - " because of conflicts (", - join(',', @conflicts), ")"); - return "conflicts"; + if (!$set->is_an_update_from(@conflicts)) { + $state->errsay("Can't install ", $set->print, + " because of conflicts (", + join(',', @conflicts), ")"); + return "conflicts"; + } } } |