Annotation of FreeBSD/tinderbox2/webui/module/moduleBuildPorts.php, revision 1.1.2.1
1.1.2.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: #
! 27: # $MCom: portstools/tinderbox/webui/module/moduleBuildPorts.php,v 1.14 2007/10/07 00:58:56 ade Exp $
! 28: #
! 29:
! 30: require_once 'module/module.php';
! 31: require_once 'module/modulePorts.php';
! 32:
! 33: class moduleBuildPorts extends module {
! 34:
! 35: function moduleBuildPorts() {
! 36: $this->module();
! 37: $this->modulePorts = new modulePorts();
! 38: }
! 39:
! 40: function display_list_buildports( $build_name, $sort ) {
! 41:
! 42: $build = $this->TinderboxDS->getBuildByName( $build_name );
! 43: $ports = $this->TinderboxDS->getPortsForBuild( $build, $sort );
! 44: $ports_tree = $this->TinderboxDS->getPortsTreeById( $build->getPortsTreeId() );
! 45: $jail = $this->TinderboxDS->getJailById( $build->getJailId() );
! 46:
! 47: if( is_array( $ports ) && count( $ports ) > 0 ) {
! 48: $this->template_assign( 'data', $this->modulePorts->get_list_data( $build_name, $ports ) );
! 49: $this->template_assign( 'no_list', false );
! 50: } else {
! 51: $this->template_assign( 'no_list', true );
! 52: }
! 53:
! 54: foreach( $this->TinderboxDS->getAllPortFailReasons() as $reason ) {
! 55: $port_fail_reasons[$reason->getTag()]['tag'] = htmlentities($reason->getTag());
! 56: $port_fail_reasons[$reason->getTag()]['descr'] = $reason->getDescr();
! 57: $port_fail_reasons[$reason->getTag()]['type'] = $reason->getType();
! 58: $port_fail_reasons[$reason->getTag()]['link'] = true;
! 59: }
! 60:
! 61: foreach ( $ports as $port ) {
! 62: if ( $port->getLastFailedDep() != "" ) {
! 63: $depreason = $port->getLastFailedDep();
! 64: $port_fail_reasons[$depreason]['tag'] = htmlentities( $depreason );
! 65: $port_fail_reasons[$depreason]['descr'] = htmlentities( "Port was not built since dependency $depreason failed." );
! 66: $port_fail_reasons[$depreason]['type'] = 'COMMON';
! 67: $port_fail_reasons[$depreason]['link'] = false;
! 68:
! 69: }
! 70: }
! 71:
! 72: $qs = array();
! 73: $qkvs = explode('&', $_SERVER['QUERY_STRING']);
! 74: foreach ($qkvs as $qkv) {
! 75: $kv = explode('=', $qkv);
! 76: $qs[$kv[0]] = $kv[1];
! 77: }
! 78:
! 79: $this->template_assign( 'port_fail_reasons', $port_fail_reasons );
! 80: $this->template_assign( 'maintainers', $this->TinderboxDS->getAllMaintainers() );
! 81: $this->template_assign( 'build_description', $build->getDescription() );
! 82: $this->template_assign( 'build_name', $build_name );
! 83: $this->template_assign( 'jail_name', $jail->getName() );
! 84: $this->template_assign( 'jail_tag', $jail->getTag() );
! 85: $this->template_assign( 'jail_lastbuilt', prettyDatetime( $jail->getLastBuilt() ) );
! 86: $this->template_assign( 'ports_tree_description', $ports_tree->getDescription() );
! 87: $this->template_assign( 'ports_tree_lastbuilt', prettyDatetime( $ports_tree->getLastBuilt() ) );
! 88: $this->template_assign( 'local_time', prettyDatetime( date( 'Y-m-d H:i:s' ) ) );
! 89: $this->template_assign( 'querystring', $qs);
! 90:
! 91: return $this->template_parse( 'list_buildports.tpl' );
! 92: }
! 93:
! 94: function display_failed_buildports( $build_name, $maintainer, $all ) {
! 95:
! 96: if( $build_name ) {
! 97: $build = $this->TinderboxDS->getBuildByName( $build_name );
! 98: $build_id = $build->getId();
! 99: } else {
! 100: $build_id = false;
! 101: }
! 102:
! 103: if ($all) {
! 104: $ports = $this->TinderboxDS->getPortsByStatus( $build_id, $maintainer, '', 'SUCCESS' );
! 105: } else {
! 106: $ports = $this->TinderboxDS->getPortsByStatus( $build_id, $maintainer, 'FAIL', '' );
! 107: }
! 108:
! 109: if( is_array( $ports ) && count( $ports ) > 0 ) {
! 110: $this->template_assign( 'data', $this->modulePorts->get_list_data( $build_name, $ports ) );
! 111: $this->template_assign( 'no_list', false );
! 112: } else {
! 113: $this->template_assign( 'no_list', true );
! 114: }
! 115:
! 116: foreach( $this->TinderboxDS->getAllPortFailReasons() as $reason ) {
! 117: $port_fail_reasons[$reason->getTag()]['tag'] = htmlentities($reason->getTag());
! 118: $port_fail_reasons[$reason->getTag()]['descr'] = $reason->getDescr();
! 119: $port_fail_reasons[$reason->getTag()]['type'] = $reason->getType();
! 120: $port_fail_reasons[$reason->getTag()]['link'] = true;
! 121: }
! 122:
! 123: foreach ( $ports as $port ) {
! 124: if ( $port->getLastFailedDep() != "" ) {
! 125: $depreason = $port->getLastFailedDep();
! 126: $port_fail_reasons[$depreason]['tag'] = htmlentities( $depreason );
! 127: $port_fail_reasons[$depreason]['descr'] = htmlentities( "Port was not built since dependency $depreason failed." );
! 128: $port_fail_reasons[$depreason]['type'] = 'COMMON';
! 129: $port_fail_reasons[$depreason]['link'] = false;
! 130: }
! 131: }
! 132:
! 133: $this->template_assign( 'port_fail_reasons', $port_fail_reasons );
! 134: $this->template_assign( 'build_name', $build_name );
! 135: $this->template_assign( 'maintainer', $maintainer );
! 136: $this->template_assign( 'local_time', prettyDatetime( date( 'Y-m-d H:i:s' ) ) );
! 137:
! 138: return $this->template_parse( 'failed_buildports.tpl' );
! 139: }
! 140:
! 141: function display_latest_buildports( $build_name ) {
! 142:
! 143: $current_builds = $this->display_current_buildports( $build_name );
! 144:
! 145: if( $build_name ) {
! 146: $build = $this->TinderboxDS->getBuildByName( $build_name );
! 147: $build_id = $build->getId();
! 148: } else {
! 149: $build_id = false;
! 150: }
! 151:
! 152: $ports = $this->TinderboxDS->getLatestPorts( $build_id, 20 );
! 153:
! 154: if( is_array( $ports ) && count( $ports ) > 0 ) {
! 155: $this->template_assign( 'data', $this->modulePorts->get_list_data( $build_name, $ports ) );
! 156: $this->template_assign( 'no_list', false );
! 157: } else {
! 158: $this->template_assign( 'no_list', true );
! 159: }
! 160:
! 161: foreach( $this->TinderboxDS->getAllPortFailReasons() as $reason ) {
! 162: $port_fail_reasons[$reason->getTag()]['tag'] = htmlentities($reason->getTag());
! 163: $port_fail_reasons[$reason->getTag()]['descr'] = $reason->getDescr();
! 164: $port_fail_reasons[$reason->getTag()]['type'] = $reason->getType();
! 165: $port_fail_reasons[$reason->getTag()]['link'] = true;
! 166: }
! 167:
! 168: foreach ( $ports as $port ) {
! 169: if ( $port->getLastFailedDep() != "" ) {
! 170: $depreason = $port->getLastFailedDep();
! 171: $port_fail_reasons[$depreason]['tag'] = htmlentities( $depreason );
! 172: $port_fail_reasons[$depreason]['descr'] = htmlentities( "Port was not built since dependency $depreason failed." );
! 173: $port_fail_reasons[$depreason]['type'] = 'COMMON';
! 174: $port_fail_reasons[$depreason]['link'] = false;
! 175: }
! 176: }
! 177:
! 178: $this->template_assign( 'port_fail_reasons', $port_fail_reasons );
! 179: $this->template_assign( 'current_builds', $current_builds );
! 180: $this->template_assign( 'build_name', $build_name );
! 181: $this->template_assign( 'local_time', prettyDatetime( date( 'Y-m-d H:i:s' ) ) );
! 182:
! 183: return $this->template_parse( 'latest_buildports.tpl' );
! 184: }
! 185:
! 186: function display_current_buildports( $showbuild ) {
! 187: $activeBuilds = array();
! 188: $builds = $this->TinderboxDS->getBuilds();
! 189: if( $builds ) {
! 190: foreach( $builds as $build ) {
! 191: if( empty( $showbuild ) || $build->getName() == $showbuild ) {
! 192: if( $build->getBuildStatus() == 'PORTBUILD' ) {
! 193: $activeBuilds[] = $build;
! 194: }
! 195: }
! 196: }
! 197: }
! 198:
! 199: if( sizeof( $activeBuilds ) > 0 ) {
! 200: $i = 0;
! 201: foreach( $activeBuilds as $build ) {
! 202: if( $build->getBuildCurrentPort() )
! 203: $data[$i]['port_current_version'] = $build->getBuildCurrentPort();
! 204: else
! 205: $data[$i]['port_current_version'] = preparing_next_build;
! 206:
! 207: $data[$i]['build_name'] = $build->getName();
! 208: $data[$i]['build_last_updated'] = $build->getBuildLastUpdated();
! 209: $data[$i]['build_eta'] = 'N/A';
! 210: $currport = $this->TinderboxDS->getCurrentPortForBuild($build->getId());
! 211: if (!is_null($currport)) {
! 212: $bp = $this->TinderboxDS->getBuildPorts($currport->getId(), $build->getId());
! 213: $as = explode(" ", $build->getBuildLastUpdated());
! 214: $ymd = explode("-", $as[0]);
! 215: $hms = explode(":", $as[1]);
! 216: $then = mktime($hms[0], $hms[1], $hms[2], $ymd[1], $ymd[2], $ymd[0]);
! 217: $diff = time() - $then;
! 218: if ($bp->getLastRunDuration() - $diff >= 0)
! 219: $data[$i]['build_eta'] = $bp->getLastRunDuration() - $diff;
! 220: }
! 221: $i++;
! 222: }
! 223: $this->template_assign( 'data', $data );
! 224: $this->template_assign( 'no_list', false );
! 225: } else {
! 226: $this->template_assign( 'no_list', true );
! 227: }
! 228:
! 229: $this->template_assign( 'build_name', $showbuild );
! 230:
! 231: return $this->template_parse( 'current_buildports.tpl' );
! 232: }
! 233: }
! 234: ?>