5 Copyright (c) 2003-2010, Andrew Dunstan
7 See accompanying License file for license details
11 use vars qw($VERSION); $VERSION = 'REL_0.1';
15 no warnings qw(once); # suppress spurious warning about conf structure
18 use HTTP::Request::Common;
20 use Digest::SHA qw(sha1_hex);
23 # copy command line before processing - so we can later report it
26 my @invocation_args = (@ARGV);
28 my $buildconf = "build-farm.conf"; # default value
29 my ($sys_notes,$help,$del);
32 'config=s' => \$buildconf,
35 )|| usage("bad command line");
39 usage("No extra args allowed")
42 usage("must not specify notes if delete flag used")
43 if $del && defined($sys_notes);
48 usage("must specify notes")
49 unless ($del || defined($sys_notes));
56 my ($target,$animal,$secret) =@EximBuild::conf{qw(target animal secret)};
58 $target =~ s/eximstatus.pl/addnotes.pl/;
60 # make the base64 data escape-proof; = is probably ok but no harm done
61 # this ensures that what is seen at the other end is EXACTLY what we
62 # see when we calculate the signature
64 map{ $_ ||= ""; $_ = encode_base64($_,""); tr/+=/$@/; }($sys_notes);
66 my $content = "animal=$animal\&sysnotes=$sys_notes";
68 my $sig= sha1_hex($content,$secret);
70 # set environment from config
71 while (my ($envkey,$envval) = each %{$EximBuild::conf{build_env}})
73 $ENV{$envkey}=$envval;
76 my $ua = new LWP::UserAgent;
77 $ua->agent("Exim Build Farm Reporter");
78 if (my $proxy = $ENV{BF_PROXY})
80 $ua->proxy('http',$proxy);
83 my $request=HTTP::Request->new(POST => "$target/$sig");
84 $request->content_type("application/x-www-form-urlencoded");
85 $request->content($content);
87 my $response=$ua->request($request);
89 unless ($response->is_success)
92 "Query for: animal=$animal\n",
93 "Target: $target/$sig\n",
94 "Query Content: $content\n";
95 print "Status Line: ",$response->status_line,"\n";
96 print "Content: \n", $response->content,"\n";
102 #######################################################################
106 my $opt_message = shift;
107 print "$opt_message\n" if $opt_message;
109 set_notes.pl [ option ... ] notes
111 set_notes.pl --delete [ option ... ]
113 where option is one or more of
114 --config=path /path/to/buildfarm.conf
115 --help get this message
118 exit defined($opt_message)+0;