1 # This module is part of debbugs, and is released
2 # under the terms of the GPL version 2, or any later
3 # version at your option.
4 # See the file README and COPYING for more information.
6 # [Other people have contributed to this file; their copyrights should
8 # Copyright 2007 by Don Armstrong <don@donarmstrong.com>.
10 package Debbugs::Status;
14 Debbugs::Status -- Routines for dealing with summary and status files
23 This module is a replacement for the parts of errorlib.pl which write
24 and read status and summary files.
26 It also contains generic routines for returning information about the
27 status of a particular bug
35 use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT);
36 use base qw(Exporter);
38 use Params::Validate qw(validate_with :types);
39 use Debbugs::Common qw(:util :lock :quit :misc);
40 use Debbugs::Config qw(:config);
41 use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522);
42 use Debbugs::Packages qw(makesourceversions getversions get_versions binarytosource);
43 use Debbugs::Versions;
44 use Debbugs::Versions::Dpkg;
50 $DEBUG = 0 unless defined $DEBUG;
53 %EXPORT_TAGS = (status => [qw(splitpackages get_bug_status buggy bug_archiveable),
54 qw(isstrongseverity bug_presence),
56 read => [qw(readbug read_bug lockreadbug)],
57 write => [qw(writebug makestatus unlockwritebug)],
58 versions => [qw(addfoundversions addfixedversions),
59 qw(removefoundversions removefixedversions)
61 hook => [qw(bughook bughook_archive)],
64 Exporter::export_ok_tags(qw(status read write versions hook));
65 $EXPORT_TAGS{all} = [@EXPORT_OK];
71 readbug($bug_num,$location)
74 Reads a summary file from the archive given a bug number and a bug
75 location. Valid locations are those understood by L</getbugcomponent>
80 my %fields = (originator => 'submitter',
83 msgid => 'message-id',
84 'package' => 'package',
87 forwarded => 'forwarded-to',
88 mergedwith => 'merged-with',
89 severity => 'severity',
91 found_versions => 'found-in',
92 found_date => 'found-date',
93 fixed_versions => 'fixed-in',
94 fixed_date => 'fixed-date',
96 blockedby => 'blocked-by',
99 # Fields which need to be RFC1522-decoded in format versions earlier than 3.
100 my @rfc1522_fields = qw(originator subject done forwarded owner);
103 return read_bug(bug => $_[0],
104 (@_ > 1)?(location => $_[1]):()
110 read_bug(bug => $bug_num,
111 location => 'archive',
113 read_bug(summary => 'path/to/bugnum.summary');
116 A more complete function than readbug; it enables you to pass a full
117 path to the summary file instead of the bug number and/or location.
123 =item bug -- the bug number
125 =item location -- optional location which is passed to getbugcomponent
127 =item summary -- complete path to the .summary file which will be read
131 One of C<bug> or C<summary> must be passed. This function will return
132 undef on failure, and will die if improper arguments are passed.
140 my %param = validate_with(params => \@_,
141 spec => {bug => {type => SCALAR,
145 # negative bugnumbers
148 location => {type => SCALAR|UNDEF,
151 summary => {type => SCALAR,
156 die "One of bug or summary must be passed to read_bug"
157 if not exists $param{bug} and not exists $param{summary};
159 if (not defined $param{summary}) {
160 my ($lref, $location) = @param{qw(bug location)};
161 if (not defined $location) {
162 $location = getbuglocation($lref,'summary');
163 return undef if not defined $location;
165 $status = getbugcomponent($lref, 'summary', $location);
166 return undef unless defined $status;
169 $status = $param{summary};
171 my $status_fh = new IO::File $status, 'r' or
172 warn "Unable to open $status for reading: $!" and return undef;
179 while (<$status_fh>) {
182 $version = $1 if /^Format-Version: ([0-9]+)/i;
185 # Version 3 is the latest format version currently supported.
186 return undef if $version > 3;
188 my %namemap = reverse %fields;
189 for my $line (@lines) {
190 if ($line =~ /(\S+?): (.*)/) {
191 my ($name, $value) = (lc $1, $2);
192 $data{$namemap{$name}} = $value if exists $namemap{$name};
195 for my $field (keys %fields) {
196 $data{$field} = '' unless exists $data{$field};
199 $data{severity} = $config{default_severity} if $data{severity} eq '';
200 for my $field (qw(found_versions fixed_versions found_date fixed_date)) {
201 $data{$field} = [split ' ', $data{$field}];
203 for my $field (qw(found fixed)) {
204 # create the found/fixed hashes which indicate when a
205 # particular version was marked found or marked fixed.
206 @{$data{$field}}{@{$data{"${field}_versions"}}} =
207 (('') x (@{$data{"${field}_date"}} - @{$data{"${field}_versions"}}),
208 @{$data{"${field}_date"}});
212 for my $field (@rfc1522_fields) {
213 $data{$field} = decode_rfc1522($data{$field});
222 lockreadbug($bug_num,$location)
224 Performs a filelock, then reads the bug; the bug is unlocked if the
225 return is undefined, otherwise, you need to call unfilelock or
228 See readbug above for information on what this returns
233 my ($lref, $location) = @_;
234 &filelock("lock/$lref");
235 my $data = read_bug(bug => $lref, location => $location);
236 &unfilelock unless defined $data;
240 my @v1fieldorder = qw(originator date subject msgid package
241 keywords done forwarded mergedwith severity);
245 my $content = makestatus($status,$version)
246 my $content = makestatus($status);
248 Creates the content for a status file based on the $status hashref
251 Really only useful for writebug
253 Currently defaults to version 2 (non-encoded rfc1522 names) but will
254 eventually default to version 3. If you care, you should specify a
260 my ($data,$version) = @_;
261 $version = 2 unless defined $version;
265 my %newdata = %$data;
266 for my $field (qw(found fixed)) {
267 if (exists $newdata{$field}) {
268 $newdata{"${field}_date"} =
269 [map {$newdata{$field}{$_}||''} keys %{$newdata{$field}}];
273 for my $field (qw(found_versions fixed_versions found_date fixed_date)) {
274 $newdata{$field} = join ' ', @{$newdata{$field}||[]};
278 for my $field (@rfc1522_fields) {
279 $newdata{$field} = encode_rfc1522($newdata{$field});
284 for my $field (@v1fieldorder) {
285 if (exists $newdata{$field} and defined $newdata{$field}) {
286 $contents .= "$newdata{$field}\n";
291 } elsif ($version == 2 or $version == 3) {
292 # Version 2 or 3. Add a file format version number for the sake of
293 # further extensibility in the future.
294 $contents .= "Format-Version: $version\n";
295 for my $field (keys %fields) {
296 if (exists $newdata{$field} and defined $newdata{$field}
297 and $newdata{$field} ne '') {
298 # Output field names in proper case, e.g. 'Merged-With'.
299 my $properfield = $fields{$field};
300 $properfield =~ s/(?:^|(?<=-))([a-z])/\u$1/g;
301 $contents .= "$properfield: $newdata{$field}\n";
311 writebug($bug_num,$status,$location,$minversion,$disablebughook)
313 Writes the bug status and summary files out.
315 Skips writting out a status file if minversion is 2
317 Does not call bughook if disablebughook is true.
322 my ($ref, $data, $location, $minversion, $disablebughook) = @_;
325 my %outputs = (1 => 'status', 2 => 'summary');
326 for my $version (keys %outputs) {
327 next if defined $minversion and $version < $minversion;
328 my $status = getbugcomponent($ref, $outputs{$version}, $location);
329 &quit("can't find location for $ref") unless defined $status;
330 open(S,"> $status.new") || &quit("opening $status.new: $!");
331 print(S makestatus($data, $version)) ||
332 &quit("writing $status.new: $!");
333 close(S) || &quit("closing $status.new: $!");
339 rename("$status.new",$status) || &quit("installing new $status: $!");
342 # $disablebughook is a bit of a hack to let format migration scripts use
343 # this function rather than having to duplicate it themselves.
344 &bughook($change,$ref,$data) unless $disablebughook;
347 =head2 unlockwritebug
349 unlockwritebug($bug_num,$status,$location,$minversion,$disablebughook);
351 Writes a bug, then calls unfilelock; see writebug for what these
363 The following functions are exported with the :versions tag
365 =head2 addfoundversions
367 addfoundversions($status,$package,$version,$isbinary);
374 sub addfoundversions {
378 my $isbinary = shift;
379 return unless defined $version;
380 undef $package if $package =~ m[(?:\s|/)];
381 my $source = $package;
383 if (defined $package and $isbinary) {
384 my @srcinfo = binarytosource($package, $version, undef);
386 # We know the source package(s). Use a fully-qualified version.
387 addfoundversions($data, $_->[0], $_->[1], '') foreach @srcinfo;
390 # Otherwise, an unqualified version will have to do.
394 # Strip off various kinds of brain-damage.
396 $version =~ s/ *\(.*\)//;
397 $version =~ s/ +[A-Za-z].*//;
399 foreach my $ver (split /[,\s]+/, $version) {
400 my $sver = defined($source) ? "$source/$ver" : '';
401 unless (grep { $_ eq $ver or $_ eq $sver } @{$data->{found_versions}}) {
402 push @{$data->{found_versions}}, defined($source) ? $sver : $ver;
404 @{$data->{fixed_versions}} =
405 grep { $_ ne $ver and $_ ne $sver } @{$data->{fixed_versions}};
409 =head2 removefoundversions
411 removefoundversions($data,$package,$versiontoremove)
413 Removes found versions from $data
415 If a version is fully qualified (contains /) only versions matching
416 exactly are removed. Otherwise, all versions matching the version
419 Currently $package and $isbinary are entirely ignored, but accepted
420 for backwards compatibilty.
424 sub removefoundversions {
428 my $isbinary = shift;
429 return unless defined $version;
431 foreach my $ver (split /[,\s]+/, $version) {
433 # fully qualified version
434 @{$data->{found_versions}} =
436 @{$data->{found_versions}};
439 # non qualified version; delete all matchers
440 @{$data->{found_versions}} =
441 grep {$_ !~ m[(?:^|/)\Q$ver\E$]}
442 @{$data->{found_versions}};
448 sub addfixedversions {
452 my $isbinary = shift;
453 return unless defined $version;
454 undef $package if defined $package and $package =~ m[(?:\s|/)];
455 my $source = $package;
457 if (defined $package and $isbinary) {
458 my @srcinfo = binarytosource($package, $version, undef);
460 # We know the source package(s). Use a fully-qualified version.
461 addfixedversions($data, $_->[0], $_->[1], '') foreach @srcinfo;
464 # Otherwise, an unqualified version will have to do.
468 # Strip off various kinds of brain-damage.
470 $version =~ s/ *\(.*\)//;
471 $version =~ s/ +[A-Za-z].*//;
473 foreach my $ver (split /[,\s]+/, $version) {
474 my $sver = defined($source) ? "$source/$ver" : '';
475 unless (grep { $_ eq $ver or $_ eq $sver } @{$data->{fixed_versions}}) {
476 push @{$data->{fixed_versions}}, defined($source) ? $sver : $ver;
478 @{$data->{found_versions}} =
479 grep { $_ ne $ver and $_ ne $sver } @{$data->{found_versions}};
483 sub removefixedversions {
487 my $isbinary = shift;
488 return unless defined $version;
489 undef $package if $package =~ m[(?:\s|/)];
490 my $source = $package;
492 if (defined $package and $isbinary) {
493 my @srcinfo = binarytosource($package, $version, undef);
495 # We know the source package(s). Use a fully-qualified version.
496 removefixedversions($data, $_->[0], $_->[1], '') foreach @srcinfo;
499 # Otherwise, an unqualified version will have to do.
503 foreach my $ver (split /[,\s]+/, $version) {
504 my $sver = defined($source) ? "$source/$ver" : '';
505 @{$data->{fixed_versions}} =
506 grep { $_ ne $ver and $_ ne $sver } @{$data->{fixed_versions}};
516 Split a package string from the status file into a list of package names.
522 return unless defined $pkgs;
523 return map lc, split /[ \t?,()]+/, $pkgs;
527 =head2 bug_archiveable
529 bug_archiveable(bug => $bug_num);
535 =item bug -- bug number (required)
537 =item status -- Status hashref returned by read_bug or get_bug_status (optional)
539 =item version -- Debbugs::Version information (optional)
541 =item days_until -- return days until the bug can be archived
545 Returns 1 if the bug can be archived
546 Returns 0 if the bug cannot be archived
548 If days_until is true, returns the number of days until the bug can be
549 archived, -1 if it cannot be archived. 0 means that the bug can be
550 archived the next time the archiver runs.
552 Returns undef on failure.
556 # This will eventually need to be fixed before we start using mod_perl
557 our $version_cache = {};
559 my %param = validate_with(params => \@_,
560 spec => {bug => {type => SCALAR,
563 status => {type => HASHREF,
566 days_until => {type => BOOLEAN,
571 # This is what we return if the bug cannot be archived.
572 my $cannot_archive = $param{days_until}?-1:0;
573 # read the status information
574 my $status = $param{status};
575 if (not exists $param{status} or not defined $status) {
576 $status = read_bug(bug=>$param{bug});
577 return undef if not defined $status;
579 # Bugs can be archived if they are
581 return $cannot_archive if not defined $status->{done} or not length $status->{done};
582 # If we just are checking if the bug can be archived, we'll not even bother
583 # checking the versioning information if the bug has been -done for less than 28 days.
584 if (not $param{days_until} and $config{remove_age} >
585 -M getbugcomponent($param{ref},'log')
587 return $cannot_archive;
589 # At this point, we have to get the versioning information for this bug.
590 # We examine the set of distribution tags. If a bug has no distribution
591 # tags set, we assume a default set, otherwise we use the tags the bug
594 # There must be fixed_versions for us to look at the versioning
596 if (@{$status->{fixed_versions}}) {
598 @dist_tags{@{$config{removal_distribution_tags}}} =
599 (1) x @{$config{removal_distribution_tags}};
601 @dists{@{$config{removal_default_distribution_tags}}} =
602 (1) x @{$config{removal_default_distribution_tags}};
603 for my $tag (split ' ', $status->{tags}) {
604 next unless $dist_tags{$tag};
608 my @sourceversions = get_versions(package => $status->{package},
609 dist => [keys %dists],
612 @source_versions{@sourceversions} = (1) x @sourceversions;
613 if ('found' eq max_buggy(bug => $param{bug},
614 sourceversions => [keys %source_versions],
615 found => $status->{found_versions},
616 fixed => $status->{fixed_versions},
617 version_cache => $version_cache,
618 package => $status->{package},
620 return $cannot_archive;
622 # Since the bug has at least been fixed in the architectures
623 # that matters, we check to see how long it has been fixed.
626 # 6. at least 28 days have passed since the last action has occured or the bug was closed
627 my $age = ceil($config{remove_age} - -M getbugcomponent($param{bug},'log'));
629 return $param{days_until}?$age:0;
632 return $param{days_until}?0:1;
637 =head2 get_bug_status
639 my $status = get_bug_status(bug => $nnn);
641 my $status = get_bug_status($bug_num)
647 =item bug -- scalar bug number
649 =item status -- optional hashref of bug status as returned by readbug
650 (can be passed to avoid rereading the bug information)
652 =item bug_index -- optional tied index of bug status infomration;
653 currently not correctly implemented.
655 =item version -- optional version(s) to check package status at
657 =item dist -- optional distribution(s) to check package status at
659 =item arch -- optional architecture(s) to check package status at
661 =item usertags -- optional hashref of usertags
663 =item sourceversion -- optional arrayref of source/version; overrides
664 dist, arch, and version. [The entries in this array must be in the
665 "source/version" format.] Eventually this can be used to for caching.
669 Note: Currently the version information is cached; this needs to be
670 changed before using this function in long lived programs.
678 my %param = validate_with(params => \@_,
679 spec => {bug => {type => SCALAR,
682 status => {type => HASHREF,
685 bug_index => {type => OBJECT,
688 version => {type => SCALAR|ARRAYREF,
691 dist => {type => SCALAR|ARRAYREF,
694 arch => {type => SCALAR|ARRAYREF,
697 usertags => {type => HASHREF,
700 sourceversions => {type => ARRAYREF,
707 if (defined $param{bug_index} and
708 exists $param{bug_index}{$param{bug}}) {
709 %status = %{ $param{bug_index}{$param{bug}} };
710 $status{pending} = $status{ status };
711 $status{id} = $param{bug};
714 if (defined $param{status}) {
715 %status = %{$param{status}};
718 my $location = getbuglocation($param{bug}, 'summary');
719 return {} if not length $location;
720 %status = %{ readbug( $param{bug}, $location ) };
722 $status{id} = $param{bug};
724 if (defined $param{usertags}{$param{bug}}) {
725 $status{keywords} = "" unless defined $status{keywords};
726 $status{keywords} .= " " unless $status{keywords} eq "";
727 $status{keywords} .= join(" ", @{$param{usertags}{$param{bug}}});
729 $status{tags} = $status{keywords};
730 my %tags = map { $_ => 1 } split ' ', $status{tags};
732 $status{"package"} =~ s/\s*$//;
733 $status{"package"} = 'unknown' if ($status{"package"} eq '');
734 $status{"severity"} = 'normal' if ($status{"severity"} eq '');
736 $status{"pending"} = 'pending';
737 $status{"pending"} = 'forwarded' if (length($status{"forwarded"}));
738 $status{"pending"} = 'pending-fixed' if ($tags{pending});
739 $status{"pending"} = 'fixed' if ($tags{fixed});
742 my $presence = bug_presence(map{(exists $param{$_})?($_,$param{$_}):()}
743 qw(bug sourceversions arch dist version found fixed package)
745 if (defined $presence) {
746 if ($presence eq 'fixed') {
747 $status{pending} = 'done';
749 elsif ($presence eq 'absent') {
750 $status{pending} = 'absent';
758 my $precence = bug_presence(bug => nnn,
762 Returns 'found', 'absent', 'fixed' or undef based on whether the bug
763 is found, absent, fixed, or no information is available in the
764 distribution (dist) and/or architecture (arch) specified.
771 =item bug -- scalar bug number
773 =item status -- optional hashref of bug status as returned by readbug
774 (can be passed to avoid rereading the bug information)
776 =item bug_index -- optional tied index of bug status infomration;
777 currently not correctly implemented.
779 =item version -- optional version to check package status at
781 =item dist -- optional distribution to check package status at
783 =item arch -- optional architecture to check package status at
785 =item sourceversion -- optional arrayref of source/version; overrides
786 dist, arch, and version. [The entries in this array must be in the
787 "source/version" format.] Eventually this can be used to for caching.
794 my %param = validate_with(params => \@_,
795 spec => {bug => {type => SCALAR,
798 status => {type => HASHREF,
801 version => {type => SCALAR|ARRAYREF,
804 dist => {type => SCALAR|ARRAYREF,
807 arch => {type => SCALAR|ARRAYREF,
810 sourceversions => {type => ARRAYREF,
816 if (defined $param{status}) {
817 %status = %{$param{status}};
820 my $location = getbuglocation($param{bug}, 'summary');
821 return {} if not length $location;
822 %status = %{ readbug( $param{bug}, $location ) };
826 if (not exists $param{sourceversions}) {
828 if (defined $param{version}) {
829 foreach my $arch (make_list($param{arch})) {
830 my @temp = makesourceversions($status{package},
832 make_list($param{version})
834 @sourceversions{@temp} = (1) x @temp;
836 } elsif (defined $param{dist}) {
837 foreach my $arch (make_list($param{arch})) {
839 foreach my $dist (make_list($param{dist})) {
840 push @versions, getversions($status{package}, $dist, $arch);
842 my @temp = makesourceversions($status{package},
846 @sourceversions{@temp} = (1) x @temp;
850 # TODO: This should probably be handled further out for efficiency and
851 # for more ease of distinguishing between pkg= and src= queries.
852 @sourceversions = keys %sourceversions;
855 @sourceversions = @{$param{sourceversions}};
857 my $maxbuggy = 'undef';
858 if (@sourceversions) {
859 $maxbuggy = max_buggy(bug => $param{bug},
860 sourceversions => \@sourceversions,
861 found => $status{found_versions},
862 fixed => $status{fixed_versions},
863 package => $status{package},
864 version_cache => $version_cache,
867 elsif (defined $param{dist}) {
870 if (length($status{done}) and
871 (not @sourceversions or not @{$status{fixed_versions}})) {
886 =item bug -- scalar bug number
888 =item sourceversion -- optional arrayref of source/version; overrides
889 dist, arch, and version. [The entries in this array must be in the
890 "source/version" format.] Eventually this can be used to for caching.
894 Note: Currently the version information is cached; this needs to be
895 changed before using this function in long lived programs.
900 my %param = validate_with(params => \@_,
901 spec => {bug => {type => SCALAR,
904 sourceversions => {type => ARRAYREF,
907 found => {type => ARRAYREF,
910 fixed => {type => ARRAYREF,
913 package => {type => SCALAR,
915 version_cache => {type => HASHREF,
920 # Resolve bugginess states (we might be looking at multiple
921 # architectures, say). Found wins, then fixed, then absent.
922 my $maxbuggy = 'absent';
923 for my $version (@{$param{sourceversions}}) {
924 my $buggy = buggy(bug => $param{bug},
926 found => $param{found},
927 fixed => $param{fixed},
928 version_cache => $param{version_cache},
929 package => $param{package},
931 if ($buggy eq 'found') {
933 } elsif ($buggy eq 'fixed') {
950 Returns the output of Debbugs::Versions::buggy for a particular
951 package, version and found/fixed set. Automatically turns found, fixed
952 and version into source/version strings.
954 Caching can be had by using the version_cache, but no attempt to check
955 to see if the on disk information is more recent than the cache is
956 made. [This will need to be fixed for long-lived processes.]
961 my %param = validate_with(params => \@_,
962 spec => {bug => {type => SCALAR,
965 found => {type => ARRAYREF,
968 fixed => {type => ARRAYREF,
971 version_cache => {type => HASHREF,
974 package => {type => SCALAR,
976 version => {type => SCALAR,
980 my @found = @{$param{found}};
981 my @fixed = @{$param{fixed}};
982 if (grep {$_ !~ m{/}} (@{$param{found}}, @{$param{fixed}})) {
983 # We have non-source version versions
984 @found = makesourceversions($param{package},undef,
987 @fixed = makesourceversions($param{package},undef,
991 if ($param{version} !~ m{/}) {
992 $param{version} = makesourceversions($param{package},undef,
996 # Figure out which source packages we need
998 @sources{map {m{(.+)/}; $1} @found} = (1) x @found;
999 @sources{map {m{(.+)/}; $1} @fixed} = (1) x @fixed;
1000 @sources{map {m{(.+)/}; $1} $param{version}} = 1;
1002 if (not defined $param{version_cache} or
1003 not exists $param{version_cache}{join(',',sort keys %sources)}) {
1004 $version = Debbugs::Versions->new(\&Debbugs::Versions::Dpkg::vercmp);
1005 foreach my $source (keys %sources) {
1006 my $srchash = substr $source, 0, 1;
1007 my $version_fh = new IO::File "$config{version_packages_dir}/$srchash/$source", 'r' or
1008 warn "Unable to open $config{version_packages_dir}/$srchash/$source: $!" and next;
1009 $version->load($version_fh);
1011 if (defined $param{version_cache}) {
1012 $param{version_cache}{join(',',sort keys %sources)} = $version;
1016 $version = $param{version_cache}{join(',',sort keys %sources)};
1018 return $version->buggy($param{version},\@found,\@fixed);
1021 sub isstrongseverity {
1022 my $severity = shift;
1023 $severity = $config{default_severity} if $severity eq '';
1024 return grep { $_ eq $severity } @{$config{strong_severities}};
1028 =head1 PRIVATE FUNCTIONS
1032 sub update_realtime {
1033 my ($file, $bug, $new) = @_;
1035 # update realtime index.db
1037 open(IDXDB, "<$file") or die "Couldn't open $file";
1038 open(IDXNEW, ">$file.new");
1042 while($line = <IDXDB>) {
1043 @line = split /\s/, $line;
1044 last if ($line[1] >= $bug);
1049 if ($new eq "NOCHANGE") {
1050 print IDXNEW $line if ($line ne "" and $line[1] == $bug);
1051 } elsif ($new eq "REMOVE") {
1056 if (defined $line and $line ne "" and @line and $line[1] > $bug) {
1061 print IDXNEW while(<IDXDB>);
1066 rename("$file.new", $file);
1071 sub bughook_archive {
1073 &filelock("debbugs.trace.lock");
1074 &appendfile("debbugs.trace","archive $ref\n");
1075 my $line = update_realtime(
1076 "$config{spool_dir}/index.db.realtime",
1079 update_realtime("$config{spool_dir}/index.archive.realtime",
1085 my ( $type, $ref, $data ) = @_;
1086 &filelock("debbugs.trace.lock");
1088 &appendfile("debbugs.trace","$type $ref\n",makestatus($data, 1));
1090 my $whendone = "open";
1091 my $severity = $config{default_severity};
1092 (my $pkglist = $data->{package}) =~ s/[,\s]+/,/g;
1093 $pkglist =~ s/^,+//;
1094 $pkglist =~ s/,+$//;
1095 $whendone = "forwarded" if defined $data->{forwarded} and length $data->{forwarded};
1096 $whendone = "done" if defined $data->{done} and length $data->{done};
1097 $severity = $data->{severity} if length $data->{severity};
1099 my $k = sprintf "%s %d %d %s [%s] %s %s\n",
1100 $pkglist, $ref, $data->{date}, $whendone,
1101 $data->{originator}, $severity, $data->{keywords};
1103 update_realtime("$config{spool_dir}/index.db.realtime", $ref, $k);