-
Notifications
You must be signed in to change notification settings - Fork 3
/
sink.pl
executable file
·59 lines (52 loc) · 1.46 KB
/
sink.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl -w
use strict;
# zypper in perl-SOAP-Lite perl-LWP-Protocol-https perl-XMLRPC-Lite perl-MLDBM perl-JSON-XS
# usage: ./sink.pl
# uses entries from queue/ to post updates
use MLDBM qw(DB_File Storable);
use Fcntl qw(:DEFAULT :flock);
use lib ".";
use config;
use common;
use obssupport;
open(my $fh, '>>', ".lockfile") or die $!;
flock($fh, LOCK_EX) or die $!;
my %data;
my $dbname="issuemention.dbm";
tie(%data, "MLDBM", $dbname, O_RDWR|O_CREAT, 0666) or die "error opening DB: $!";
my %bugmap1=%data;
my %bugmap2=%bugmap1;
untie(%data);
sub diag(@) #{print @_,"\n"}
{}
my @sinks = glob("sink/*.pm");
my $mentions = common::getcumulatedqueue();
foreach my $mention (keys %$mentions) {
my $e1 = $mentions->{$mention};
foreach my $id (keys %$e1) {
my $e = $e1->{$id};
my ($sr, $extra) = ($id, $e->{extra});
diag("$sr ($extra) mention: $mention");
addentry(\%bugmap2, $mention, $sr);
addsrinfo($sr, $extra);
}
}
# check which entries were new
foreach our $bugid (sort(keys(%bugmap2))) {
our $diff=common::diffhash($bugmap2{$bugid}, $bugmap1{$bugid});
if($diff && @$diff) {
for my $sink (@sinks) {
my $ret = do $sink; # uses $bugid and $diff
if($ret) {
print "OK\n";
} else {
print "failed\n";
$bugmap2{$bugid} = $bugmap1{$bugid}; # avoid adding it as done
}
}
}
}
tie(%data, "MLDBM", $dbname, O_RDWR|O_CREAT, 0666) or die "error opening DB: $!";
%data=%bugmap2;
untie(%data);
close($fh) or die $!;