die_xml_error($p,$dbh,"Must specify a machine name!");
}
my$os=$p->param('os')||"";
my$os_version=$p->param('os_version')||"";
my$compiler=$p->param('compiler')||"";
my$status=$p->param('status')||0;
my$clobber=$p->param('clobber')||0;
#
# Get data for response
#
my$tree_info=$dbh->selectrow_arrayref("SELECT new_machines_visible FROM tbox_tree WHERE tree_name = ?",undef,$tree);
if(!defined($tree_info)){
die_xml_error($p,$dbh,"Could not get tree!");
}
my($new_machines_visible)=@{$tree_info};
my$patch_ids=$dbh->selectcol_arrayref("SELECT patch_id FROM tbox_patch WHERE tree_name = ? AND in_use",undef,$tree);
if(!$patch_ids){
die_xml_error($p,$dbh,"Could not get patches!");
}
#
# Insert the machine into the machines table if it is not there
#
my$machine_info=$dbh->selectrow_arrayref("SELECT machine_id, commands FROM tbox_machine WHERE tree_name = ? AND machine_name = ? AND os = ? AND os_version = ? AND compiler = ?",undef,$tree,$machine_name,$os,$os_version,$compiler);
my$sth=$dbh->prepare("SELECT name, value FROM tbox_initial_machine_config WHERE tree_name = ?");
$sth->execute($tree);
while(my$row=$sth->fetchrow_arrayref()){
$machine_config{$row->[0]}=$row->[1];
}
$sth=$dbh->prepare("SELECT name, value FROM tbox_machine_config WHERE machine_id = ?");
$sth->execute($machine_id);
while(my$row=$sth->fetchrow_arrayref()){
$machine_config{$row->[0]}=$row->[1];
}
{
#
# Close the last old build info if there is one and it was incomplete
#
my$last_build=$dbh->selectrow_arrayref("SELECT status, build_time, log FROM tbox_build WHERE machine_id = ? ORDER BY build_time DESC LIMIT 1",undef,$machine_id);
if(defined($last_build)&&$last_build->[0]>=0&&
$last_build->[0]<100){
my$rows=$dbh->do("UPDATE tbox_build SET status = ? WHERE machine_id = ? AND build_time = ?",undef,$last_build->[0]+300,$machine_id,$last_build->[1]);
# We have to compress the log too, be a good citizen
compress_log($machine_id,$last_build->[2]);
}
# Create logfile
my$log=create_logfile_name($machine_id);
my$fh=get_log_fh($machine_id,$log,">");
close$fh;
#
# Insert a new build info signifying that the build has started