diff options
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Add.pm | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index f2f266f2d44..02553556c7f 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.11 2004/11/11 11:36:26 espie Exp $ +# $OpenBSD: Add.pm,v 1.12 2004/11/11 12:13:57 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -19,6 +19,7 @@ use warnings; package OpenBSD::Add; use OpenBSD::Error; +use OpenBSD::PackageInfo; sub manpages_index { @@ -50,6 +51,37 @@ sub register_installation $plist->to_installation(); } +sub collision_report($) +{ + my $list = shift; + my %todo = map {($_, 1)} @$list; + my $bypkg = {}; + + + for my $pkg (installed_packages()) { + 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}; + } + } + } + print "Collision: the following files already exist\n"; + for my $pkg (sort keys %$bypkg) { + for my $item (sort @{$bypkg->{$pkg}}) { + print "\t$item ($pkg)\n"; + } + } + for my $item (sort keys %todo) { + print "\t$item\n"; + } +} + sub validate_plist($$) { my ($plist, $state) = @_; @@ -96,6 +128,7 @@ sub validate_plist($$) Fatal "fatal issues" if $problems; return $totsize; } + # used by newuser/newgroup to deal with options. package OpenBSD::PackingElement; use OpenBSD::Error; |