summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-11-11 12:32:04 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-11-11 12:32:04 +0000
commitdac9950a04ceb5cf20ea409d31c27659111aebb2 (patch)
treed983be8d3b6ef694f64856b4641376d0aad00dc1
parent63ddfd51ddaedc7390c3a7435bf25b80b16701d5 (diff)
don't use Warn if we've got a $state, get through errprint/errsay.
Also: reset lastdisplay on clear, and don't clear twice.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Add.pm12
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm10
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingElement.pm6
-rw-r--r--usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm4
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Replace.pm24
-rw-r--r--usr.sbin/pkg_add/OpenBSD/UpdateSet.pm4
-rw-r--r--usr.sbin/pkg_add/pkg_add10
7 files changed, 36 insertions, 34 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm
index c541c20fbc9..6ee8ac27a45 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.94 2009/11/11 12:21:20 espie Exp $
+# $OpenBSD: Add.pm,v 1.95 2009/11/11 12:32:03 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -232,11 +232,11 @@ sub prepare_for_addition
my ($self, $state, $pkgname) = @_;
if ($state->{cdrom_only} && $self->{cdrom} ne 'yes') {
- Warn "Package $pkgname is not for cdrom.\n";
+ $state->errsay("Package $pkgname is not for cdrom.");
$state->{problems}++;
}
if ($state->{ftp_only} && $self->{ftp} ne 'yes') {
- Warn "Package $pkgname is not for ftp.\n";
+ $state->errsay("Package $pkgname is not for ftp.");
$state->{problems}++;
}
}
@@ -266,8 +266,8 @@ sub prepare_for_addition
my $ok = $self->check;
if (defined $ok) {
if ($ok == 0) {
- Warn $self->type, " ", $self->name,
- " does not match\n";
+ $state->errsay($self->type, " ", $self->name,
+ " does not match");
$state->{problems}++;
}
}
@@ -524,7 +524,7 @@ sub install
$state->say("The file $filename would be installed from $origname");
} else {
if (!copy($origname, $filename)) {
- Warn "File $filename could not be installed:\n\t$!\n";
+ $state->errsay("File $filename could not be installed:\n\t$!");
}
$self->set_modes($filename);
if ($state->{verbose}) {
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index 98bf70dd56a..5bb6e0a48e2 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.83 2009/11/11 12:21:20 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.84 2009/11/11 12:32:03 espie Exp $
#
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
#
@@ -472,9 +472,9 @@ sub solve_wantlibs
next if $lib_finder->lookup($solver,
$solver->{to_register}->{$h}, $state,
$lib->{name});
- OpenBSD::Error::Warn "Can't install ",
+ $state->errsay("Can't install ",
$h->pkgname, ": lib not found ",
- $lib->{name}, "\n";
+ $lib->{name});
if ($okay) {
$solver->dump;
$lib_finder->dump;
@@ -497,9 +497,9 @@ sub solve_tags
for my $tag (keys %{$h->{plist}->{tags}}) {
next if $tag_finder->lookup($solver,
$solver->{to_register}->{$h}, $state, $tag);
- OpenBSD::Error::Warn "Can't install ",
+ $state->errsay("Can't install ",
$h->pkgname, ": tag definition not found ",
- $tag, "\n";
+ $tag);
if ($okay) {
$solver->dump;
$tag_finder->dump;
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
index a36379356cc..214c03342c2 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.160 2009/11/11 12:04:19 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.161 2009/11/11 12:32:03 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -1365,7 +1365,7 @@ sub run_if_exists
if (-x $cmd) {
OpenBSD::Error::VSystem($state->{very_verbose}, $cmd, @l);
} else {
- OpenBSD::Error::Warn("$cmd not found\n");
+ $state->errsay("$cmd not found");
}
}
@@ -1562,7 +1562,7 @@ sub prepare
$state->log($_);
}
} else {
- Warn "Can't open $fname: $!\n";
+ $state->errsay("Can't open $fname: $!");
}
}
diff --git a/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm b/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm
index 1cfdd285027..412c7da646a 100644
--- a/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm
+++ b/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: ProgressMeter.pm,v 1.15 2009/11/11 12:21:20 espie Exp $
+# $OpenBSD: ProgressMeter.pm,v 1.16 2009/11/11 12:32:03 espie Exp $
#
# Copyright (c) 2004-2007 Marc Espie <espie@openbsd.org>
#
@@ -131,7 +131,9 @@ sub clear
{
my $self = shift;
return unless $isatty;
+ return unless length($lastdisplay) > 0;
print ' 'x length($lastdisplay), "\r";
+ $lastdisplay = '';
}
sub print
diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm
index 2de93736369..b87f9c52192 100644
--- a/usr.sbin/pkg_add/OpenBSD/Replace.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Replace.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Replace.pm,v 1.53 2009/11/11 12:04:19 espie Exp $
+# $OpenBSD: Replace.pm,v 1.54 2009/11/11 12:32:03 espie Exp $
#
# Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org>
#
@@ -234,7 +234,7 @@ sub validate_depend
return if $self->spec->filter($replacement);
if ($state->{defines}->{updatedepends}) {
- Warn "Forward dependency of $wanting on $toreplace doesn't match $replacement, forcing it\n";
+ $state->errsay("Forward dependency of $wanting on $toreplace doesn't match $replacement, forcing it");
$state->{forcedupdates} = {} unless defined $state->{forcedupdates};
$state->{forcedupdates}->{$wanting} = 1;
} elsif ($state->{interactive}) {
@@ -247,7 +247,7 @@ sub validate_depend
}
} else {
$state->{okay} = 0;
- Warn "Can't update forward dependency of $wanting on $toreplace: $replacement doesn't match (use -F updatedepends to force it)\n";
+ $state->errsay("Can't update forward dependency of $wanting on $toreplace: $replacement doesn't match (use -F updatedepends to force it)");
}
}
@@ -316,13 +316,13 @@ sub can_old_package_be_replaced
$state->{journal} = [];
$old_plist->can_update(0, $state);
if ($state->{okay} == 0) {
- Warn "Old package ", $old_plist->pkgname,
- " contains potentially unsafe operations\n";
+ $state->errsay("Old package ", $old_plist->pkgname,
+ " contains potentially unsafe operations");
for my $i (@{$state->{journal}}) {
- Warn "\t$i\n";
+ $state->errsay("\t", $i);
}
if ($state->{defines}->{update}) {
- Warn "(forcing update)\n";
+ $state->errsay("(forcing update)");
$state->{okay} = 1;
} elsif ($state->{interactive}) {
@@ -343,7 +343,7 @@ sub can_old_package_be_replaced
my $p2 = OpenBSD::PackingList->from_installation(
$wanting, \&OpenBSD::PackingList::DependOnly);
if (!defined $p2) {
- Warn "Error: $wanting missing from installation\n"
+ $state->errsay("Error: $wanting missing from installation");
} else {
$p2->validate_depend($state, $wanting,
$old_plist->pkgname, $new_pkgname);
@@ -360,13 +360,13 @@ sub is_new_package_safe
$state->{journal} = [];
$plist->can_update(1, $state);
if ($state->{okay} == 0) {
- Warn "New package ", $plist->pkgname,
- " contains potentially unsafe operations\n";
+ $state->errsay("New package ", $plist->pkgname,
+ " contains potentially unsafe operations");
for my $i (@{$state->{journal}}) {
- Warn "\t$i\n";
+ $state->errsay("\t", $i);
}
if ($state->{defines}->{update}) {
- Warn "(forcing update)\n";
+ $state->errsay("(forcing update)");
$state->{okay} = 1;
} elsif ($state->{interactive}) {
if (OpenBSD::Interactive::confirm("proceed with update anyways", 1, 0, 'update')) {
diff --git a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
index 6502274f7d1..e400f06a115 100644
--- a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
+++ b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: UpdateSet.pm,v 1.20 2009/11/11 12:21:20 espie Exp $
+# $OpenBSD: UpdateSet.pm,v 1.21 2009/11/11 12:32:03 espie Exp $
#
# Copyright (c) 2007 Marc Espie <espie@openbsd.org>
#
@@ -139,7 +139,7 @@ sub check_root
my $state = shift;
if ($< && !$state->{defines}->{nonroot}) {
if ($state->{not}) {
- Warn "$0 should be run as root\n";
+ $state->errsay("$0 should be run as root");
} else {
Fatal "$0 must be run as root";
}
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index ccfeeeb3c6d..00d47a07185 100644
--- a/usr.sbin/pkg_add/pkg_add
+++ b/usr.sbin/pkg_add/pkg_add
@@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_add,v 1.378 2009/11/11 12:21:20 espie Exp $
+# $OpenBSD: pkg_add,v 1.379 2009/11/11 12:32:03 espie Exp $
#
# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org>
#
@@ -229,7 +229,7 @@ sub can_install
for my $toreplace (@conflicts) {
if ($state->tracker->is_installed($toreplace)) {
- Warn "Cannot replace $toreplace with $pkgname: just got installed\n";
+ $state->errsay("Cannot replace $toreplace with $pkgname: just got installed");
$handle->set_error(OpenBSD::Handle::CANT_INSTALL);
return;
}
@@ -370,7 +370,7 @@ sub really_add
$state);
} catchall {
unless ($state->{interrupted}) {
- Warn $_;
+ $state->errprint($_);
$errors++;
}
};
@@ -390,7 +390,7 @@ sub really_add
try {
OpenBSD::Delete::delete_plist($o->plist, $state);
} catchall {
- Warn $_;
+ $state->errprint($_);
Fatal partial_install(
"Deinstallation of $oldname failed",
$set, $state);
@@ -420,7 +420,7 @@ sub really_add
}
} catchall {
unless ($state->{interrupted}) {
- Warn $_;
+ $state->errprint($_);
$errors++;
}
};