fix for the XXX-warning warning... have the test be a bit more specific
authorespie <espie@openbsd.org>
Wed, 6 Oct 2021 14:23:50 +0000 (14:23 +0000)
committerespie <espie@openbsd.org>
Wed, 6 Oct 2021 14:23:50 +0000 (14:23 +0000)
for the really bizarre case where we would end up having several update
paths.

usr.sbin/pkg_add/OpenBSD/PkgAdd.pm

index 18dccc8..a676e17 100644 (file)
@@ -1,7 +1,7 @@
 #! /usr/bin/perl
 
 # ex:ts=8 sw=4:
-# $OpenBSD: PkgAdd.pm,v 1.120 2021/06/28 14:17:01 espie Exp $
+# $OpenBSD: PkgAdd.pm,v 1.121 2021/10/06 14:23:50 espie Exp $
 #
 # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
 #
@@ -463,6 +463,23 @@ LOOP:      for my $c (@conflicts) {
        return 1;
 }
 
+sub find_belated_update
+{
+       my ($set, $state, $old) = @_;
+
+       for my $n ($set->newer) {
+               if ($n->conflict_list->conflicts_with($old->pkgname)) {
+                       if (defined $old->{update_found}) {
+                               $state->errsay("Ambiguous update #1 vs #2", 
+                                   $n->pkgname, 
+                                   $old->{update_found}->pkgname);
+                       } else {
+                               $old->{update_found} = $n;
+                       }
+               }
+       }
+}
+
 sub install_issues
 {
        my ($set, $state) = @_;
@@ -503,8 +520,9 @@ sub install_issues
                if (defined $s && $s ne $set) {
                        $set->merge($state->tracker, $s);
                } else {
-                       $set->add_older(OpenBSD::Handle->create_old($toreplace,
-                           $state));
+                       my $h = OpenBSD::Handle->create_old($toreplace, $state);
+                       $set->add_older($h);
+                       find_belated_update($set, $state, $h);
                }
        }