diff options
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/AddDelete.pm | 30 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgAdd.pm | 30 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgDelete.pm | 38 |
3 files changed, 61 insertions, 37 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm index c01343989c0..f8a58762ab5 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.49 2011/07/13 13:01:13 espie Exp $ +# $OpenBSD: AddDelete.pm,v 1.50 2011/07/14 11:31:20 espie Exp $ # # Copyright (c) 2007-2010 Marc Espie <espie@openbsd.org> # @@ -196,6 +196,34 @@ sub ntogo_string return $self->todo($offset // 0); } +# one-level dependencies tree, for nicer printouts +sub build_deptree +{ + my ($state, $set, @deps) = @_; + + if (defined $state->{deptree}->{$set}) { + $set = $state->{deptree}->{$set}; + } + for my $dep (@deps) { + $state->{deptree}->{$dep} = $set unless + defined $state->{deptree}->{$dep}; + } +} + +sub deptree_header +{ + my ($state, $pkg) = @_; + if (defined $state->{deptree}->{$pkg}) { + my $s = $state->{deptree}->{$pkg}->real_set; + if ($s eq $pkg) { + delete $state->{deptree}->{$pkg}; + } else { + return $s->short_print.':'; + } + } + return ''; +} + sub vstat { my $self = shift; diff --git a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm index 1e6f768cb7c..0f169bcf31d 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.27 2011/07/13 13:01:13 espie Exp $ +# $OpenBSD: PkgAdd.pm,v 1.28 2011/07/14 11:31:20 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # @@ -157,34 +157,6 @@ sub handle_options } } -# one-level dependencies tree, for nicer printouts -sub build_deptree -{ - my ($state, $set, @deps) = @_; - - if (defined $state->{deptree}->{$set}) { - $set = $state->{deptree}->{$set}; - } - for my $dep (@deps) { - $state->{deptree}->{$dep} = $set unless - defined $state->{deptree}->{$dep}; - } -} - -sub deptree_header -{ - my ($state, $pkg) = @_; - if (defined $state->{deptree}->{$pkg}) { - my $s = $state->{deptree}->{$pkg}->real_set; - if ($s eq $pkg) { - delete $state->{deptree}->{$pkg}; - } else { - return $s->short_print.':'; - } - } - return ''; -} - sub set_name_from_handle { my ($state, $h, $extra) = @_; diff --git a/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm b/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm index 4f3d29ea616..8bf4d6c99fc 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm @@ -1,6 +1,6 @@ #!/usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgDelete.pm,v 1.16 2011/07/13 13:01:13 espie Exp $ +# $OpenBSD: PkgDelete.pm,v 1.17 2011/07/14 11:31:20 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # @@ -137,6 +137,33 @@ sub deleteset_from_location return $self->deleteset->add_older(OpenBSD::Handle->from_location($location)); } +package OpenBSD::DeleteSet; +sub setup_header +{ + my ($set, $state, $handle) = @_; + my $header = $state->deptree_header($set); + if (defined $handle) { + $header .= $handle->pkgname; + } else { + $header .= $set->print; + } + if (!$state->progress->set_header($header)) { + return unless $state->verbose; + $header = "Deleting $header"; + if (defined $state->{lastheader} && + $header eq $state->{lastheader}) { + return; + } + $state->{lastheader} = $header; + $state->print("#1", $header); + $state->print("(pretending) ") if $state->{not}; + if ($state->{do_faked}) { + $state->print(" under #1", $state->{destdir}); + } + $state->print("\n"); + } +} + package OpenBSD::PkgDelete; our @ISA = qw(OpenBSD::AddDelete); @@ -214,13 +241,9 @@ sub really_remove } else { $state->status->what("Deleting"); } - if (!$state->progress->set_header($set->print)) { - $state->say($state->{not} ? - "Pretending to delete #1" : - "Deleting #1", - $set->print) if $state->verbose; - } + $set->setup_header($state); for my $pkgname ($set->older_names) { + $set->setup_header($state, $set->{older}{$pkgname}); $state->log->set_context('-'.$pkgname); OpenBSD::Delete::delete_package($pkgname, $state); } @@ -331,6 +354,7 @@ sub remove_set return ($set); } $set->{once} = 1; + $state->build_deptree($set, values %$todo); return (values %$todo, $set); } if ($state->{automatic}) { |