5 Copyright (c) 2003-2010, Andrew Dunstan
7 See accompanying License file for license details
11 use vars qw($VERSION); $VERSION = '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 ($os_version, $compiler_version,$help);
32 'config=s' => \$buildconf,
34 'os-version=s' => \$os_version,
35 'compiler-version=s' => \$compiler_version,
36 )|| usage("bad command line");
38 usage("No extra args allowed")
44 usage("must specify at least one item to change")
45 unless ($os_version or $compiler_version);
52 my ($target,$animal,$secret,$upgrade_target) =
53 @EximBuild::conf{qw(target animal secret upgrade_target)};
55 # default for old config files
56 unless ($upgrade_target)
58 $upgrade_target = $target;
59 $upgrade_target =~ s/eximstatus.pl/upgrade.pl/;
62 # make the base64 data escape-proof; = is probably ok but no harm done
63 # this ensures that what is seen at the other end is EXACTLY what we
64 # see when we calculate the signature
66 map{ $_ ||= ""; $_ = encode_base64($_,""); tr/+=/$@/; }
67 ($os_version,$compiler_version);
71 my $content = "animal=$animal\&ts=$ts";
72 $content .= "\&new_os=$os_version" if $os_version;
73 $content .= "\&new_compiler=$compiler_version" if $compiler_version;
75 my $sig= sha1_hex($content,$secret);
77 # set environment from config
78 while (my ($envkey,$envval) = each %{$EximBuild::conf{build_env}})
80 $ENV{$envkey}=$envval;
83 my $ua = new LWP::UserAgent;
84 $ua->agent("Exim Build Farm Reporter");
85 if (my $proxy = $ENV{BF_PROXY})
87 $ua->proxy('http',$proxy);
90 my $request=HTTP::Request->new(POST => "$upgrade_target/$sig");
91 $request->content_type("application/x-www-form-urlencoded");
92 $request->content($content);
94 my $response=$ua->request($request);
96 unless ($response->is_success)
99 "Query for: animal=$animal&ts=$ts\n",
100 "Target: $upgrade_target/$sig\n",
101 "Query Content: $content\n";
102 print "Status Line: ",$response->status_line,"\n";
103 print "Content: \n", $response->content,"\n";
109 #######################################################################
113 my $opt_message = shift;
114 print "$opt_message\n" if $opt_message;
116 update_personality.pl [ option ... ]
117 where option is one or more of
118 --config=path /path/to/buildfarm.conf
119 --os-version=version new operating system version
120 --compiler-version=version new compiler version
121 --help get this message
124 exit defined($opt_message)+0;