2 package Debbugs::Status;
6 Debbugs::Status -- Routines for dealing with summary and status files
15 This module is a replacement for the parts of errorlib.pl which write
16 and read status and summary files.
18 It also contains generic routines for returning information about the
19 status of a particular bug
27 use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT);
28 use base qw(Exporter);
30 use Params::Validate qw(validate_with :types);
31 use Debbugs::Common qw(:util :lock :quit);
32 use Debbugs::Config qw(:config);
33 use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522);
34 use Debbugs::Packages qw(makesourceversions getversions binarytosource);
35 use Debbugs::Versions;
36 use Debbugs::Versions::Dpkg;
42 $DEBUG = 0 unless defined $DEBUG;
45 %EXPORT_TAGS = (status => [qw(splitpackages get_bug_status buggy bug_archiveable),
46 qw(isstrongseverity bug_presence),
48 read => [qw(readbug read_bug lockreadbug)],
49 write => [qw(writebug makestatus unlockwritebug)],
50 versions => [qw(addfoundversions addfixedversions),
51 qw(removefoundversions)
53 hook => [qw(bughook bughook_archive)],
56 Exporter::export_ok_tags(qw(status read write versions hook));
57 $EXPORT_TAGS{all} = [@EXPORT_OK];
63 readbug($bug_num,$location)
66 Reads a summary file from the archive given a bug number and a bug
67 location. Valid locations are those understood by L</getbugcomponent>
72 my %fields = (originator => 'submitter',
75 msgid => 'message-id',
76 'package' => 'package',
79 forwarded => 'forwarded-to',
80 mergedwith => 'merged-with',
81 severity => 'severity',
83 found_versions => 'found-in',
84 found_date => 'found-date',
85 fixed_versions => 'fixed-in',
86 fixed_date => 'fixed-date',
88 blockedby => 'blocked-by',
91 # Fields which need to be RFC1522-decoded in format versions earlier than 3.
92 my @rfc1522_fields = qw(originator subject done forwarded owner);
95 return read_bug(bug => $_[0],
96 (@_ > 1)?(location => $_[1]):()
102 read_bug(bug => $bug_num,
103 location => 'archive',
105 read_bug(summary => 'path/to/bugnum.summary');
108 A more complete function than readbug; it enables you to pass a full
109 path to the summary file instead of the bug number and/or location.
115 =item bug -- the bug number
117 =item location -- optional location which is passed to getbugcomponent
119 =item summary -- complete path to the .summary file which will be read
123 One of C<bug> or C<summary> must be passed. This function will return
124 undef on failure, and will die if improper arguments are passed.
132 my %param = validate_with(params => \@_,
133 spec => {bug => {type => SCALAR,
137 location => {type => SCALAR|UNDEF,
140 summary => {type => SCALAR,
145 die "One of bug or summary must be passed to read_bug"
146 if not exists $param{bug} and not exists $param{summary};
148 if (not defined $param{summary}) {
149 my ($lref, $location) = @param{qw(bug location)};
150 if (not defined $location) {
151 $location = getbuglocation($lref,'summary');
152 return undef if not defined $location;
154 $status = getbugcomponent($lref, 'summary', $location);
155 return undef unless defined $status;
158 $status = $param{summary};
160 my $status_fh = new IO::File $status, 'r' or
161 warn "Unable to open $status for reading: $!" and return undef;
168 while (<$status_fh>) {
171 $version = $1 if /^Format-Version: ([0-9]+)/i;
174 # Version 3 is the latest format version currently supported.
175 return undef if $version > 3;
177 my %namemap = reverse %fields;
178 for my $line (@lines) {
179 if ($line =~ /(\S+?): (.*)/) {
180 my ($name, $value) = (lc $1, $2);
181 $data{$namemap{$name}} = $value if exists $namemap{$name};
184 for my $field (keys %fields) {
185 $data{$field} = '' unless exists $data{$field};
188 $data{severity} = $config{default_severity} if $data{severity} eq '';
189 for my $field (qw(found_versions fixed_versions found_date fixed_date)) {
190 $data{$field} = [split ' ', $data{$field}];
192 for my $field (qw(found fixed)) {
193 # create the found/fixed hashes which indicate when a
194 # particular version was marked found or marked fixed.
195 @{$data{$field}}{@{$data{"${field}_versions"}}} =
196 (('') x (@{$data{"${field}_date"}} - @{$data{"${field}_versions"}}),
197 @{$data{"${field}_date"}});
201 for my $field (@rfc1522_fields) {
202 $data{$field} = decode_rfc1522($data{$field});
211 lockreadbug($bug_num,$location)
213 Performs a filelock, then reads the bug; the bug is unlocked if the
214 return is undefined, otherwise, you need to call unfilelock or
217 See readbug above for information on what this returns
222 my ($lref, $location) = @_;
223 &filelock("lock/$lref");
224 my $data = read_bug(bug => $lref, location => $location);
225 &unfilelock unless defined $data;
229 my @v1fieldorder = qw(originator date subject msgid package
230 keywords done forwarded mergedwith severity);
234 my $content = makestatus($status,$version)
235 my $content = makestatus($status);
237 Creates the content for a status file based on the $status hashref
240 Really only useful for writebug
242 Currently defaults to version 2 (non-encoded rfc1522 names) but will
243 eventually default to version 3. If you care, you should specify a
249 my ($data,$version) = @_;
250 $version = 2 unless defined $version;
254 my %newdata = %$data;
255 for my $field (qw(found fixed)) {
256 if (exists $newdata{$field}) {
257 $newdata{"${field}_date"} =
258 [map {$newdata{$field}{$_}||''} keys %{$newdata{$field}}];
262 for my $field (qw(found_versions fixed_versions found_date fixed_date)) {
263 $newdata{$field} = join ' ', @{$newdata{$field}||[]};
267 for my $field (@rfc1522_fields) {
268 $newdata{$field} = encode_rfc1522($newdata{$field});
273 for my $field (@v1fieldorder) {
274 if (exists $newdata{$field} and defined $newdata{$field}) {
275 $contents .= "$newdata{$field}\n";
280 } elsif ($version == 2 or $version == 3) {
281 # Version 2 or 3. Add a file format version number for the sake of
282 # further extensibility in the future.
283 $contents .= "Format-Version: $version\n";
284 for my $field (keys %fields) {
285 if (exists $newdata{$field} and defined $newdata{$field}
286 and $newdata{$field} ne '') {
287 # Output field names in proper case, e.g. 'Merged-With'.
288 my $properfield = $fields{$field};
289 $properfield =~ s/(?:^|(?<=-))([a-z])/\u$1/g;
290 $contents .= "$properfield: $newdata{$field}\n";
300 writebug($bug_num,$status,$location,$minversion,$disablebughook)
302 Writes the bug status and summary files out.
304 Skips writting out a status file if minversion is 2
306 Does not call bughook if disablebughook is true.
311 my ($ref, $data, $location, $minversion, $disablebughook) = @_;
314 my %outputs = (1 => 'status', 2 => 'summary');
315 for my $version (keys %outputs) {
316 next if defined $minversion and $version < $minversion;
317 my $status = getbugcomponent($ref, $outputs{$version}, $location);
318 &quit("can't find location for $ref") unless defined $status;
319 open(S,"> $status.new") || &quit("opening $status.new: $!");
320 print(S makestatus($data, $version)) ||
321 &quit("writing $status.new: $!");
322 close(S) || &quit("closing $status.new: $!");
328 rename("$status.new",$status) || &quit("installing new $status: $!");
331 # $disablebughook is a bit of a hack to let format migration scripts use
332 # this function rather than having to duplicate it themselves.
333 &bughook($change,$ref,$data) unless $disablebughook;
336 =head2 unlockwritebug
338 unlockwritebug($bug_num,$status,$location,$minversion,$disablebughook);
340 Writes a bug, then calls unfilelock; see writebug for what these
352 The following functions are exported with the :versions tag
354 =head2 addfoundversions
356 addfoundversions($status,$package,$version,$isbinary);
363 sub addfoundversions {
367 my $isbinary = shift;
368 return unless defined $version;
369 undef $package if $package =~ m[(?:\s|/)];
370 my $source = $package;
372 if (defined $package and $isbinary) {
373 my @srcinfo = binarytosource($package, $version, undef);
375 # We know the source package(s). Use a fully-qualified version.
376 addfoundversions($data, $_->[0], $_->[1], '') foreach @srcinfo;
379 # Otherwise, an unqualified version will have to do.
383 # Strip off various kinds of brain-damage.
385 $version =~ s/ *\(.*\)//;
386 $version =~ s/ +[A-Za-z].*//;
388 foreach my $ver (split /[,\s]+/, $version) {
389 my $sver = defined($source) ? "$source/$ver" : '';
390 unless (grep { $_ eq $ver or $_ eq $sver } @{$data->{found_versions}}) {
391 push @{$data->{found_versions}}, defined($source) ? $sver : $ver;
393 @{$data->{fixed_versions}} =
394 grep { $_ ne $ver and $_ ne $sver } @{$data->{fixed_versions}};
398 =head2 removefoundversions
400 removefoundversions($data,$package,$versiontoremove)
402 Removes found versions from $data
404 If a version is fully qualified (contains /) only versions matching
405 exactly are removed. Otherwise, all versions matching the version
408 Currently $package and $isbinary are entirely ignored, but accepted
409 for backwards compatibilty.
413 sub removefoundversions {
417 my $isbinary = shift;
418 return unless defined $version;
420 foreach my $ver (split /[,\s]+/, $version) {
422 # fully qualified version
423 @{$data->{found_versions}} =
425 @{$data->{found_versions}};
428 # non qualified version; delete all matchers
429 @{$data->{found_versions}} =
430 grep {$_ !~ m[(?:^|/)\Q$ver\E$]}
431 @{$data->{found_versions}};
437 sub addfixedversions {
441 my $isbinary = shift;
442 return unless defined $version;
443 undef $package if $package =~ m[(?:\s|/)];
444 my $source = $package;
446 if (defined $package and $isbinary) {
447 my @srcinfo = binarytosource($package, $version, undef);
449 # We know the source package(s). Use a fully-qualified version.
450 addfixedversions($data, $_->[0], $_->[1], '') foreach @srcinfo;
453 # Otherwise, an unqualified version will have to do.
457 # Strip off various kinds of brain-damage.
459 $version =~ s/ *\(.*\)//;
460 $version =~ s/ +[A-Za-z].*//;
462 foreach my $ver (split /[,\s]+/, $version) {
463 my $sver = defined($source) ? "$source/$ver" : '';
464 unless (grep { $_ eq $ver or $_ eq $sver } @{$data->{fixed_versions}}) {
465 push @{$data->{fixed_versions}}, defined($source) ? $sver : $ver;
467 @{$data->{found_versions}} =
468 grep { $_ ne $ver and $_ ne $sver } @{$data->{found_versions}};
472 sub removefixedversions {
476 my $isbinary = shift;
477 return unless defined $version;
478 undef $package if $package =~ m[(?:\s|/)];
479 my $source = $package;
481 if (defined $package and $isbinary) {
482 my @srcinfo = binarytosource($package, $version, undef);
484 # We know the source package(s). Use a fully-qualified version.
485 removefixedversions($data, $_->[0], $_->[1], '') foreach @srcinfo;
488 # Otherwise, an unqualified version will have to do.
492 foreach my $ver (split /[,\s]+/, $version) {
493 my $sver = defined($source) ? "$source/$ver" : '';
494 @{$data->{fixed_versions}} =
495 grep { $_ ne $ver and $_ ne $sver } @{$data->{fixed_versions}};
505 Split a package string from the status file into a list of package names.
511 return unless defined $pkgs;
512 return map lc, split /[ \t?,()]+/, $pkgs;
516 =head2 bug_archiveable
518 bug_archiveable(bug => $bug_num);
524 =item bug -- bug number (required)
526 =item status -- Status hashref returned by read_bug or get_bug_status (optional)
528 =item version -- Debbugs::Version information (optional)
530 =item days_until -- return days until the bug can be archived
534 Returns 1 if the bug can be archived
535 Returns 0 if the bug cannot be archived
537 If days_until is true, returns the number of days until the bug can be
538 archived, -1 if it cannot be archived. 0 means that the bug can be
539 archived the next time the archiver runs.
541 Returns undef on failure.
545 # This will eventually need to be fixed before we start using mod_perl
546 my $version_cache = {};
548 my %param = validate_with(params => \@_,
549 spec => {bug => {type => SCALAR,
552 status => {type => HASHREF,
555 days_until => {type => BOOLEAN,
560 # This is what we return if the bug cannot be archived.
561 my $cannot_archive = $param{days_until}?-1:0;
562 # read the status information
563 my $status = $param{status};
564 if (not exists $param{status} or not defined $status) {
565 $status = read_bug(bug=>$param{bug});
566 return undef if not defined $status;
568 # Bugs can be archived if they are
570 return $cannot_archive if not defined $status->{done} or not length $status->{done};
571 # If we just are checking if the bug can be archived, we'll not even bother
572 # checking the versioning information if the bug has been -done for less than 28 days.
573 if (not $param{days_until} and $config{remove_age} >
574 -M getbugcomponent($param{ref},'log')
576 return $cannot_archive;
578 # At this point, we have to get the versioning information for this bug.
579 # We examine the set of distribution tags. If a bug has no distribution
580 # tags set, we assume a default set, otherwise we use the tags the bug
583 # There must be fixed_versions for us to look at the versioning
585 if (@{$status->{fixed_versions}}) {
587 @dist_tags{@{$config{removal_distribution_tags}}} =
588 (1) x @{$config{removal_distribution_tags}};
590 @dists{@{$config{removal_default_distribution_tags}}} =
591 (1) x @{$config{removal_default_distribution_tags}};
592 for my $tag (split ' ', $status->{tags}) {
593 next unless $dist_tags{$tag};
597 for my $dist (keys %dists){
599 @versions = getversions($status->{package},
602 # TODO: This should probably be handled further out for efficiency and
603 # for more ease of distinguishing between pkg= and src= queries.
604 my @sourceversions = makesourceversions($status->{package},
607 @source_versions{@sourceversions} = (1) x @sourceversions;
609 if ('found' eq max_buggy(bug => $param{bug},
610 sourceversions => [keys %source_versions],
611 found => $status->{found_versions},
612 fixed => $status->{fixed_versions},
613 version_cache => $version_cache,
614 package => $status->{package},
616 return $cannot_archive;
619 # 6. at least 28 days have passed since the last action has occured or the bug was closed
620 # XXX We still need some more work here before we actually can archive;
621 # we really need to track when a bug was closed in a version.
622 my $age = ceil($config{remove_age} - -M getbugcomponent($param{bug},'log'));
624 return $param{days_until}?$age:0;
627 return $param{days_until}?0:1;
632 =head2 get_bug_status
634 my $status = get_bug_status(bug => $nnn);
636 my $status = get_bug_status($bug_num)
642 =item bug -- scalar bug number
644 =item status -- optional hashref of bug status as returned by readbug
645 (can be passed to avoid rereading the bug information)
647 =item bug_index -- optional tied index of bug status infomration;
648 currently not correctly implemented.
650 =item version -- optional version to check package status at
652 =item dist -- optional distribution to check package status at
654 =item arch -- optional architecture to check package status at
656 =item usertags -- optional hashref of usertags
658 =item sourceversion -- optional arrayref of source/version; overrides
659 dist, arch, and version. [The entries in this array must be in the
660 "source/version" format.] Eventually this can be used to for caching.
664 Note: Currently the version information is cached; this needs to be
665 changed before using this function in long lived programs.
673 my %param = validate_with(params => \@_,
674 spec => {bug => {type => SCALAR,
677 status => {type => HASHREF,
680 bug_index => {type => OBJECT,
683 version => {type => SCALAR,
686 dist => {type => SCALAR,
689 arch => {type => SCALAR,
692 usertags => {type => HASHREF,
695 sourceversions => {type => ARRAYREF,
702 if (defined $param{bug_index} and
703 exists $param{bug_index}{$param{bug}}) {
704 %status = %{ $param{bug_index}{$param{bug}} };
705 $status{pending} = $status{ status };
706 $status{id} = $param{bug};
709 if (defined $param{status}) {
710 %status = %{$param{status}};
713 my $location = getbuglocation($param{bug}, 'summary');
714 return {} if not length $location;
715 %status = %{ readbug( $param{bug}, $location ) };
717 $status{id} = $param{bug};
719 if (defined $param{usertags}{$param{bug}}) {
720 $status{keywords} = "" unless defined $status{keywords};
721 $status{keywords} .= " " unless $status{keywords} eq "";
722 $status{keywords} .= join(" ", @{$param{usertags}{$param{bug}}});
724 $status{tags} = $status{keywords};
725 my %tags = map { $_ => 1 } split ' ', $status{tags};
727 $status{"package"} =~ s/\s*$//;
728 $status{"package"} = 'unknown' if ($status{"package"} eq '');
729 $status{"severity"} = 'normal' if ($status{"severity"} eq '');
731 $status{"pending"} = 'pending';
732 $status{"pending"} = 'forwarded' if (length($status{"forwarded"}));
733 $status{"pending"} = 'pending-fixed' if ($tags{pending});
734 $status{"pending"} = 'fixed' if ($tags{fixed});
737 my $presence = bug_presence(map{exists $param{$_}?($_,$param{$_}):()}
738 qw(bug sourceversions arch dist version found fixed package)
740 if (defined $presence) {
741 if ($presence eq 'fixed') {
742 $status{pending} = 'done';
744 elsif ($presence eq 'absent') {
745 $status{pending} = 'absent';
753 my $precence = bug_presence(bug => nnn,
757 Returns 'found', 'absent', 'fixed' or undef based on whether the bug
758 is found, absent, fixed, or no information is available in the
759 distribution (dist) and/or architecture (arch) specified.
766 =item bug -- scalar bug number
768 =item status -- optional hashref of bug status as returned by readbug
769 (can be passed to avoid rereading the bug information)
771 =item bug_index -- optional tied index of bug status infomration;
772 currently not correctly implemented.
774 =item version -- optional version to check package status at
776 =item dist -- optional distribution to check package status at
778 =item arch -- optional architecture to check package status at
780 =item sourceversion -- optional arrayref of source/version; overrides
781 dist, arch, and version. [The entries in this array must be in the
782 "source/version" format.] Eventually this can be used to for caching.
789 my %param = validate_with(params => \@_,
790 spec => {bug => {type => SCALAR,
793 status => {type => HASHREF,
796 version => {type => SCALAR,
799 dist => {type => SCALAR,
802 arch => {type => SCALAR,
805 sourceversions => {type => ARRAYREF,
811 if (defined $param{status}) {
812 %status = %{$param{status}};
815 my $location = getbuglocation($param{bug}, 'summary');
816 return {} if not length $location;
817 %status = %{ readbug( $param{bug}, $location ) };
821 if (not exists $param{sourceversions}) {
823 if (defined $param{version}) {
824 @versions = ($param{version});
825 } elsif (defined $param{dist}) {
826 @versions = getversions($status{package}, $param{dist}, $param{arch});
829 # TODO: This should probably be handled further out for efficiency and
830 # for more ease of distinguishing between pkg= and src= queries.
831 @sourceversions = makesourceversions($status{package},
836 @sourceversions = @{$param{sourceversions}};
838 if (@sourceversions) {
839 my $maxbuggy = max_buggy(bug => $param{bug},
840 sourceversions => \@sourceversions,
841 found => $status{found_versions},
842 fixed => $status{fixed_versions},
843 package => $status{package},
844 version_cache => $version_cache,
848 if (length($status{done}) and
849 (not @sourceversions or not @{$status{fixed_versions}})) {
864 =item bug -- scalar bug number
866 =item sourceversion -- optional arrayref of source/version; overrides
867 dist, arch, and version. [The entries in this array must be in the
868 "source/version" format.] Eventually this can be used to for caching.
872 Note: Currently the version information is cached; this needs to be
873 changed before using this function in long lived programs.
878 my %param = validate_with(params => \@_,
879 spec => {bug => {type => SCALAR,
882 sourceversions => {type => ARRAYREF,
885 found => {type => ARRAYREF,
888 fixed => {type => ARRAYREF,
891 package => {type => SCALAR,
893 version_cache => {type => HASHREF,
898 # Resolve bugginess states (we might be looking at multiple
899 # architectures, say). Found wins, then fixed, then absent.
900 my $maxbuggy = 'absent';
901 for my $version (@{$param{sourceversions}}) {
902 my $buggy = buggy(bug => $param{bug},
904 found => $param{found},
905 fixed => $param{fixed},
906 version_cache => $param{version_cache},
907 package => $param{package},
909 if ($buggy eq 'found') {
911 } elsif ($buggy eq 'fixed') {
928 Returns the output of Debbugs::Versions::buggy for a particular
929 package, version and found/fixed set. Automatically turns found, fixed
930 and version into source/version strings.
932 Caching can be had by using the version_cache, but no attempt to check
933 to see if the on disk information is more recent than the cache is
934 made. [This will need to be fixed for long-lived processes.]
939 my %param = validate_with(params => \@_,
940 spec => {bug => {type => SCALAR,
943 found => {type => ARRAYREF,
946 fixed => {type => ARRAYREF,
949 version_cache => {type => HASHREF,
952 package => {type => SCALAR,
954 version => {type => SCALAR,
958 my @found = @{$param{found}};
959 my @fixed = @{$param{fixed}};
960 if (grep {$_ !~ m{/}} (@{$param{found}}, @{$param{fixed}})) {
961 # We have non-source version versions
962 @found = makesourceversions($param{package},undef,
965 @fixed = makesourceversions($param{package},undef,
969 if ($param{version} !~ m{/}) {
970 $param{version} = makesourceversions($param{package},undef,
974 # Figure out which source packages we need
976 @sources{map {m{(.+)/}; $1} @found} = (1) x @found;
977 @sources{map {m{(.+)/}; $1} @fixed} = (1) x @fixed;
978 @sources{map {m{(.+)/}; $1} $param{version}} = 1;
980 if (not defined $param{version_cache} or
981 not exists $param{version_cache}{join(',',sort keys %sources)}) {
982 $version = Debbugs::Versions->new(\&Debbugs::Versions::Dpkg::vercmp);
983 foreach my $source (keys %sources) {
984 my $srchash = substr $source, 0, 1;
985 my $version_fh = new IO::File "$config{version_packages_dir}/$srchash/$source", 'r' or
986 warn "Unable to open $config{version_packages_dir}/$srchash/$source: $!" and next;
987 $version->load($version_fh);
989 if (defined $param{version_cache}) {
990 $param{version_cache}{join(',',sort keys %sources)} = $version;
994 $version = $param{version_cache}{join(',',sort keys %sources)};
996 return $version->buggy($param{version},\@found,\@fixed);
999 sub isstrongseverity {
1000 my $severity = shift;
1001 $severity = $config{default_severity} if $severity eq '';
1002 return grep { $_ eq $severity } @{$config{strong_severities}};
1006 =head1 PRIVATE FUNCTIONS
1010 sub update_realtime {
1011 my ($file, $bug, $new) = @_;
1013 # update realtime index.db
1015 open(IDXDB, "<$file") or die "Couldn't open $file";
1016 open(IDXNEW, ">$file.new");
1020 while($line = <IDXDB>) {
1021 @line = split /\s/, $line;
1022 last if ($line[1] >= $bug);
1027 if ($new eq "NOCHANGE") {
1028 print IDXNEW $line if ($line ne "" and $line[1] == $bug);
1029 } elsif ($new eq "REMOVE") {
1034 if (defined $line and $line ne "" and @line and $line[1] > $bug) {
1039 print IDXNEW while(<IDXDB>);
1044 rename("$file.new", $file);
1049 sub bughook_archive {
1051 &filelock("debbugs.trace.lock");
1052 &appendfile("debbugs.trace","archive $ref\n");
1053 my $line = update_realtime(
1054 "$config{spool_dir}/index.db.realtime",
1057 update_realtime("$config{spool_dir}/index.archive.realtime",
1063 my ( $type, $ref, $data ) = @_;
1064 &filelock("debbugs.trace.lock");
1066 &appendfile("debbugs.trace","$type $ref\n",makestatus($data, 1));
1068 my $whendone = "open";
1069 my $severity = $config{default_severity};
1070 (my $pkglist = $data->{package}) =~ s/[,\s]+/,/g;
1071 $pkglist =~ s/^,+//;
1072 $pkglist =~ s/,+$//;
1073 $whendone = "forwarded" if defined $data->{forwarded} and length $data->{forwarded};
1074 $whendone = "done" if defined $data->{done} and length $data->{done};
1075 $severity = $data->{severity} if length $data->{severity};
1077 my $k = sprintf "%s %d %d %s [%s] %s %s\n",
1078 $pkglist, $ref, $data->{date}, $whendone,
1079 $data->{originator}, $severity, $data->{keywords};
1081 update_realtime("$config{spool_dir}/index.db.realtime", $ref, $k);