diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-12-17 11:26:23 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-12-17 11:26:23 +0000 |
commit | 1287806bfb8c768032253488deaada417b30fb7b (patch) | |
tree | 88e768619443f82f3dd20e3e9d4d4dc702062fc2 /usr.sbin/pkg_add/OpenBSD/CollisionReport.pm | |
parent | 5465df75affa6e96def5df641090f1833bf3c1eb (diff) |
better collision reports.
- in validate_plist, don't re-add a file that exists.
- allows the virtual file system to put marks on existing files
- use a \$pkgname the first time a file is added (space constraints: don't
duplicate the pkgname).
- in CollisionReport, first check the vfs, so that we don't look
at installed packages when the collision only concerns newly added pkgs.
Makes pkg_add -n report collision reports correctly.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/CollisionReport.pm')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/CollisionReport.pm | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm index ec166fc7f3b..683469ff587 100644 --- a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm +++ b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: CollisionReport.pm,v 1.6 2004/12/16 11:18:44 espie Exp $ +# $OpenBSD: CollisionReport.pm,v 1.7 2004/12/17 11:26:22 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -20,6 +20,7 @@ use warnings; package OpenBSD::CollisionReport; use OpenBSD::PackingList; use OpenBSD::PackageInfo; +use OpenBSD::Vstat; sub collision_report($$) @@ -29,23 +30,34 @@ sub collision_report($$) my $bypkg = {}; my $clueless_bat = 0; + for my $name (keys %todo) { + my $p = OpenBSD::Vstat::vexists $name; + if (ref $p) { + my $pkg = $$p; + $bypkg->{$pkg} = [] unless defined $bypkg->{$pkg}; + push(@{$bypkg->{$pkg}}, $name); + delete $todo{$name}; + } + } - BIGLOOP: { - for my $pkg (installed_packages()) { - print "Looking for collisions in $pkg\n" if $state->{verbose}; - my $plist = OpenBSD::PackingList->from_installation($pkg, - \&OpenBSD::PackingList::FilesOnly); - for my $item (@{$plist->{items}}) { - next unless $item->IsFile(); - my $name = $item->fullname(); - if (defined $todo{$name}) { - $bypkg->{$pkg} = [] unless defined $bypkg->{$pkg}; - push(@{$bypkg->{$pkg}}, $name); - delete $todo{$name}; - last BIGLOOP if !%todo; + if (%todo) { + BIGLOOP: { + for my $pkg (installed_packages()) { + print "Looking for collisions in $pkg\n" if $state->{verbose}; + my $plist = OpenBSD::PackingList->from_installation($pkg, + \&OpenBSD::PackingList::FilesOnly); + for my $item (@{$plist->{items}}) { + next unless $item->IsFile(); + my $name = $item->fullname(); + if (defined $todo{$name}) { + $bypkg->{$pkg} = [] unless defined $bypkg->{$pkg}; + push(@{$bypkg->{$pkg}}, $name); + delete $todo{$name}; + last BIGLOOP if !%todo; + } } } - } + } } print "Collision: the following files already exist\n"; for my $pkg (sort keys %$bypkg) { |