Fix multiple lines returned for animal on status page
[buildfarm-server.git] / scripts / re_cmp_version_system.pl
1 #!/usr/bin/perl
2 # Update the ompiler version for a system
3
4 use strict;
5 use warnings;
6 use DBI;
7 use Data::Dumper;
8
9 die "Must pass current sysname and new version-string\n" unless scalar @ARGV == 2;
10
11 use vars qw($dbhost $dbname $dbuser $dbpass $dbport
12             $user_list_format
13 );
14
15 use FindBin qw($RealBin);
16 require "$RealBin/../BuildFarmWeb.pl";
17
18 die "no dbname" unless $dbname;
19 die "no dbuser" unless $dbuser;
20
21 my $dsn="dbi:Pg:dbname=$dbname";
22 $dsn .= ";host=$dbhost" if $dbhost;
23 $dsn .= ";port=$dbport" if $dbport;
24
25 my $db = DBI->connect($dsn,$dbuser,$dbpass);
26
27 die $DBI::errstr unless $db;
28
29 my $sth_up = $db->prepare(q[
30        UPDATE buildsystems AS b
31        SET compiler_version = ?
32        WHERE name = ?
33       ]);
34 $sth_up->execute($ARGV[1],$ARGV[0]);
35
36 my $sth = $db->prepare(q[ 
37        SELECT name, status, compiler, compiler_version, sys_owner, owner_email
38        FROM buildsystems AS b
39        ORDER BY name ASC
40       ]);
41 $sth->execute();
42
43 printf $user_list_format,
44        "SysName", "Status", "Owner", "Email", "Compiler", "Version";
45 while (my $row = $sth->fetchrow_hashref)
46 {
47   printf $user_list_format,
48                   $row->{name}, $row->{status}, $row->{sys_owner},
49                   $row->{owner_email}, $row->{compiler}, $row->{compiler_version};
50 }
51 $db->disconnect();