#!/usr/bin/perl -w # Small script to remove "keywords" from the "Whiteboard status" field in # Bugzilla. # No guarantees given... # Created by Allan Beaufour use strict; use HTML::Form; use HTTP::Request; use LWP::UserAgent; use HTTP::Cookies::Netscape; # XXX XXX CHANGE THIS: my $cookieloc = "$ENV{HOME}/.mozilla/firefox/dxwwwdkc.default/cookies.txt"; sub help() { print "Usage: wb-remove [bugnum ]*\n\n"; } my $keyword = shift || help() && die "Keyword must be first parameter!"; my $bugnum = shift || help() && die "Must have at least one bug as parameter"; my $cookies = HTTP::Cookies::Netscape->new(file => $cookieloc) || die "Could not read cookies file"; my $ua = LWP::UserAgent->new || die "Failed to create LWP::UserAgent"; $ua->cookie_jar($cookies); while ($bugnum) { print "Checking bug $bugnum ...\n"; my $uri = "https://bugzilla.mozilla.org/show_bug.cgi?id=$bugnum"; my $request = HTTP::Request->new(GET => $uri); my $response = $ua->request($request) || die "Could not get URI: $uri"; my $form = HTML::Form->parse($response->content, $uri) || die "Could not parse form!"; # Check for presence my $whiteboard = $form->value("status_whiteboard"); print "\tWhiteboard = '$whiteboard'\n"; if ($whiteboard =~ $keyword) { print "\t\tHas keyword!\n"; $whiteboard =~ s/$keyword//; print "\t\tNew value = '$whiteboard'\n"; $form->value("status_whiteboard", $whiteboard); print "\tSaving ...\n"; $request = $form->make_request() || die "Could not make request"; $response = $ua->request($request) || die "Could not submit form!"; if ($response->content =~ "Log in to Bugzilla") { die "\tLogin was probably wrong!!\n"; } } # Next bug $bugnum = shift; }