From: espie Date: Tue, 3 Aug 2010 14:10:12 +0000 (+0000) Subject: sort journal messsages in a better way, put - before +, so that one can X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9dd4eb062266beeb693e823efe005f4e77f4ad0e;p=openbsd sort journal messsages in a better way, put - before +, so that one can see deinstall info before new install info (prompted by a comment from tedu@) --- diff --git a/usr.sbin/pkg_add/OpenBSD/Log.pm b/usr.sbin/pkg_add/OpenBSD/Log.pm index bfc8412e482..30fdee858dd 100644 --- a/usr.sbin/pkg_add/OpenBSD/Log.pm +++ b/usr.sbin/pkg_add/OpenBSD/Log.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Log.pm,v 1.3 2010/06/30 10:51:04 espie Exp $ +# $OpenBSD: Log.pm,v 1.4 2010/08/03 14:10:12 espie Exp $ # # Copyright (c) 2007-2010 Marc Espie # @@ -65,10 +65,16 @@ sub errsay push(@{$self->{erroutput}}, $self->f(@_)."\n"); } +sub specialsort +{ + return ((sort grep { /^\-/ } @_), (sort grep { /^\+/} @_), + (sort grep { !/^[\-+]/ } @_)); +} + sub dump { my $self = shift; - for my $ctxt (sort keys %{$self->{errmessages}}) { + for my $ctxt (specialsort keys %{$self->{errmessages}}) { my $msgs = $self->{errmessages}->{$ctxt}; if (@$msgs > 0) { $self->{p}->errsay("--- #1 -------------------", $ctxt); @@ -76,7 +82,7 @@ sub dump } } $self->{errmessages} = {}; - for my $ctxt (sort keys %{$self->{messages}}) { + for my $ctxt (specialsort keys %{$self->{messages}}) { my $msgs = $self->{messages}->{$ctxt}; if (@$msgs > 0) { $self->{p}->say("--- #1 -------------------", $ctxt); diff --git a/usr.sbin/pkg_add/OpenBSD/SharedItems.pm b/usr.sbin/pkg_add/OpenBSD/SharedItems.pm index fb0cf7e81d5..a3fe9a2b5a8 100644 --- a/usr.sbin/pkg_add/OpenBSD/SharedItems.pm +++ b/usr.sbin/pkg_add/OpenBSD/SharedItems.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: SharedItems.pm,v 1.27 2010/08/01 10:03:24 espie Exp $ +# $OpenBSD: SharedItems.pm,v 1.28 2010/08/03 14:10:12 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie # @@ -69,7 +69,7 @@ sub wipe_directory my $realname = $state->{destdir}.$d; for my $i (@{$h->{$d}}) { - $state->log->set_context($i->{pkgname}); + $state->log->set_context('-'.$i->{pkgname}); $i->cleanup($state); } if (!rmdir $realname) { @@ -104,7 +104,7 @@ sub cleanup my $realname = $state->{destdir}.$d; if ($remaining->{dirs}->{$realname}) { for my $i (@{$h->{$d}}) { - $state->log->set_context($i->{pkgname}); + $state->log->set_context('-'.$i->{pkgname}); $i->reload($state); } } else { @@ -119,7 +119,7 @@ sub cleanup $state->system(OpenBSD::Paths->userdel, '--', $user); } else { - $state->log->set_context($pkgname); + $state->log->set_context('-'.$pkgname); $state->log("You should also run /usr/sbin/userdel #1", $user); } $done++; @@ -131,7 +131,7 @@ sub cleanup $state->system(OpenBSD::Paths->groupdel, '--', $group); } else { - $state->log->set_context($pkgname); + $state->log->set_context('-'.$pkgname); $state->log("You should also run /usr/sbin/groupdel #1", $group); } $done++;