#!/usr/bin/perl use strict; use warnings; use BZ::Client; use BZ::Client::Bug; use Config::Record; my $cfg = Config::Record->new(file => "todo.cfg"); my $server = $cfg->get("bugzilla/server", "https://bugzilla.redhat.com"); my $username = $cfg->get("bugzilla/username"); my $password = $cfg->get("bugzilla/password"); my $product = $cfg->get("query/product", "Virtualization Tools"); my $todoalias = $cfg->get("query/todoalias", "libvirtTodo"); my $title = $cfg->get("output/title", undef); my $blurb = $cfg->get("output/blurb", undef); $SIG{__DIE__} = sub { my $err = shift; if (UNIVERSAL::isa($err, "BZ::Client::Exception")) { die "Unable to access bugzilla: " . $err->message; } die $err; }; my $client = BZ::Client->new(url => $server, user => $username, password => $password); my $todo = BZ::Client::Bug->search($client, {'product' => $product, 'alias' => $todoalias}); die "Cannot find bug alias 'libvirtTodo'" unless $#{$todo} > -1; my $todoid = $todo->[0]->{'bug_id'}; my $todosummary = $todo->[0]->{'short_desc'}; $todosummary =~ s/^\s*RFE\s*:\s*//; $todosummary =~ s/^\s*\[\s*RFE\s*\]\s*:?\s*//; $todosummary =~ s/^\s*Tracker\s*:\s*//; my $trackers = BZ::Client::Bug->search($client, {'product' => $product, 'blocked' => $todoid }); my @trackers; foreach my $tracker (@{$trackers}) { my $summary = $tracker->{'short_desc'}; $summary =~ s/^\s*RFE\s*:\s*//; $summary =~ s/^\s*\[\s*RFE\s*\]\s*:?\s*//; $summary =~ s/^\s*Tracker\s*:\s*//; push @trackers, { id => $tracker->{'bug_id'}, summary => $summary, features => [], }; } foreach my $tracker (@trackers) { my $features = BZ::Client::Bug->search($client, {'product' => $product, 'blocked' => $tracker->{id}}); foreach my $feature (@{$features}) { my $summary = $feature->{'short_desc'}; $summary =~ s/^\s*RFE\s*:\s*//; $summary =~ s/^\s*\[\s*RFE\s*\]\s*:?\s*//; push @{$tracker->{features}}, { id => $feature->{'bug_id'}, summary => $summary, }; } } sub escape { my $txt = shift; $txt =~ s/&/&/g; $txt =~ s/</g; $txt =~ s/>/>/g; return $txt; }; print "\n"; print "\n"; print "
\n"; if (defined $title) { print "\n"; print $blurb; print "
\n"; } foreach my $tracker (sort { $a->{summary} cmp $b->{summary} } @trackers) { next unless $#{$tracker->{features}} >= 0; my $summary = &escape($tracker->{summary}); my $id = $tracker->{id}; print "\n"; print " This page is automatically generated from ", &escape($todosummary), "\n"; print "
\n"; print " \n"; print "\n";