Currently, when pkg_add -u is run, if it encounters an update candidate
with the same package name, but a different pkgpath, it silent discards
the candidate.  This makes it more difficult to track down the cause.

The most common way this happens is if a package is moved in the tree,
and someone forgets to add the @pkgpath marker to the PLIST.  You have
an old version installed that uses the old pkgpath, and when you run
pkg_add -u, it doesn't update and doesn't tell you why, even in the more
verbose modes.

This makes pkg_add -uvv print a message saying why the update candidate
was skipped, with both package names and all pkgpaths for both packages.

For example, if I copy the databases/ruby-sequel port to
databases/ruby-sequel-new, update the version, and then try to update
it:

$ pkg_add -uvv ruby-sequel
Update candidates: quirks-1.75 -> quirks-1.75 (ok)
parsing quirks-1.75
No change in quirks-1.75
Skipping ruby-sequel-4.29.0 due to differing pkgpath:
databases/ruby-sequel-new,ruby18|databases/ruby-sequel-new|databases/ruby-sequel-foo
vs. databases/ruby-sequel,ruby18|databases/ruby-sequel for
ruby-sequel-3.37.0p0
Update candidates: ruby-sequel-3.37.0p0 -> ruby-sequel-3.37.0p0 (ok)
No change in ruby-sequel-3.37.0p0

I don't really like the current output, but unless we want to split the
message into multiple lines, I can't think of anything better.

Thoughts?

Jeremy


Index: PackingElement.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PackingElement.pm,v
retrieving revision 1.207
diff -u -p -r1.207 PackingElement.pm
--- PackingElement.pm   12 Jul 2012 08:57:02 -0000      1.207
+++ PackingElement.pm   12 Oct 2012 17:56:36 -0000
@@ -1863,6 +1863,17 @@ sub new
        }, $class;
 }
 
+sub fullpkgpath
+{
+       my ($self) = @_;
+       if(%{$self->{mandatory}}) {
+               my $m = join(",", keys %{$self->{mandatory}});
+               return "$self->{dir},$m";
+       } else {
+               return $self->{dir};
+       }
+}
+
 # a pkgpath has a dir, and some flavors/multi parts. To match, we must
 # remove them all. So, keep a full hash of everything we have (has), and
 # when stuff $to_rm matches, remove them from $from.
Index: Update.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/Update.pm,v
retrieving revision 1.152
diff -u -p -r1.152 Update.pm
--- Update.pm   28 Apr 2012 11:55:16 -0000      1.152
+++ Update.pm   12 Oct 2012 18:15:32 -0000
@@ -164,7 +164,16 @@ sub process_handle
                        }
                    }
                    if (!$plist->match_pkgpath($p2)) {
-                       $loc->forget;
+                       my $pkgname_old = $plist->pkgname;
+                       my @pkgpaths_o = map { @{$plist->pkgpath->{$_}} } keys 
%{$plist->pkgpath};
+                       my $pkgpaths_old = join("|", map {$_->fullpkgpath} 
@pkgpaths_o);
+
+                       my $pkgname_new = $p2->pkgname;
+                       my @pkgpaths_n = map { @{$p2->pkgpath->{$_}} } keys 
%{$p2->pkgpath};
+                       my $pkgpaths_new = join("|", map {$_->fullpkgpath} 
@pkgpaths_n);
+
+                       $state->updater->progress_message($state, "Skipping 
$pkgname_new due to differing pkgpath: $pkgpaths_new vs. $pkgpaths_old for 
$pkgname_old");
+                       $loc->forget;
                        next
                    }
                    if ($p2->has('explicit-update') && $state->{allupdates}) {

Reply via email to