summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2015-08-13 16:34:12 +0000
committerMarc Espie <espie@cvs.openbsd.org>2015-08-13 16:34:12 +0000
commit0fea5e4e7363295dabada8953674d98f4efc0137 (patch)
tree9f289052772f91394b87e7d4b70c2efb04997932 /usr.sbin/pkg_add
parentc6f035bf37f1b42f22b8cc4448d17752cf683e7a (diff)
scaffolding that will display more info for the elusive REQUIRED_BY error
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/RequiredBy.pm19
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Tracker.pm35
2 files changed, 46 insertions, 8 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm b/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm
index 9c8bda58073..2528257b098 100644
--- a/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm
+++ b/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: RequiredBy.pm,v 1.26 2014/03/18 18:53:29 espie Exp $
+# $OpenBSD: RequiredBy.pm,v 1.27 2015/08/13 16:34:11 espie Exp $
#
# Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org>
#
@@ -22,6 +22,14 @@ package OpenBSD::RequirementList;
use OpenBSD::PackageInfo;
use Carp;
+sub fatal_error
+{
+ my ($self, $msg) = @_;
+ require OpenBSD::Tracker;
+ OpenBSD::Tracker->dump;
+ confess ref($self), ": $msg $self->{filename}: $!";
+}
+
sub fill_entries
{
my $self = shift;
@@ -29,9 +37,8 @@ sub fill_entries
my $l = $self->{entries} = {};
if (-f $self->{filename}) {
- open(my $fh, '<', $self->{filename}) or
- croak ref($self),
- ": reading $self->{filename}: $!";
+ open(my $fh, '<', $self->{filename}) or
+ $self->fatal_error("reading");
while(<$fh>) {
s/\s+$//o;
next if /^$/o;
@@ -57,8 +64,8 @@ sub synch
}
}
if (%{$self->{entries}}) {
- open(my $fh, '>', $self->{filename}) or
- croak ref($self), ": writing $self->{filename}: $!";
+ open(my $fh, '>', $self->{filename}) or
+ $self->fatal_error("writing");
while (my ($k, $v) = each %{$self->{entries}}) {
print $fh "$k\n";
}
diff --git a/usr.sbin/pkg_add/OpenBSD/Tracker.pm b/usr.sbin/pkg_add/OpenBSD/Tracker.pm
index b6eb2e2bb5e..1b019879819 100644
--- a/usr.sbin/pkg_add/OpenBSD/Tracker.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Tracker.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Tracker.pm,v 1.27 2014/02/06 17:13:05 espie Exp $
+# $OpenBSD: Tracker.pm,v 1.28 2015/08/13 16:34:11 espie Exp $
#
# Copyright (c) 2009 Marc Espie <espie@openbsd.org>
#
@@ -32,10 +32,41 @@ use strict;
use warnings;
package OpenBSD::Tracker;
+our $s;
+
sub new
{
my $class = shift;
- return bless {}, $class;
+ return $s = bless {}, $class;
+}
+
+sub dump2
+{
+ my $set = shift;
+ if (defined $set->{merged}) {
+ return "merged from ".dump2($set->{merged});
+ }
+ return join("/",
+ join(",", $set->newer_names),
+ join(",", $set->older_names),
+ join(",", $set->kept_names),
+ join(",", $set->hint_names));
+}
+
+sub dump
+{
+ return unless defined $s;
+ for my $l ('to_install', 'to_update') {
+ next unless defined $s->{$l};
+ print STDERR "$l:\n";
+ while (my ($k, $e) = each %{$s->{$l}}) {
+ print STDERR "\t$k => ", dump2($e), "\n";
+ }
+ }
+ for my $l ('uptodate', 'can_install', 'cant_update') {
+ next unless defined $s->{$l};
+ print STDERR "$l: ", join(' ', keys %{$s->{$l}}), "\n";
+ }
}
sub sets_todo