summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2010-12-13 12:13:55 +0000
committerMarc Espie <espie@cvs.openbsd.org>2010-12-13 12:13:55 +0000
commitcf762c384f9d2ce8931c52fc78f6180c03524040 (patch)
tree57cebc69fada81595120f82104faee9ed5e2aab7
parent7464352578e1b479dc6f3372b023428b892dd3da (diff)
pass state around and use state->print
inspired by landry@
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Delete.pm12
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm29
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgAdd.pm4
3 files changed, 22 insertions, 23 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm
index 24b6ad7ec98..cf343c80880 100644
--- a/usr.sbin/pkg_add/OpenBSD/Delete.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Delete.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Delete.pm,v 1.109 2010/10/27 14:35:56 espie Exp $
+# $OpenBSD: Delete.pm,v 1.110 2010/12/13 12:13:54 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -92,7 +92,7 @@ sub remove_packing_info
sub delete_package
{
my ($pkgname, $state) = @_;
- $state->progress->message("reading plist");
+ $state->progress->message($state->f("reading list for #1", $pkgname));
my $plist = OpenBSD::PackingList->from_installation($pkgname) or
$state->fatal("bad package #1", $pkgname);
if (!defined $plist->pkgname) {
@@ -176,7 +176,7 @@ package OpenBSD::PackingElement;
sub rename_file_to_temp
{
- my $self = shift;
+ my ($self, $state) = @_;
require OpenBSD::Temp;
my $n = $self->fullname;
@@ -184,14 +184,14 @@ sub rename_file_to_temp
my ($fh, $j) = OpenBSD::Temp::permanent_file(undef, $n);
close $fh;
if (rename($n, $j)) {
- print "Renaming old file $n to $j\n";
+ $state->say("Renaming old file #1 to #2", $n, $j);
if ($self->name !~ m/^\//o && $self->cwd ne '.') {
my $c = $self->cwd;
$j =~ s|^\Q$c\E/||;
}
$self->set_name($j);
} else {
- print "Bad rename $n to $j: $!\n";
+ $state->errsay("Bad rename #1 to #2: #", $n, $j, $!);
}
}
@@ -445,7 +445,7 @@ sub copy_old_stuff
if (defined $self->{stillaround}) {
delete $self->{stillaround};
if ($state->{replacing}) {
- $self->rename_file_to_temp;
+ $self->rename_file_to_temp($state);
}
$self->add_object($plist);
}
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index 6e77c596408..61801fcc014 100644
--- a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Dependencies.pm,v 1.137 2010/11/27 11:58:12 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.138 2010/12/13 12:13:54 espie Exp $
#
# Copyright (c) 2005-2010 Marc Espie <espie@openbsd.org>
#
@@ -68,11 +68,11 @@ sub new
sub dump
{
- my $self = shift;
+ my ($self, $state) = @_;
return unless %{$self->{done}};
- print "Full dependency tree is ", join(' ', keys %{$self->{done}}),
- "\n";
+ $state->say("Full dependency tree is #1",
+ join(' ', keys %{$self->{done}}));
}
package OpenBSD::lookup::library;
@@ -613,15 +613,14 @@ sub check_depends
sub dump
{
- my $self = shift;
+ my ($self, $state) = @_;
if ($self->dependencies) {
- print "Direct dependencies for ", $self->{set}->print,
- " resolve to: ", join(' ', $self->dependencies);
- print " (todo: ",
- join(' ', (map {$_->print} values %{$self->{deplist}})),
- ")"
+ $state->print("Direct dependencies for #1 resolve to #2",
+ $self->{set}->print, join(' ', $self->dependencies));
+ $state->print(" (todo: #1)",
+ join(' ', (map {$_->print} values %{$self->{deplist}})))
if %{$self->{deplist}};
- print "\n";
+ $state->print("\n");
}
}
@@ -705,8 +704,8 @@ sub solve_wantlibs
}
}
if (!$okay) {
- $solver->dump;
- $lib_finder->dump;
+ $solver->dump($state);
+ $lib_finder->dump($state);
}
return $okay;
}
@@ -724,8 +723,8 @@ sub solve_tags
$state->errsay("Can't install #1: tag definition not found #2",
$h->pkgname, $tag);
if ($okay) {
- $solver->dump;
- $tag_finder->dump;
+ $solver->dump($state);
+ $tag_finder->dump($state);
$okay = 0;
}
}
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm
index 76b1ded8f88..3189952dbe5 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm
@@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgAdd.pm,v 1.16 2010/10/02 13:36:56 espie Exp $
+# $OpenBSD: PkgAdd.pm,v 1.17 2010/12/13 12:13:54 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -878,7 +878,7 @@ sub install_set
my @deps = $set->solver->solve_depends($state);
if ($state->verbose >= 2) {
- $set->solver->dump;
+ $set->solver->dump($state);
}
if (@deps > 0) {
$state->build_deptree($set, @deps);