summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-11-11 12:29:59 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-11-11 12:29:59 +0000
commit3af25a49f80d5eb5db02ca411b555ebd29898486 (patch)
tree0bff2e543c364197951e1a841a37f5b9b52b1998 /usr.sbin
parent5cabf9e88a3f734e93f78171e48b45303cbf40f4 (diff)
move collision reporter to a separate file, so that it doesn't get loaded
all the time.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/Makefile3
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Add.pm37
-rw-r--r--usr.sbin/pkg_add/OpenBSD/CollisionReport.pm60
3 files changed, 66 insertions, 34 deletions
diff --git a/usr.sbin/pkg_add/Makefile b/usr.sbin/pkg_add/Makefile
index b30d7f2f745..66d9f1fb4cc 100644
--- a/usr.sbin/pkg_add/Makefile
+++ b/usr.sbin/pkg_add/Makefile
@@ -1,9 +1,10 @@
-# $OpenBSD: Makefile,v 1.16 2004/11/09 11:11:01 espie Exp $
+# $OpenBSD: Makefile,v 1.17 2004/11/11 12:29:58 espie Exp $
MAN=pkg_add.1 pkg_info.1 pkg_create.1 pkg_delete.1 pkg.1
PACKAGES= \
OpenBSD/Add.pm \
+ OpenBSD/CollisionReport.pm \
OpenBSD/Delete.pm \
OpenBSD/Error.pm \
OpenBSD/Getopt.pm \
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm
index 9109f2ac417..b6b027b8d1c 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.13 2004/11/11 12:17:25 espie Exp $
+# $OpenBSD: Add.pm,v 1.14 2004/11/11 12:29:58 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -52,37 +52,6 @@ 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) = @_;
@@ -124,7 +93,9 @@ sub validate_plist($$)
}
}
if (@$colliding > 0) {
- collision_report($colliding);
+ require OpenBSD::CollisionReport;
+
+ OpenBSD::CollisionReport::collision_report($colliding, $state);
}
Fatal "fatal issues" if $problems;
return $totsize;
diff --git a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm
new file mode 100644
index 00000000000..96c0b2fa923
--- /dev/null
+++ b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm
@@ -0,0 +1,60 @@
+# ex:ts=8 sw=4:
+# $OpenBSD: CollisionReport.pm,v 1.1 2004/11/11 12:29:58 espie Exp $
+#
+# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+use strict;
+use warnings;
+
+package OpenBSD::CollisionReport;
+use OpenBSD::PackingList;
+use OpenBSD::PackageInfo;
+
+
+sub collision_report($$)
+{
+ my ($list, $state) = @_;
+ my %todo = map {($_, 1)} @$list;
+ my $bypkg = {};
+
+
+ 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 LOOP if !%todo;
+ }
+ }
+ }
+ }
+ 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";
+ }
+}
+
+1;