Annotation of FreeBSD/tinderbox/webui/module/moduleBuildPorts.php, revision 1.1.1.1.2.1
1.1 as 1: <?php
2: #-
3: # Copyright (c) 2005 Oliver Lehmann <oliver@FreeBSD.org>
4: # All rights reserved.
5: #
6: # Redistribution and use in source and binary forms, with or without
7: # modification, are permitted provided that the following conditions
8: # are met:
9: # 1. Redistributions of source code must retain the above copyright
10: # notice, this list of conditions and the following disclaimer
11: # 2. Redistributions in binary form must reproduce the above copyright
12: # notice, this list of conditions and the following disclaimer in the
13: # documentation and/or other materials provided with the distribution.
14: #
15: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16: # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17: # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18: # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19: # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20: # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21: # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22: # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23: # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24: # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25: # SUCH DAMAGE.
26: #
1.1.1.1.2.1! as 27: # $Paefchen$
1.1 as 28: # $MCom: portstools/tinderbox/webui/module/moduleBuildPorts.php,v 1.14 2007/10/07 00:58:56 ade Exp $
29: #
30:
31: class moduleBuildPorts extends module {
1.1.1.1.2.1! as 32: private $modulePorts = null;
1.1 as 33:
1.1.1.1.2.1! as 34: public function __construct() {
! 35: parent::__construct();
! 36: $this->modulePorts = new modulePorts;
1.1 as 37: }
38:
1.1.1.1.2.1! as 39: public function display_list_buildports( $build_name, $sort ) {
1.1 as 40:
41: $build = $this->TinderboxDS->getBuildByName( $build_name );
42: $ports = $this->TinderboxDS->getPortsForBuild( $build, $sort );
43: $ports_tree = $this->TinderboxDS->getPortsTreeById( $build->getPortsTreeId() );
44: $jail = $this->TinderboxDS->getJailById( $build->getJailId() );
45:
46: if( is_array( $ports ) && count( $ports ) > 0 ) {
47: $this->template_assign( 'data', $this->modulePorts->get_list_data( $build_name, $ports ) );
48: $this->template_assign( 'no_list', false );
49: } else {
50: $this->template_assign( 'no_list', true );
51: }
52:
53: foreach( $this->TinderboxDS->getAllPortFailReasons() as $reason ) {
54: $port_fail_reasons[$reason->getTag()]['tag'] = htmlentities($reason->getTag());
55: $port_fail_reasons[$reason->getTag()]['descr'] = $reason->getDescr();
56: $port_fail_reasons[$reason->getTag()]['type'] = $reason->getType();
57: $port_fail_reasons[$reason->getTag()]['link'] = true;
58: }
59:
60: foreach ( $ports as $port ) {
61: if ( $port->getLastFailedDep() != "" ) {
62: $depreason = $port->getLastFailedDep();
63: $port_fail_reasons[$depreason]['tag'] = htmlentities( $depreason );
64: $port_fail_reasons[$depreason]['descr'] = htmlentities( "Port was not built since dependency $depreason failed." );
65: $port_fail_reasons[$depreason]['type'] = 'COMMON';
66: $port_fail_reasons[$depreason]['link'] = false;
67:
68: }
69: }
70:
71: $qs = array();
72: $qkvs = explode('&', $_SERVER['QUERY_STRING']);
73: foreach ($qkvs as $qkv) {
74: $kv = explode('=', $qkv);
75: $qs[$kv[0]] = $kv[1];
76: }
77:
78: $this->template_assign( 'port_fail_reasons', $port_fail_reasons );
79: $this->template_assign( 'maintainers', $this->TinderboxDS->getAllMaintainers() );
80: $this->template_assign( 'build_description', $build->getDescription() );
81: $this->template_assign( 'build_name', $build_name );
82: $this->template_assign( 'jail_name', $jail->getName() );
83: $this->template_assign( 'jail_tag', $jail->getTag() );
84: $this->template_assign( 'jail_lastbuilt', prettyDatetime( $jail->getLastBuilt() ) );
85: $this->template_assign( 'ports_tree_description', $ports_tree->getDescription() );
86: $this->template_assign( 'ports_tree_lastbuilt', prettyDatetime( $ports_tree->getLastBuilt() ) );
87: $this->template_assign( 'local_time', prettyDatetime( date( 'Y-m-d H:i:s' ) ) );
88: $this->template_assign( 'querystring', $qs);
89:
90: return $this->template_parse( 'list_buildports.tpl' );
91: }
92:
1.1.1.1.2.1! as 93: public function display_failed_buildports( $build_name, $maintainer, $all ) {
1.1 as 94:
95: if( $build_name ) {
96: $build = $this->TinderboxDS->getBuildByName( $build_name );
97: $build_id = $build->getId();
98: } else {
99: $build_id = false;
100: }
101:
102: if ($all) {
103: $ports = $this->TinderboxDS->getPortsByStatus( $build_id, $maintainer, '', 'SUCCESS' );
104: } else {
105: $ports = $this->TinderboxDS->getPortsByStatus( $build_id, $maintainer, 'FAIL', '' );
106: }
107:
108: if( is_array( $ports ) && count( $ports ) > 0 ) {
109: $this->template_assign( 'data', $this->modulePorts->get_list_data( $build_name, $ports ) );
110: $this->template_assign( 'no_list', false );
111: } else {
112: $this->template_assign( 'no_list', true );
113: }
114:
115: foreach( $this->TinderboxDS->getAllPortFailReasons() as $reason ) {
116: $port_fail_reasons[$reason->getTag()]['tag'] = htmlentities($reason->getTag());
117: $port_fail_reasons[$reason->getTag()]['descr'] = $reason->getDescr();
118: $port_fail_reasons[$reason->getTag()]['type'] = $reason->getType();
119: $port_fail_reasons[$reason->getTag()]['link'] = true;
120: }
121:
122: foreach ( $ports as $port ) {
123: if ( $port->getLastFailedDep() != "" ) {
124: $depreason = $port->getLastFailedDep();
125: $port_fail_reasons[$depreason]['tag'] = htmlentities( $depreason );
126: $port_fail_reasons[$depreason]['descr'] = htmlentities( "Port was not built since dependency $depreason failed." );
127: $port_fail_reasons[$depreason]['type'] = 'COMMON';
128: $port_fail_reasons[$depreason]['link'] = false;
129: }
130: }
131:
132: $this->template_assign( 'port_fail_reasons', $port_fail_reasons );
133: $this->template_assign( 'build_name', $build_name );
134: $this->template_assign( 'maintainer', $maintainer );
135: $this->template_assign( 'local_time', prettyDatetime( date( 'Y-m-d H:i:s' ) ) );
136:
137: return $this->template_parse( 'failed_buildports.tpl' );
138: }
139:
1.1.1.1.2.1! as 140: public function display_latest_buildports( $build_name ) {
1.1 as 141:
142: $current_builds = $this->display_current_buildports( $build_name );
143:
144: if( $build_name ) {
145: $build = $this->TinderboxDS->getBuildByName( $build_name );
146: $build_id = $build->getId();
147: } else {
148: $build_id = false;
149: }
150:
151: $ports = $this->TinderboxDS->getLatestPorts( $build_id, 20 );
152:
153: if( is_array( $ports ) && count( $ports ) > 0 ) {
154: $this->template_assign( 'data', $this->modulePorts->get_list_data( $build_name, $ports ) );
155: $this->template_assign( 'no_list', false );
156: } else {
157: $this->template_assign( 'no_list', true );
158: }
159:
160: foreach( $this->TinderboxDS->getAllPortFailReasons() as $reason ) {
161: $port_fail_reasons[$reason->getTag()]['tag'] = htmlentities($reason->getTag());
162: $port_fail_reasons[$reason->getTag()]['descr'] = $reason->getDescr();
163: $port_fail_reasons[$reason->getTag()]['type'] = $reason->getType();
164: $port_fail_reasons[$reason->getTag()]['link'] = true;
165: }
166:
167: foreach ( $ports as $port ) {
168: if ( $port->getLastFailedDep() != "" ) {
169: $depreason = $port->getLastFailedDep();
170: $port_fail_reasons[$depreason]['tag'] = htmlentities( $depreason );
171: $port_fail_reasons[$depreason]['descr'] = htmlentities( "Port was not built since dependency $depreason failed." );
172: $port_fail_reasons[$depreason]['type'] = 'COMMON';
173: $port_fail_reasons[$depreason]['link'] = false;
174: }
175: }
176:
177: $this->template_assign( 'port_fail_reasons', $port_fail_reasons );
178: $this->template_assign( 'current_builds', $current_builds );
179: $this->template_assign( 'build_name', $build_name );
180: $this->template_assign( 'local_time', prettyDatetime( date( 'Y-m-d H:i:s' ) ) );
181:
182: return $this->template_parse( 'latest_buildports.tpl' );
183: }
184:
1.1.1.1.2.1! as 185: public function display_current_buildports( $showbuild ) {
1.1 as 186: $activeBuilds = array();
187: $builds = $this->TinderboxDS->getBuilds();
188: if( $builds ) {
189: foreach( $builds as $build ) {
190: if( empty( $showbuild ) || $build->getName() == $showbuild ) {
191: if( $build->getBuildStatus() == 'PORTBUILD' ) {
192: $activeBuilds[] = $build;
193: }
194: }
195: }
196: }
197:
198: if( sizeof( $activeBuilds ) > 0 ) {
199: $i = 0;
200: foreach( $activeBuilds as $build ) {
201: if( $build->getBuildCurrentPort() )
202: $data[$i]['port_current_version'] = $build->getBuildCurrentPort();
203: else
204: $data[$i]['port_current_version'] = preparing_next_build;
205:
206: $data[$i]['build_name'] = $build->getName();
207: $data[$i]['build_last_updated'] = $build->getBuildLastUpdated();
208: $data[$i]['build_eta'] = 'N/A';
209: $currport = $this->TinderboxDS->getCurrentPortForBuild($build->getId());
210: if (!is_null($currport)) {
211: $bp = $this->TinderboxDS->getBuildPorts($currport->getId(), $build->getId());
212: $as = explode(" ", $build->getBuildLastUpdated());
213: $ymd = explode("-", $as[0]);
214: $hms = explode(":", $as[1]);
215: $then = mktime($hms[0], $hms[1], $hms[2], $ymd[1], $ymd[2], $ymd[0]);
216: $diff = time() - $then;
217: if ($bp->getLastRunDuration() - $diff >= 0)
218: $data[$i]['build_eta'] = $bp->getLastRunDuration() - $diff;
219: }
220: $i++;
221: }
222: $this->template_assign( 'data', $data );
223: $this->template_assign( 'no_list', false );
224: } else {
225: $this->template_assign( 'no_list', true );
226: }
227:
228: $this->template_assign( 'build_name', $showbuild );
229:
230: return $this->template_parse( 'current_buildports.tpl' );
231: }
232: }
1.1.1.1.2.1! as 233:
1.1 as 234: ?>