More nitpicking and patches
Edwin Groothuis
edwin at mavetju.org
Wed Dec 28 08:08:33 EST 2005
- I've attached a patch to automatically reload the "Latest Builds".
When there is an active build, it refreshes every 15 seconds. If
there is no active build, it refreshes every 5 minutes.
- Email_On_Completion is a boolean in postgresql, and a tinyint in
mysql. Which gives me a:
SELECT * FROM users WHERE User_Id IN (SELECT User_Id FROM build_users WHERE Build_Id=$1 AND Email_On_Completion=1)
ERROR Moperator does not exist: boolean = integer.No operator matches the given name and argument type(s). You may need to add explicit type casts..Fparse_oper.c.L786.Rop_error..
(yes, bad ngrep output, sue me)
I think this can only be fixed by changing the type from boolean
to int, since the place where it is called (lib/TinderboxDS.pm:1111)
is a "global" function for queries:
$rc = $self->_doQueryHashRef(
"SELECT * FROM users WHERE User_Id IN (SELECT User_Id FROM
build_users WHERE Build_Id=? AND $field=1)",
\@results, $build->getId()
);
- tc is not clean:
[/usr/local/tinderbox/scripts] root at k7>perl -wc tc
Use of comma-less variable list is deprecated at tc line 892.
Use of comma-less variable list is deprecated at tc line 892.
Use of comma-less variable list is deprecated at tc line 963.
Use of comma-less variable list is deprecated at tc line 963.
- core/TinderboxDS.php, function getPortById() doesn't work.
- I have attached a patch to keep track on how long the build attempt
lasted, so that a. you can see how long a previous build attempt
lasted (can I get coffee or should I wait the thirteen seconds?)
and how long the current port will last (twenty more seconds!)
Build Port Duration ETA
5.4-FreeBSD dhcpdump-1.7 00:02 01:06
It adds a new function to core/TinderboxDS.php called time_elapsed(),
and a quick change to time_difference() in the patches submitted
last week.
It requires a change in the database, in Builds and in Build_Ports,
and a change in the arguments for "tc updateBuildCurrentPort" so
that the Builds table know which port is being rebuild instead
of only knowing the packagename.
Happy MMVI, Edwin
--
Edwin Groothuis | Personal website: http://www.mavetju.org
edwin at mavetju.org | Weblog: http://weblog.barnet.com.au/edwin/
-------------- next part --------------
diff -ru scripts-2.2.1/www-exp/templates/default/current_buildports.tpl scripts/www-exp/templates/default/current_buildports.tpl
--- scripts-2.2.1/www-exp/templates/default/current_buildports.tpl Wed Dec 28 13:44:52 2005
+++ scripts/www-exp/templates/default/current_buildports.tpl Wed Dec 28 14:08:59 2005
@@ -19,4 +19,8 @@
</tr>
<?}?>
</table>
+ <script language="javascript">
+ setTimeout("reloadpage()",15000)
+ </script>
+
<?}?>
diff -ru scripts-2.2.1/www-exp/templates/default/latest_buildports.tpl scripts/www-exp/templates/default/latest_buildports.tpl
--- scripts-2.2.1/www-exp/templates/default/latest_buildports.tpl Wed Dec 28 13:44:52 2005
+++ scripts/www-exp/templates/default/latest_buildports.tpl Wed Dec 28 14:07:45 2005
@@ -1,6 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
+<script language="javascript">
+ function reloadpage() {
+ document.location.reload();
+ }
+ setTimeout("reloadpage()",300000)
+</script>
<!-- $MCom: portstools/tinderbox/www-exp/templates/default/latest_buildports.tpl,v 1.2.2.1 2005/10/23 21:42:29 marcus Exp $ //-->
<title><?=$tinderbox_name?></title>
<link href="<?=$templatesuri?>/tinderstyle.css" rel="stylesheet" type="text/css" />
-------------- next part --------------
diff -ru scripts-2.2.1r1/lib/TinderboxDS.pm scripts/lib/TinderboxDS.pm
--- scripts-2.2.1r1/lib/TinderboxDS.pm Wed Dec 28 14:26:10 2005
+++ scripts/lib/TinderboxDS.pm Wed Dec 28 22:43:18 2005
@@ -892,6 +892,29 @@
sub updatePortLastBuilt {
my $self = shift;
+
+ # copy the time from now() minus builds.build_last_updated
+ # to build_ports.last_run_duration
+ {
+ my $port = $_[0];
+ my $build = $_[1];
+ my $rc;
+ my @results;
+
+ $rc = $self->_doQueryHashRef(
+ "SELECT 'now'-Build_Last_uPdated as d FROM Builds WHERE Build_Id=?",
+ \@results, $build->getId()
+ );
+
+ my @a=split(/:/,substr($results[0]{d},0,8));
+ my $d=$a[0]*3600+$a[1]*60+$a[2];
+
+ $self->_doQuery(
+ "UPDATE Build_Ports SET Last_Run_Duration=? WHERE Port_Id=? AND Build_Id=?",
+ [$d, $port->getId(), $build->getId()]
+ );
+ }
+
return $self->updatePortLastBuilts(@_, "Last_Built");
}
@@ -911,6 +934,7 @@
my $build = shift;
my $last_built = shift;
my $column = shift;
+
croak "ERROR: Argument 1 not of type Port\n" if (ref($port) ne "Port");
croak "ERROR: Argument 2 not of type Build\n"
if (ref($build) ne "Build");
@@ -1058,6 +1082,7 @@
sub updateBuildCurrentPort {
my $self = shift;
my $build = shift;
+ my $port = shift;
my $pkgname = shift;
croak "ERROR: Argument 1 not of type build\n"
if (ref($build) ne "Build");
@@ -1065,13 +1090,13 @@
my $rc;
if (!defined($pkgname)) {
$rc = $self->_doQuery(
- "UPDATE builds SET Build_Current_Port=NULL,Build_Last_Updated='now' WHERE Build_Id=?",
+ "UPDATE builds SET Port_Id=NULL,Build_Current_Port=NULL,Build_Last_Updated='now' WHERE Build_Id=?",
[$build->getId()]
);
} else {
$rc = $self->_doQuery(
- "UPDATE builds SET Build_Current_Port=?,Build_Last_Updated='now' WHERE Build_Id=?",
- [$pkgname, $build->getId()]
+ "UPDATE builds SET Port_Id=?,Build_Current_Port=?,Build_Last_Updated='now' WHERE Build_Id=?",
+ [$port, $pkgname, $build->getId()]
);
}
diff -ru scripts-2.2.1r1/portbuild scripts/portbuild
--- scripts-2.2.1r1/portbuild Wed Dec 28 14:26:10 2005
+++ scripts/portbuild Wed Dec 28 23:10:27 2005
@@ -203,7 +203,7 @@
echo "building $pkgname in $chroot"
-${pb}/scripts/tc updateBuildCurrentPort -b ${branch} -n ${pkgname}
+${pb}/scripts/tc updateBuildCurrentPort -b ${branch} -n ${pkgname} -d ${portdir}
chroot=${pb}/${branch}
packages=${pb}/packages/${branch}
diff -ru scripts-2.2.1r1/tc scripts/tc
--- scripts-2.2.1r1/tc Wed Dec 28 14:26:10 2005
+++ scripts/tc Thu Dec 29 00:07:19 2005
@@ -407,8 +407,8 @@
func => \&updateBuildCurrentPort,
help =>
"Update the port currently being built for the specify build",
- usage => "-b <build name> [-n <package name>]",
- optstr => 'b:n:',
+ usage => "-b <build name> [-n <package name> -d <port directory>]",
+ optstr => 'b:n:d:',
},
"sendBuildCompletionMail" => {
func => \&sendBuildCompletionMail,
@@ -2429,7 +2429,7 @@
}
sub updateBuildCurrentPort {
- if (!$opts->{'b'}) {
+ if (!$opts->{'b'} && !$opts->{'d'}) {
usage("updateBuildCurrentPort");
}
@@ -2437,9 +2437,11 @@
cleanup($ds, 1, "Unknown build, " . $opts->{'b'} . "\n");
}
+ my $port = $ds->getPortByDirectory($opts->{'d'});
+
my $build = $ds->getBuildByName($opts->{'b'});
- $ds->updateBuildCurrentPort($build, $opts->{'n'})
+ $ds->updateBuildCurrentPort($build, $port->{Port_Id}, $opts->{'n'})
or cleanup($ds, 1,
"Failed to get last update build current port for build "
. $opts->{'b'} . ": "
diff -ru scripts-2.2.1r1/tinderbox-mysql.schema scripts/tinderbox-mysql.schema
--- scripts-2.2.1r1/tinderbox-mysql.schema Wed Dec 28 14:26:10 2005
+++ scripts/tinderbox-mysql.schema Wed Dec 28 21:22:55 2005
@@ -45,6 +45,7 @@
Build_Id int NOT NULL auto_increment,
Build_Name varchar(32) NOT NULL,
Jail_Id int NOT NULL,
+ Port_Id int NOT NULL,
Ports_Tree_Id int NOT NULL,
Build_Description text,
Build_Status enum('IDLE','PREPARE','PORTBUILD') DEFAULT 'IDLE',
@@ -124,6 +125,7 @@
Last_Fail_Reason varchar(20) NOT NULL DEFAULT '__nofail__',
Last_Successful_Built datetime,
Last_Built_Version varchar(100),
+ Last_Run_Duration int,
PRIMARY KEY (Build_Port_Id),
INDEX (Build_Id),
FOREIGN KEY (Build_Id)
diff -ru scripts-2.2.1r1/tinderbox-pgsql.schema scripts/tinderbox-pgsql.schema
--- scripts-2.2.1r1/tinderbox-pgsql.schema Wed Dec 28 14:26:10 2005
+++ scripts/tinderbox-pgsql.schema Wed Dec 28 21:23:45 2005
@@ -34,6 +34,7 @@
Build_Id SERIAL PRIMARY KEY,
Build_Name VARCHAR(32) UNIQUE NOT NULL,
Jail_Id INTEGER REFERENCES Jails(Jail_Id) ON UPDATE CASCADE ON DELETE RESTRICT,
+ Port_Id INTEGER,
Ports_Tree_Id INTEGER REFERENCES ports_trees(Ports_Tree_Id) ON UPDATE CASCADE ON DELETE RESTRICT,
Build_Description TEXT,
Build_Status VARCHAR(16) CHECK (Build_Status IN ('IDLE','PREPARE','PORTBUILD')) DEFAULT 'IDLE',
@@ -91,7 +92,8 @@
Last_Status VARCHAR(16) CHECK (Last_Status IN ('UNKNOWN','SUCCESS','FAIL','BROKEN','LEFTOVERS','DUD')) DEFAULT 'UNKNOWN',
Last_Fail_Reason VARCHAR(20) NOT NULL DEFAULT '__nofail__' REFERENCES port_fail_reasons(Port_Fail_Reason_Tag) ON UPDATE CASCADE ON DELETE RESTRICT,
Last_Successful_Built TIMESTAMP,
- Last_Built_Version VARCHAR(100)
+ Last_Built_Version VARCHAR(100),
+ Last_Run_Duration int
);
-- DROP TABLE config CASCADE;
diff -ru scripts-2.2.1r1/www-exp/core/Build.php scripts/www-exp/core/Build.php
--- scripts-2.2.1r1/www-exp/core/Build.php Wed Dec 28 14:26:10 2005
+++ scripts/www-exp/core/Build.php Wed Dec 28 22:48:45 2005
@@ -36,6 +36,7 @@
'Build_Id' => '',
'Build_Name' => '',
'Jail_Id' => '',
+ 'Port_Id' => '',
'Ports_Tree_Id' => '',
'Build_Description' => '',
'Build_Status' => '',
@@ -56,6 +57,10 @@
function getJailId() {
return $this->Jail_Id;
+ }
+
+ function getPortId() {
+ return $this->Port_Id;
}
function getPortsTreeId() {
diff -ru scripts-2.2.1r1/www-exp/core/Port.php scripts/www-exp/core/Port.php
--- scripts-2.2.1r1/www-exp/core/Port.php Wed Dec 28 14:26:10 2005
+++ scripts/www-exp/core/Port.php Wed Dec 28 16:49:28 2005
@@ -43,7 +43,8 @@
'Last_Status' => '',
'Last_Successful_Built' => '',
'Last_Built_Version' => '',
- 'Last_Fail_Reason' => ''
+ 'Last_Fail_Reason' => '',
+ 'Last_Run_Duration' => ''
);
$this->TinderObject($object_hash, $argv);
@@ -91,6 +92,10 @@
function getLastFailReason() {
return $this->Last_Fail_Reason;
+ }
+
+ function getLastRunDuration() {
+ return $this->Last_Run_Duration;
}
function getLogfileName() {
diff -ru scripts-2.2.1r1/www-exp/core/TinderboxDS.php scripts/www-exp/core/TinderboxDS.php
--- scripts-2.2.1r1/www-exp/core/TinderboxDS.php Wed Dec 28 14:26:10 2005
+++ scripts/www-exp/core/TinderboxDS.php Thu Dec 29 00:00:57 2005
@@ -375,6 +375,7 @@
bp.Last_Status,
bp.Last_Successful_Built,
bp.Last_Built_Version,
+ bp.Last_Run_Duration,
CASE bp.Last_Fail_Reason
WHEN '__nofail__' THEN ''
ELSE bp.Last_Fail_Reason
@@ -404,6 +405,7 @@
bp.Last_Status,
bp.Last_Successful_Built,
bp.Last_Built_Version,
+ bp.Last_Run_Duration,
CASE bp.Last_Fail_Reason
WHEN '__nofail__' THEN ''
ELSE bp.Last_Fail_Reason
@@ -478,6 +480,13 @@
return $results[0];
}
+ function getBuildPorts($port_id,$build_id) {
+ $query = 'SELECT * FROM build_ports WHERE Build_Id = ? AND Port_Id = ?';
+ $rc = $this->_doQueryHashRef($query, $results, array($build_id, $port_id));
+ if (!$rc) return null;
+ return $results[0];
+ }
+
function getPortById($id) {
$results = $this->getPorts(array( 'Port_Id' => $id ));
@@ -857,7 +866,17 @@
$hms=explode(":",$as[1]);
$then=mktime($hms[0],$hms[1],$hms[2],$ymd[1],$ymd[2],$ymd[0]);
$diff=time()-$then;
- return sprintf("%02d:%02d:%02d",
- floor($diff/3600),floor(($diff%3600)/60),floor($diff%60));
+ return time_elapsed($diff);
}
+
+ function time_elapsed($c) {
+ if ($c===0 || $c=="")
+ return "-";
+ if ($c>=3600)
+ return sprintf("%0d:%02d:%02d",
+ floor($c/3600),floor(($c%3600)/60),floor($c%60));
+ return sprintf("%02d:%02d",
+ floor(($c%3600)/60),floor($c%60));
+ }
+
?>
diff -ru scripts-2.2.1r1/www-exp/module/moduleBuildPorts.php scripts/www-exp/module/moduleBuildPorts.php
--- scripts-2.2.1r1/www-exp/module/moduleBuildPorts.php Wed Dec 28 14:26:10 2005
+++ scripts/www-exp/module/moduleBuildPorts.php Wed Dec 28 23:53:27 2005
@@ -168,6 +168,18 @@
$data[$i]['build_name'] = $build->getName();
$data[$i]['build_last_updated'] = $build->getBuildLastUpdated();
+
+ $bp=$this->TinderboxDS->getBuildPorts($build->getPortId(),$build->getId());
+
+ $as=explode(" ",$build->getBuildLastUpdated());
+ $ymd=explode("-",$as[0]);
+ $hms=explode(":",$as[1]);
+ $then=mktime($hms[0],$hms[1],$hms[2],$ymd[1],$ymd[2],$ymd[0]);
+ $diff=time()-$then;
+
+ $data[$i]['build_eta'] = "n/a";
+ if ($bp["last_run_duration"] - $diff>=0)
+ $data[$i]['build_eta'] = $bp["last_run_duration"] - $diff;
$i++;
}
$this->template_assign( 'data', $data );
diff -ru scripts-2.2.1r1/www-exp/module/modulePorts.php scripts/www-exp/module/modulePorts.php
--- scripts-2.2.1r1/www-exp/module/modulePorts.php Wed Dec 28 14:26:10 2005
+++ scripts/www-exp/module/modulePorts.php Wed Dec 28 14:51:19 2005
@@ -91,6 +91,7 @@
$port_logfilename = $port->getLogfileName();
$port_link_logfile = $loguri . '/' . $build_name . '/' . $port_logfilename;
$port_link_package = $pkguri . '/' . $build_name . '/All/' . $port_last_built_version . $package_suffix;
+ $port_last_run_duration = $port->getLastRunDuration();
switch( $port->getLastStatus() ) {
case 'SUCCESS':
@@ -134,6 +135,7 @@
'port_last_built' => $this->TinderboxDS->prettyDatetime( $port->getLastBuilt() ),
'port_last_successful_built' => $this->TinderboxDS->prettyDatetime( $port->getLastSuccessfulBuilt() ),
'port_last_fail_reason' => htmlentities($port->getLastFailReason()),
+ 'port_last_run_duration' => $port_last_run_duration,
'port_link_logfile' => $port_link_logfile,
'port_link_package' => $port_link_package,
'status_field_class' => $status_field_class,
diff -ru scripts-2.2.1r1/www-exp/templates/default/current_buildports.tpl scripts/www-exp/templates/default/current_buildports.tpl
--- scripts-2.2.1r1/www-exp/templates/default/current_buildports.tpl Wed Dec 28 14:26:10 2005
+++ scripts/www-exp/templates/default/current_buildports.tpl Wed Dec 28 23:52:20 2005
@@ -10,12 +10,14 @@
<th>Build</th>
<th>Port</th>
<th>Duration</th>
+ <th>ETA</th>
</tr>
<?foreach($data as $row) {?>
<tr>
<td><a href="index.php?action=list_buildports&build=<?=$row['build_name']?>"><?=$row['build_name']?></a></td>
<td><?=$row['port_current_version']?></td>
- <td><?=time_difference_from_now($row['build_last_updated'])?></td>
+ <td align="right"><?=time_difference_from_now($row['build_last_updated'])?></td>
+ <td align="right"><?=is_string($row['build_eta'])?$row['build_eta']:time_elapsed($row['build_eta'])?></td>
</tr>
<?}?>
</table>
diff -ru scripts-2.2.1r1/www-exp/templates/default/latest_buildports.tpl scripts/www-exp/templates/default/latest_buildports.tpl
--- scripts-2.2.1r1/www-exp/templates/default/latest_buildports.tpl Wed Dec 28 14:26:10 2005
+++ scripts/www-exp/templates/default/latest_buildports.tpl Wed Dec 28 17:25:02 2005
@@ -31,6 +31,7 @@
<th> </th>
<th>Last Build Attempt</th>
<th>Last Successful Build</th>
+ <th>Duration</th>
</tr>
<?foreach($data as $row) {?>
@@ -53,6 +54,7 @@
</td>
<td><?=$row['port_last_built']?></td>
<td><?=$row['port_last_successful_built']?></td>
+ <td align="right"><?=time_elapsed($row['port_last_run_duration'])?></td>
</tr>
<?}?>
</table>
More information about the tinderbox-list
mailing list