diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2009-11-11 12:04:20 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2009-11-11 12:04:20 +0000 |
commit | 1c829fb0f939d9417b3b16b2637885a826516516 (patch) | |
tree | d82a0ae2dc06d00f975cfffd14a8c576d7e2fb8e /usr.sbin/pkg_add/OpenBSD | |
parent | bdb3c585ad77981c01fa06d17090eac21f6cd3c1 (diff) |
progressmeter puts STDOUT in autoflush if -t, so that it can display to it instead of piping a lot of stuff to STDERR.
Go through state->print for most messages, so they will NOT do weird things
with the progressmeter.
Use a ->say shortcut which does the same thing that perl 5.10 say does...
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Add.pm | 38 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/CollisionReport.pm | 30 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Delete.pm | 51 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Dependencies.pm | 25 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Handle.pm | 19 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageInfo.pm | 7 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 13 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm | 21 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Replace.pm | 29 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Update.pm | 16 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/UpdateSet.pm | 15 |
11 files changed, 143 insertions, 121 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index 76124a59aef..3f2af49af53 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.92 2009/11/11 11:13:16 espie Exp $ +# $OpenBSD: Add.pm,v 1.93 2009/11/11 12:04:19 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -35,7 +35,7 @@ sub manpages_index while (my ($k, $v) = each %{$state->{mandirs}}) { my @l = map { $destdir.$_ } @$v; if ($state->{not}) { - print "Merging manpages in $destdir$k: ", join(@l), "\n" if $state->{verbose}; + $state->say("Merging manpages in $destdir$k: ", join(@l)) if $state->{verbose}; } else { try { OpenBSD::Makewhatis::merge($destdir.$k, \@l); @@ -82,8 +82,9 @@ sub record_partial_installation my $lastname = $last->realname($state); $last->{d} = $last->compute_digest($lastname, $old); if (!$old->equals($last->{d})) { - print "Adjusting ", $old->keyword, " for $lastname from ", - $old->stringize, " to ", $last->{d}->stringize, "\n"; + $state->say("Adjusting ", $old->keyword, + " for $lastname from ", $old->stringize, + " to ", $last->{d}->stringize); } } register_installation($n); @@ -278,7 +279,7 @@ sub install my ($self, $state) = @_; $self->SUPER::install($state); my $auth = $self->name; - print "adding ", $self->type, " $auth\n" if $state->{verbose}; + $state->say("adding ", $self->type, " ", $auth) if $state->{verbose}; return if $state->{not}; return if defined $self->{okay}; my $l=[]; @@ -334,8 +335,7 @@ sub install return; } if ($state->{not}) { - print "sysctl -w $name != ". - $self->{value}, "\n"; + $state->say("sysctl -w $name != ". $self->{value}); return; } VSystem($state->{very_verbose}, @@ -385,7 +385,7 @@ sub install if ($state->{replacing}) { if ($state->{not}) { - print "moving tempfile -> $destdir$fullname\n" if $state->{very_verbose}; + $state->say("moving tempfile -> $destdir$fullname") if $state->{very_verbose}; return; } File::Path::mkpath(dirname($destdir.$fullname)); @@ -396,13 +396,13 @@ sub install } else { rename($self->{tempname}, $destdir.$fullname) or Fatal "Can't move ", $self->{tempname}, " to $fullname: $!"; - print "moving ", $self->{tempname}, " -> $destdir$fullname\n" if $state->{very_verbose}; + $state->say("moving ", $self->{tempname}, " -> $destdir$fullname") if $state->{very_verbose}; undef $self->{tempname}; } } else { my $file = $self->prepare_to_extract($state); - print "extracting $destdir$fullname\n" if $state->{very_verbose}; + $state->say("extracting $destdir$fullname") if $state->{very_verbose}; if ($state->{not}) { $state->{archive}->skip; return; @@ -506,29 +506,29 @@ sub install my $origname = $destdir.$orig->fullname; if (-e $filename) { if ($state->{verbose}) { - print "The existing file $filename has NOT been changed\n"; + $state->say("The existing file $filename has NOT been changed"); if (defined $orig->{d}) { # XXX assume this would be the same type of file my $d = $self->compute_digest($filename, $orig->{d}); if ($d->equals($orig->{d})) { - print "(but it seems to match the sample file $origname)\n"; + $state->say("(but it seems to match the sample file $origname)"); } else { - print "It does NOT match the sample file $origname\n"; - print "You may wish to update it manually\n"; + $state->say("It does NOT match the sample file $origname"); + $state->say("You may wish to update it manually"); } } } } else { if ($state->{not}) { - print "The file $filename would be installed from $origname\n"; + $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"; } $self->set_modes($filename); if ($state->{verbose}) { - print "installed $filename from $origname\n"; + $state->say("installed $filename from $origname"); } } } @@ -593,8 +593,8 @@ sub install open(my $shells2, '>>', $destdir.OpenBSD::Paths->shells) or return; print $shells2 $fullname, "\n"; close $shells2; - print "Shell $fullname appended to $destdir", - OpenBSD::Paths->shells, "\n"; + $state->say("Shell $fullname appended to $destdir", + OpenBSD::Paths->shells); } package OpenBSD::PackingElement::Dir; @@ -605,7 +605,7 @@ sub install my $fullname = $self->fullname; my $destdir = $state->{destdir}; - print "new directory ", $destdir, $fullname, "\n" if $state->{very_verbose}; + $state->say("new directory ", $destdir, $fullname) if $state->{very_verbose}; return if $state->{not}; File::Path::mkpath($destdir.$fullname); $self->set_modes($destdir.$fullname); diff --git a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm index 6bb9d1dd501..45d80da0086 100644 --- a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm +++ b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: CollisionReport.pm,v 1.20 2009/11/10 11:36:56 espie Exp $ +# $OpenBSD: CollisionReport.pm,v 1.21 2009/11/11 12:04:19 espie Exp $ # # Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org> # @@ -41,7 +41,7 @@ sub find_collisions return $bypkg; } for my $pkg (installed_packages()) { - print "Looking for collisions in $pkg\n" if $verbose; + $state->say("Looking for collisions in $pkg") if $verbose; my $plist = OpenBSD::PackingList->from_installation($pkg, \&OpenBSD::PackingList::FilesOnly); next if !defined $plist; @@ -74,13 +74,13 @@ sub collision_report($$) my $clueless_bat2; my $found = 0; - print "Collision: the following files already exist\n"; + $state->say("Collision: the following files already exist"); if (!$state->{defines}->{dontfindcollisions}) { my $bypkg = find_collisions(\%todo, $state->{verbose}); for my $pkg (sort keys %$bypkg) { for my $item (sort @{$bypkg->{$pkg}}) { $found++; - print "\t$item ($pkg)\n"; + $state->say("\t$item ($pkg)"); } if ($pkg =~ m/^(?:partial\-|borked\.\d+$)/o) { $clueless_bat = $pkg; @@ -98,26 +98,26 @@ sub collision_report($$) my $old = $todo{$item}; my $d = $old->new($destdir.$item); if ($d->equals($old)) { - print "\t$item (same checksum)\n"; + $state->say("\t$item (same checksum)"); } else { - print "\t$item (different checksum)\n"; + $state->say("\t$item (different checksum)"); } } else { - print "\t$item\n"; + $state->say("\t$item"); } } } if (defined $clueless_bat) { - print "The package name $clueless_bat suggests that a former installation\n"; - print "of a similar package got interrupted. It is likely that\n"; - print "\tpkg_delete $clueless_bat\n"; - print "will solve the problem\n"; + $state->print("The package name $clueless_bat suggests that a former installation\n", + "of a similar package got interrupted. It is likely that\n", + "\tpkg_delete $clueless_bat\n", + "will solve the problem\n"); } if (defined $clueless_bat2) { - print "The package name $clueless_bat2 suggests remaining libraries\n"; - print "from a former package update. It is likely that\n"; - print "\tpkg_delete $clueless_bat2\n"; - print "will solve the problem\n"; + $state->print("The package name $clueless_bat2 suggests remaining libraries\n", + "from a former package update. It is likely that\n", + "\tpkg_delete $clueless_bat2\n". + "will solve the problem\n"); } my $dorepair = 0; if ($found == 0) { diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm index 0413453e158..bd66c3b2e18 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.84 2009/11/11 11:13:16 espie Exp $ +# $OpenBSD: Delete.pm,v 1.85 2009/11/11 12:04:19 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -50,7 +50,7 @@ sub manpages_unindex while (my ($k, $v) = each %{$state->{mandirs}}) { my @l = map { $destdir.$_ } @$v; if ($state->{not}) { - print "Removing manpages in $destdir$k: ", join(@l), "\n" if $state->{verbose}; + $state->say("Removing manpages in $destdir$k: ", join(@l)) if $state->{verbose}; } else { eval { OpenBSD::Makewhatis::remove($destdir.$k, \@l); }; if ($@) { @@ -126,7 +126,7 @@ sub unregister_dependencies my $pkgname = $plist->pkgname; for my $name (OpenBSD::Requiring->new($pkgname)->list) { - print "remove dependency on $name\n" + $state->say("remove dependency on $name") if $state->{very_verbose} or $state->{not}; local $@; try { @@ -278,7 +278,7 @@ sub delete my ($self, $state) = @_; if ($state->{beverbose}) { - print "rmuser: ", $self->name, "\n"; + $state->say("rmuser: ", $self->name); } $self->record_shared($state->{recorder}, $state->{pkgname}); @@ -296,7 +296,7 @@ sub delete my ($self, $state) = @_; if ($state->{beverbose}) { - print "rmgroup: ", $self->name, "\n"; + $state->say("rmgroup: ", $self->name); } $self->record_shared($state->{recorder}, $state->{pkgname}); @@ -321,7 +321,7 @@ sub delete my ($self, $state) = @_; if ($state->{very_verbose}) { - print "rmdir: ", $self->fullname, "\n"; + $state->say("rmdir: ", $self->fullname); } $self->record_shared($state->{recorder}, $state->{pkgname}); @@ -384,38 +384,39 @@ sub delete if (-l $realname) { my $contents = readlink $realname; if ($contents ne $self->{symlink}) { - print "Symlink does not match: $realname ($contents vs. ", $self->{symlink},")\n"; + $state->say("Symlink does not match: $realname ($contents vs. ", $self->{symlink},")"); $self->do_not_delete($state); return; } } else { - print "Bogus symlink: $realname\n"; + $state->say("Bogus symlink: $realname"); $self->do_not_delete($state); return; } } else { if (-l $realname) { - print "Unexpected symlink: $realname\n"; + $state->say("Unexpected symlink: $realname"); $self->do_not_delete($state); } else { if (! -f $realname) { - print "File $realname does not exist\n"; + $state->say("File $realname does not exist"); return; } unless (defined($self->{link}) or $self->{nochecksum} or $state->{quick}) { if (!defined $self->{d}) { - print "Problem: ", $self->fullname, - " does not have a checksum\n"; - print "NOT deleting: $realname\n"; + $state->say("Problem: ", + $self->fullname, + " does not have a checksum\n", + "NOT deleting: $realname"); $state->log("Couldn't delete $realname (no checksum)\n"); return; } my $d = $self->compute_digest($realname, $self->{d}); if (!$d->equals($self->{d})) { - print "Problem: checksum doesn't match for ", - $self->fullname, "\n"; - print "NOT deleting: $realname\n"; + $state->say("Problem: checksum doesn't match for ", + $self->fullname, "\n", + "NOT deleting: $realname"); $state->log("Couldn't delete $realname (bad checksum)\n"); $self->do_not_delete($state); return; @@ -424,11 +425,11 @@ sub delete } } if ($state->{very_verbose}) { - print "deleting: $realname\n"; + $state->say("deleting: $realname"); } return if $state->{not}; if (!unlink $realname) { - print "Problem deleting $realname\n"; + $state->say("Problem deleting $realname"); $state->log("deleting $realname failed: $!\n"); } } @@ -532,7 +533,7 @@ sub delete } else { my $d = $self->compute_digest($realname, $orig->{d}); if ($d->equals($orig->{d})) { - print "File $realname identical to sample\n" if $state->{not} or $state->{verbose}; + $state->say("File $realname identical to sample") if $state->{not} or $state->{verbose}; } else { unless ($state->{extra}) { $self->mark_dir($state); @@ -542,9 +543,9 @@ sub delete } } return if $state->{not}; - print "deleting $realname\n" if $state->{verbose}; + $state->say("deleting $realname") if $state->{verbose}; if (!unlink $realname) { - print "Problem deleting $realname\n"; + $state->say("Problem deleting $realname"); $state->log("deleting $realname failed: $!\n"); } } @@ -586,8 +587,8 @@ sub delete open(my $shells2, '>', $destdir.OpenBSD::Paths->shells); print $shells2 @l; close $shells2; - print "Shell $fullname removed from $destdir", - OpenBSD::Paths->shells, "\n"; + $state->say("Shell $fullname removed from $destdir", + OpenBSD::Paths->shells); } } $self->SUPER::delete($state); @@ -601,7 +602,7 @@ sub delete my ($self, $state) = @_; my $realname = $self->realname($state); if ($state->{beverbose} && $state->{extra}) { - print "deleting extra file: $realname\n"; + $state->say("deleting extra file: $realname"); } return if $state->{not}; return unless -e $realname or -l $realname; @@ -610,7 +611,7 @@ sub delete $self->mark_dir($state); } elsif ($state->{extra}) { unlink($realname) or - print "problem deleting extra file $realname\n"; + $state->say("problem deleting extra file $realname"); } else { $state->log("You should also remove $realname\n"); $self->mark_dir($state); diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm index 3d26a0c216a..56d52dfbb8e 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.81 2009/11/10 11:36:56 espie Exp $ +# $OpenBSD: Dependencies.pm,v 1.82 2009/11/11 12:04:19 espie Exp $ # # Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org> # @@ -86,7 +86,8 @@ sub find_in_already_done my $r = $solver->check_lib_spec($solver->{localbase}, $obj, $self->{known}); if ($r) { - print "found libspec $obj in package $r\n" if $state->{verbose}; + $state->say("found libspec $obj in package $r") + if $state->{verbose}; return $r; } else { return undef; @@ -101,7 +102,8 @@ sub find_in_extra_sources OpenBSD::SharedLibs::add_libs_from_system($state->{destdir}); for my $dir (OpenBSD::SharedLibs::system_dirs()) { if ($solver->check_lib_spec($dir, $obj, {system => 1})) { - print "found libspec $obj in $dir/lib\n" if $state->{verbose}; + $state->say("found libspec $obj in $dir/lib") + if $state->{verbose}; return 'system'; } } @@ -114,7 +116,8 @@ sub find_in_new_source OpenBSD::SharedLibs::add_libs_from_installed_package($dep); if ($solver->check_lib_spec($solver->{localbase}, $obj, {$dep => 1})) { - print "found libspec $obj in package $dep\n" if $state->{verbose}; + $state->say("found libspec $obj in package $dep") + if $state->{verbose}; return $dep; } return undef; @@ -129,7 +132,8 @@ sub find_elsewhere my $r = $solver->find_old_lib($state, $solver->{localbase}, $dep->{pattern}, $obj); if ($r) { - print "found libspec $obj in old package $r\n" if $state->{verbose}; + $state->say("found libspec $obj in old package $r") + if $state->{verbose}; return $r; } } @@ -152,7 +156,7 @@ sub find_in_already_done my ($self, $solver, $state, $obj) = @_; my $r = $self->{known_tags}->{$obj}; if (defined $r) { - print "Found tag $obj in $r\n" if $state->{verbose}; + $state->say("Found tag $obj in $r") if $state->{verbose}; } return $r; } @@ -392,16 +396,17 @@ sub adjust_old_dependencies my $oldname = $o->pkgname; - print "Adjusting dependencies for $pkgname/$oldname\n" - if $state->{beverbose}; + $state->say("Adjusting dependencies for ", + "$pkgname/$oldname") if $state->{beverbose}; my $d = OpenBSD::RequiredBy->new($pkgname); for my $dep (@{$o->{wantlist}}) { if (defined $self->{set}->{skipupdatedeps}->{$dep}) { - print "\tskipping $dep\n" + $state->say("\tskipping $dep") if $state->{beverbose}; next; } - print "\t$dep\n" if $state->{beverbose}; + $state->say("\t$dep") + if $state->{beverbose}; $d->add($dep); OpenBSD::Replace::adjust_dependency($dep, $oldname, $pkgname); diff --git a/usr.sbin/pkg_add/OpenBSD/Handle.pm b/usr.sbin/pkg_add/OpenBSD/Handle.pm index 64fd15014da..96006cf07b9 100644 --- a/usr.sbin/pkg_add/OpenBSD/Handle.pm +++ b/usr.sbin/pkg_add/OpenBSD/Handle.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Handle.pm,v 1.10 2009/11/10 11:36:56 espie Exp $ +# $OpenBSD: Handle.pm,v 1.11 2009/11/11 12:04:19 espie Exp $ # # Copyright (c) 2007-2009 Marc Espie <espie@openbsd.org> # @@ -170,19 +170,18 @@ sub get_plist my $pkg = $handle->pkgname; if ($state->{verbose}) { - print $state->deptree_header($pkg); - print "parsing $pkg\n"; + $state->say($state->deptree_header($pkg), "parsing $pkg"); } my $plist = $location->grabPlist; unless (defined $plist) { - print "Can't find CONTENTS from ", $location->url, "\n"; + $state->say("Can't find CONTENTS from ", $location->url); $location->close_with_client_error; $location->wipe_info; $handle->set_error(BAD_PACKAGE); return; } if ($plist->localbase ne $state->{localbase}) { - print "Localbase mismatch: package has: ", $plist->localbase, " , user wants: ", $state->{localbase}, "\n"; + $state->say("Localbase mismatch: package has: ", $plist->localbase, " , user wants: ", $state->{localbase}); $location->close_with_client_error; $location->wipe_info; $handle->set_error(BAD_PACKAGE); @@ -197,8 +196,8 @@ sub get_plist !$plist->uses_old_libs)) { $handle->{tweaked} = OpenBSD::Add::tweak_package_status($pkgname, $state); - print "Not reinstalling $pkgname\n" if $state->{verbose} and - !$handle->{tweaked}; + $state->say("Not reinstalling $pkgname") + if $state->{verbose} and !$handle->{tweaked}; $state->tracker->{installed}->{$pkgname} = 1; $location->close_now; $location->wipe_info; @@ -207,7 +206,7 @@ sub get_plist } if ($pkg ne '-') { if (!defined $pkgname or $pkg ne $pkgname) { - print "Package name is not consistent ???\n"; + $state->say("Package name is not consistent ???"); $location->close_with_client_error; $location->wipe_info; $handle->set_error(BAD_PACKAGE); @@ -225,13 +224,13 @@ sub get_location my $location = OpenBSD::PackageLocator->find($name, $state->{arch}); if (!$location) { - print $state->deptree_header($name); + $state->print($state->deptree_header($name)); $handle->set_error(NOT_FOUND); $handle->{tweaked} = OpenBSD::Add::tweak_package_status($handle->pkgname, $state); if (!$handle->{tweaked}) { - print "Can't find $name\n"; + $state->say("Can't find $name"); } return; } diff --git a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm index 2bec8fb57e6..ac939502304 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageInfo.pm,v 1.42 2009/11/11 11:18:24 espie Exp $ +# $OpenBSD: PackageInfo.pm,v 1.43 2009/11/11 12:04:19 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -256,8 +256,9 @@ sub solve_installed_names if ($state->{defines}->{ambiguous}) { my @l = map {$_->name} @$r; - $state->print("Ambiguous: $pkgname could be ", join(' ', @l),"\n"); - print "$msg\n"; + $state->say("Ambiguous: $pkgname could be ", + join(' ', @l)); + $state->say($msg); push(@$new, @l); for my $p (@$r) { $seen->{$p} = 1; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 1ba458ee1d0..a36379356cc 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.159 2009/11/11 11:13:16 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.160 2009/11/11 12:04:19 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -410,7 +410,7 @@ sub check_digest " does not match"); } if ($state->{very_verbose}) { - print "Checksum match for ", $self->fullname, "\n"; + $state->say("Checksum match for ", $self->fullname); } } @@ -1195,7 +1195,8 @@ sub run my ($self, $state) = @_; OpenBSD::PackingElement::Lib::ensure_ldconfig($state); - print $self->keyword, " ", $self->{expanded}, "\n" if $state->{beverbose}; + $state->say($self->keyword, " ", $self->{expanded}) + if $state->{beverbose}; $state->system(OpenBSD::Paths->sh, '-c', $self->{expanded}) unless $state->{not}; } @@ -1376,7 +1377,8 @@ sub finish_fontdirs require OpenBSD::Error; map { update_fontalias($_) } @l unless $state->{not}; - print "You may wish to update your font path for ", join(' ', @l), "\n"; + $state->say("You may wish to update your font path for ", + join(' ', @l)); return if $state->{not}; run_if_exists($state, OpenBSD::Paths->mkfontscale, @l); run_if_exists($state, OpenBSD::Paths->mkfontdir, @l); @@ -1508,7 +1510,8 @@ sub run return if $state->{dont_run_scripts}; OpenBSD::PackingElement::Lib::ensure_ldconfig($state); - print $self->beautify, " script: $name $pkgname ", join(' ', @args), "\n" if $state->{beverbose}; + $state->say($self->beautify, " script: $name $pkgname ", + join(' ', @args)) if $state->{beverbose}; return if $not; chmod 0755, $name; return if $state->system($name, $pkgname, @args) == 0; diff --git a/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm b/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm index 2543feb63f4..e70984071c4 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.13 2009/11/10 11:36:56 espie Exp $ +# $OpenBSD: ProgressMeter.pm,v 1.14 2009/11/11 12:04:19 espie Exp $ # # Copyright (c) 2004-2007 Marc Espie <espie@openbsd.org> # @@ -34,7 +34,12 @@ our %sizeof; sub new { my $class = shift; - $isatty = -t STDERR; + $isatty = -t STDOUT; + if ($isatty) { + my $oldfh = select(STDOUT); + $| = 1; + select($oldfh); + } return bless {}, $class; } @@ -47,7 +52,7 @@ sub find_window_size $sizeof{'struct winsize'} = 8; require 'sys/ttycom.ph'; $width = 80; - if (ioctl(STDERR, &TIOCGWINSZ, $r)) { + if (ioctl(STDOUT, &TIOCGWINSZ, $r)) { my ($rows, $cols, $xpix, $ypix) = unpack($wsz_format, $r); $width = $cols; @@ -100,7 +105,7 @@ sub message return if $d eq $lastdisplay && !$continued; $lastdisplay=$d; $continued = 0; - print STDERR $d, "\r"; + print $d, "\r"; } sub show @@ -119,20 +124,20 @@ sub show } return if $d eq $lastdisplay; $lastdisplay=$d; - print STDERR $d, "\r"; + print $d, "\r"; } sub clear { my $self = shift; return unless $isatty; - print STDERR ' 'x length($lastdisplay), "\r"; + print ' 'x length($lastdisplay), "\r"; } sub print { shift->clear; - print STDERR @_; + print @_; } sub next @@ -140,7 +145,7 @@ sub next my $self = shift; return unless $isatty; $self->clear; - print STDERR"$header: complete\n"; + print "$header: complete\n"; } 1; diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm index d0adb8e56e1..2de93736369 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.52 2009/11/10 11:36:56 espie Exp $ +# $OpenBSD: Replace.pm,v 1.53 2009/11/11 12:04:19 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org> # @@ -116,7 +116,8 @@ sub extract $d = dirname($d); } if ($state->{not}) { - print "extracting tempfile under $d\n" if $state->{very_verbose}; + $state->say("extracting tempfile under $d") + if $state->{very_verbose}; $state->{archive}->skip; } else { if (!-e _) { @@ -124,7 +125,7 @@ sub extract } my ($fh, $tempname) = OpenBSD::Temp::permanent_file($d, "pkg"); - print "extracting $tempname\n" if $state->{very_verbose}; + $state->say("extracting $tempname") if $state->{very_verbose}; $self->{tempname} = $tempname; # XXX don't apply destdir twice @@ -144,7 +145,8 @@ sub extract return if -e $destdir.$fullname; $self->SUPER::extract($state); - print "new directory ", $destdir, $fullname, "\n" if $state->{very_verbose}; + $state->say("new directory ", $destdir, $fullname) + if $state->{very_verbose}; return if $state->{not}; File::Path::mkpath($destdir.$fullname); } @@ -335,8 +337,8 @@ sub can_old_package_be_replaced push(@r, $wanting) if !defined $ignore->{$wanting}; } if (@r) { - print "Verifying dependencies still match for ", - join(', ', @r), "\n" if $state->{verbose}; + $state->say("Verifying dependencies still match for ", + join(', ', @r)) if $state->{verbose}; for my $wanting (@wantlist) { my $p2 = OpenBSD::PackingList->from_installation( $wanting, \&OpenBSD::PackingList::DependOnly); @@ -413,12 +415,12 @@ sub adjust_depends_closure { my ($oldname, $plist, $state) = @_; - print "Packages that depend on those shared libraries:\n" + $state->say("Packages that depend on those shared libraries:") if $state->{beverbose}; my $write = OpenBSD::RequiredBy->new($plist->pkgname); for my $pkg (OpenBSD::RequiredBy->compute_closure($oldname)) { - print "\t$pkg\n" if $state->{beverbose}; + $state->say("\t", $pkg) if $state->{beverbose}; $write->add($pkg); OpenBSD::Requiring->new($pkg)->add($plist->pkgname); } @@ -435,7 +437,7 @@ sub save_old_libraries my $libs = {}; my $p = {}; - print "Looking for changes in shared libraries\n" + $state->say("Looking for changes in shared libraries") if $state->{beverbose}; $o->{plist}->mark_lib($libs, $p); for my $n ($set->newer) { @@ -443,12 +445,14 @@ sub save_old_libraries } if (%$libs) { - print "Libraries to keep: ", join(",", sort(keys %$libs)), "\n" + $state->say("Libraries to keep: ", + join(",", sort(keys %$libs))) if $state->{verbose}; ($o->{plist}, my $stub_list) = split_libs($o->{plist}, $libs); my $stub_name = $stub_list->pkgname; my $dest = installed_info($stub_name); - print "Keeping them in $stub_name\n" if $state->{verbose}; + $state->say("Keeping them in $stub_name") + if $state->{verbose}; if ($state->{not}) { $stub_list->to_cache; $o->{plist}->to_cache; @@ -470,7 +474,8 @@ sub save_old_libraries adjust_depends_closure($oldname, $stub_list, $state); } else { - print "No libraries to keep\n" if $state->{verbose}; + $state->say("No libraries to keep") + if $state->{verbose}; } } } diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm index 261656fa470..757a76a424d 100644 --- a/usr.sbin/pkg_add/OpenBSD/Update.pm +++ b/usr.sbin/pkg_add/OpenBSD/Update.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Update.pm,v 1.92 2009/11/11 11:18:24 espie Exp $ +# $OpenBSD: Update.pm,v 1.93 2009/11/11 12:04:19 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org> # @@ -44,14 +44,12 @@ sub process_handle my ($self, $set, $h, $state) = @_; my $pkgname = $h->pkgname; if (defined $h->{update}) { - $state->progress->clear; - print "Update to $pkgname already found\n"; + $state->say("Update to $pkgname already found"); return 0; } if ($pkgname =~ m/^(?:\.libs\d*|partial)\-/o) { - $state->progress->clear; - print "Not updating $pkgname, remember to clean it\n"; + $state->say("Not updating $pkgname, remember to clean it"); return 0; } my @search = (); @@ -112,8 +110,7 @@ sub process_handle } if (@$l == 1) { if ($state->{defines}->{pkgpath}) { - $state->progress->clear; - print "Directly updating $pkgname -> ", $l->[0]->name, "\n"; + $state->say("Directly updating $pkgname -> ", $l->[0]->name); $self->add_updateset($set, $h, $l->[0]); return 1; } @@ -121,12 +118,13 @@ sub process_handle !$plist->uses_old_libs && !$state->{defines}->{installed}) { my $msg = "No need to update $pkgname"; $state->progress->message($msg); - print "$msg\n" if $state->{beverbose}; + $state->say($msg) if $state->{beverbose}; return 0; } } - $state->print("Candidates for updating $pkgname -> ", join(' ', map {$_->name} @$l), "\n"); + $state->say("Candidates for updating $pkgname -> ", + join(' ', map {$_->name} @$l)); my $r = $state->choose_location($pkgname, $l); if (defined $r) { diff --git a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm index 19b44016c46..8c3012b52d7 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.18 2009/11/11 11:17:11 espie Exp $ +# $OpenBSD: UpdateSet.pm,v 1.19 2009/11/11 12:04:19 espie Exp $ # # Copyright (c) 2007 Marc Espie <espie@openbsd.org> # @@ -94,6 +94,12 @@ sub print $self->progress->print(@_); } +sub say +{ + my $self = shift; + $self->progress->print(@_, "\n"); +} + sub system { my $self = shift; @@ -132,7 +138,7 @@ sub choose_location { my ($state, $name, $list) = @_; if (@$list == 0) { - $state->print("Can't find $name\n"); + $state->say("Can't find $name"); return undef; } elsif (@$list == 1) { return $list->[0]; @@ -147,8 +153,7 @@ sub choose_location my $result = OpenBSD::Interactive::ask_list("Ambiguous: choose package for $name", 1, sort keys %h); return $h{$result}; } else { - $state->print("Ambiguous: $name could be ", - join(' ', keys %h), "\n"); + $state->say("Ambiguous: $name could be ", join(' ', keys %h)); return undef; } } @@ -168,7 +173,7 @@ sub set_header {} sub print { shift; - print STDERR @_; + print @_; } # an UpdateSet is a list of packages to remove/install. |