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 | |
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.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Add.pm | 5 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/CollisionReport.pm | 42 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Vstat.pm | 12 |
3 files changed, 38 insertions, 21 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index c16e3f6a3d6..2db732a77d6 100644 --- a/usr.sbin/pkg_add/OpenBSD/Add.pm +++ b/usr.sbin/pkg_add/OpenBSD/Add.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Add.pm,v 1.25 2004/12/16 11:07:33 espie Exp $ +# $OpenBSD: Add.pm,v 1.26 2004/12/17 11:26:21 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -81,9 +81,10 @@ sub validate_plist($$) if (OpenBSD::Vstat::vexists($fname)) { push(@$colliding, $item); $problems++; + next; } $totsize += $item->{size} if defined $item->{size}; - my $s = OpenBSD::Vstat::add($fname, $item->{size}); + my $s = OpenBSD::Vstat::add($fname, $item->{size}, \$pkgname); next unless defined $s; if ($s->{ro}) { Warn "Error: ", $s->{dev}, " is read-only ($fname)\n"; 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) { diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm index d42b582ea21..3dcda0908d2 100644 --- a/usr.sbin/pkg_add/OpenBSD/Vstat.pm +++ b/usr.sbin/pkg_add/OpenBSD/Vstat.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Vstat.pm,v 1.8 2004/11/11 15:35:10 espie Exp $ +# $OpenBSD: Vstat.pm,v 1.9 2004/12/17 11:26:22 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -163,10 +163,14 @@ sub account_for($$) return $e; } -sub add($$) +sub add($$;$) { - my ($name, $size) = @_; - $virtual->{$name} = 1; + my ($name, $size, $value) = @_; + if (defined $value) { + $virtual->{$name} = $value; + } else { + $virtual->{$name} = 1; + } my $d = dirname($name); $virtual_dir->{$d} = [] unless defined $virtual_dir->{$d}; push(@{$virtual_dir->{$d}}, $name); |