--- a/log.pl Tue Aug 01 12:25:50 2006 +0000
+++ b/log.pl Wed Aug 02 06:56:16 2006 +0000
@@ -6,12 +6,12 @@
--[no]db insert into log database [$opt_db]
--[no]mail send mails to @config::mailto [$opt_mail]
--message=s message
- - if the message looks like a file name (e.g.:
- ./text or /tmp/text, the message is read
- from this file)
- - if message is 'upgrade:<FILE>' or
- 'dist-upgrade:<FILE>', the file is parsed as apt
- output
+ - if the message starts with '@' it's considered
+ to be a message FILE.
+ - message can be: apt[:text]@<FILE> - this will
+ start special file processing (assuming output
+ from apt, with text (default: APT: upgrade) going
+ to the first line)
#
use strict;
@@ -72,17 +72,15 @@
"type=s" => \$opt_apt,
) or die eval "\"$USAGE\"";
- if ($opt_message =~ /^\.?\// and -f $opt_message) {
- @ARGV = ($opt_message);
+ if ($opt_message =~ /^@(.*)/) {
+ @ARGV = $1;
$opt_message = join "", <>;
} elsif ($opt_message eq "-") {
$opt_message = join "", <STDIN>;
- } elsif ($opt_message =~ /^((?:dist-)?upgrade):(.*)/) {
+ } elsif ($opt_message =~ /^apt(?::(.*))?\@(\S+)/) {
open(I, $2) or die "Can't open $2: $!\n";
- $opt_message = "$1\n"
- . join "", grep /^(?:\d|Inst|Conf|Remv)/, <I>;
-
- die $opt_message;
+ $opt_message = ($1 ? "APT: $1\n" : "APT: upgrade\n")
+ . join "", map { /^(?:\d|Inst|Conf|Remv)/ ? "- $_" : () } <I>;
}
if ($opt_message =~ /\n/) {