sort journal messsages in a better way, put - before +, so that one can
authorespie <espie@openbsd.org>
Tue, 3 Aug 2010 14:10:12 +0000 (14:10 +0000)
committerespie <espie@openbsd.org>
Tue, 3 Aug 2010 14:10:12 +0000 (14:10 +0000)
see deinstall info before new install info (prompted by a comment from
tedu@)

usr.sbin/pkg_add/OpenBSD/Log.pm
usr.sbin/pkg_add/OpenBSD/SharedItems.pm

index bfc8412..30fdee8 100644 (file)
@@ -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 <espie@openbsd.org>
 #
@@ -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);
index fb0cf7e..a3fe9a2 100644 (file)
@@ -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 <espie@openbsd.org>
 #
@@ -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++;