diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2010-06-15 08:26:40 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2010-06-15 08:26:40 +0000 |
commit | e9543a25f760416cd896f98c7a8e9ebb72b0f956 (patch) | |
tree | 790547109c666da81ad863b3d1f2607918730f05 /usr.sbin/pkg_add/OpenBSD/AddDelete.pm | |
parent | dc2af675bfd1f4eb14a47aa97b59c8b92d6e5419 (diff) |
more printing changes.
move log operations into their own file, since they're used outside of
pkg_add/pkg_delete by pkg_check.
move all system stuff to State, so that printing can be localized/controlled.
Create primitives _print, _errprint, _fatal for overriding output, without
localization.
Accordingly, move a lot of code out of Error. We should also move Unlink and
Copy eventually.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/AddDelete.pm')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/AddDelete.pm | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm index 7c6b695ad4b..3f8f03991dc 100644 --- a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm +++ b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: AddDelete.pm,v 1.25 2010/06/09 08:13:19 espie Exp $ +# $OpenBSD: AddDelete.pm,v 1.26 2010/06/15 08:26:39 espie Exp $ # # Copyright (c) 2007-2010 Marc Espie <espie@openbsd.org> # @@ -152,30 +152,15 @@ sub cleanup OpenBSD::SharedItems::cleanup($self, $state); } -package OpenBSD::Log; -use OpenBSD::Error; -our @ISA = qw(OpenBSD::Error); - -sub set_context -{ - &OpenBSD::Error::set_pkgname; -} - -sub dump -{ - &OpenBSD::Error::delayed_output; -} - - package OpenBSD::AddDelete::State; -use OpenBSD::Error; use OpenBSD::Vstat; +use OpenBSD::Log; our @ISA = qw(OpenBSD::AddCreateDelete::State); sub init { my $self = shift; - $self->{l} = OpenBSD::Log->new; + $self->{l} = OpenBSD::Log->new($self); $self->{vstat} = OpenBSD::Vstat->new($self); $self->{status} = OpenBSD::Status->new; $self->{recorder} = OpenBSD::SharedItemsRecorder->new; @@ -209,29 +194,32 @@ sub log if (@_ == 0) { return $self->{l}; } else { - $self->{l}->print($self->f(@_), "\n"); + $self->{l}->say(@_); } } sub vsystem { my $self = shift; - $self->progress->clear; - OpenBSD::Error::VSystem($self->verbose >= 2, @_); + my $verbose = $self; + if ($self->verbose < 2) { + $self->system(@_); + } else { + $self->print("Running #1", join(' ', @_)); + my $r = CORE::system(@_); + if ($r != 0) { + $self->say("... failed: #1", $self->child_error); + } else { + $self->say; + } + } } sub system { my $self = shift; $self->progress->clear; - OpenBSD::Error::System(@_); -} - -sub unlink -{ - my $self = shift; - $self->progress->clear; - OpenBSD::Error::Unlink(@_); + $self->SUPER::system(@_); } sub check_root |