3 require('/etc/debbugs/config');
4 require('/usr/lib/debbugs/errorlib');
5 $ENV{'PATH'}= '/usr/lib/debbugs'.$ENV{'PATH'};
6 chdir("$gSpoolDir") || die "chdir spool: $!\n";
7 #push(@INC,'/usr/lib/debbugs');
11 defined($startdate= time) || &quit("failed to get time: $!");
13 opendir(DIR,"db") || &quit("opendir db: $!\n");
14 @list= grep(m/^\d+\.status$/,readdir(DIR));
15 grep(s/\.status$//,@list);
16 @list= sort { $a <=> $b } @list;
18 while (length($ref=shift(@list))) {
19 #print DEBUG "$ref $considering\n";
20 $bfound= &lockreadbugmerge($ref);
21 #print DEBUG "$ref read $bfound\n";
23 #print DEBUG "$ref read ok (done $s_done)\n";
24 (&unlockreadbugmerge($bfound), next) unless length($s_done);
25 #print DEBUG "$ref read done\n";
27 if (length($s_mergedwith)) { push(@aref,split/ /,$s_mergedwith); }
28 #print DEBUG "$ref aref @aref\n";
31 #print DEBUG "$ref $mref check\n";
33 #print DEBUG "$ref $mref reading\n";
34 &lockreadbug($mref) || die "huh ?";
35 #print DEBUG "$ref $mref read ok\n";
38 #print DEBUG "$ref $mref read/not\n";
39 $expectmerge= join(' ',grep($_ != $mref, sort { $a <=> $b } @aref));
40 $s_mergedwith eq $expectmerge ||
41 die "$ref -> $mref: ($s_mergedwith) vs. ($expectmerge) (@aref)";
42 #print DEBUG "$ref $mref merge-ok\n";
43 length($s_done) || die "$ref -> $mref";
44 #print DEBUG "$ref $mref done-ok\n";
45 $days= -M "db/$mref.log";
46 #print DEBUG "$ref $mref days $days\n";
47 if ($days <= $gRemoveAge) {
48 #print DEBUG "$ref $mref saved\n";
53 #print DEBUG "$ref removing\n";
55 #print DEBUG "$ref removing $mref\n";
56 unlink("db/$mref.log", "db/$mref.status", "db/$mref.report");
57 print("deleted $mref (from $ref)\n") || &quit("output old: $!");
60 #print DEBUG "$ref unlocking $bfound\n";
61 for ($i=0; $i<$bfound; $i++) { &unfilelock; }
62 #print DEBUG "$ref unlocking done\n";
65 close(STDOUT) || &quit("close stdout: $!");