#import koji
#import koji.util
#from pprint import pformat
#from kojiweb import util

#include "includes/header.chtml"
#set $nvrpath = $pathinfo.build($build)

  <h4>Information for build <a href="buildinfo?buildID=$build.id">$koji.buildLabel($build)</a></h4>

  <table>
    <tr>
      <th>ID</th><td>$build.id</td>
    </tr>
    <tr>
      <th>Package Name</th><td><a href="packageinfo?packageID=$build.package_id">$build.package_name</a></td>
    </tr>
    <tr>
      <th>Version</th><td>$build.version</td>
    </tr>
    <tr>
      <th>Release</th><td>$build.release</td>
    </tr>
    <tr>
      <th>Epoch</th><td>$build.epoch</td>
    </tr>
    #if $build.get('source')
    <tr>
      <th>Source</th><td>$build['source']</td>
    </tr>
    #end if
    #if 'maven' in $typeinfo
    <tr>
      <th>Maven&nbsp;groupId</th><td>$typeinfo.maven.group_id</td>
    </tr>
    <tr>
      <th>Maven&nbsp;artifactId</th><td>$typeinfo.maven.artifact_id</td>
    </tr>
    <tr>
      <th>Maven&nbsp;version</th><td>$typeinfo.maven.version</td>
    </tr>
    #end if
    #if $summary
    <tr>
      <th>Summary</th><td class="rpmheader">$util.escapeHTML($summary)</td>
    </tr>
    #end if
    #if $description
    <tr>
      <th>Description</th><td class="rpmheader">$util.escapeHTML($description)</td>
    </tr>
    #end if
    <tr>
      <th>Built by</th><td class="user-$build.owner_name"><a href="userinfo?userID=$build.owner_id">$build.owner_name</a></td>
    </tr>
    <tr>
      #set $stateName = $util.stateName($build.state)
      <th>State</th>
      <td class="$stateName">$stateName
      #if $build.state == $koji.BUILD_STATES.BUILDING
      #if $currentUser and ('admin' in $perms or $build.owner_id == $currentUser.id)
      <span class="adminLink">(<a href="cancelbuild?buildID=$build.id$util.authToken($self)">cancel</a>)</span>
      #end if
      #end if
      </td>
    </tr>
    <tr>
      <th>Started</th><td>$util.formatTimeLong($start_time)</td>
    </tr>
    #if $build.state == $koji.BUILD_STATES.BUILDING
    #if $estCompletion
    <tr>
      <th>Est. Completion</th><td>$util.formatTimeLong($estCompletion)</td>
    </tr>
    #end if
    #else
    <tr>
      <th>Completed</th><td>$util.formatTimeLong($build.completion_time)</td>
    </tr>
    #end if
    #if $task
    <tr>
      <th>Task</th><td><a href="taskinfo?taskID=$task.id" class="task$util.taskState($task.state)">$koji.taskLabel($task)</a></td>
    </tr>
    #end if
    #if $build.get('extra')
    <tr>
      <th>Extra</th><td class="usertext">$util.escapeHTML($pformat($build.extra))</td>
    </tr>
    #end if
    <tr>
      <th>Tags</th>
      <td class="container">
        #if $len($tags) > 0
        <table class="nested">
          #for $tag in $tags
          <tr>
            <td><a href="taginfo?tagID=$tag.id">$tag.name</a></td>
          </tr>
          #end for
        </table>
        #else
        No tags
        #end if
      </td>
    </tr>
    <tr>
      <th>RPMs</th>
      <td class="container">
        #if $len($rpmsByArch) > 0
        <table class="nested">
          #if 'src' in $rpmsByArch
          <tr><th>src</th><th></th></tr>
          #for $rpm in $rpmsByArch['src']
          #set $rpmfile = '%(name)s-%(version)s-%(release)s.%(arch)s.rpm' % $rpm
          #set $rpmpath = $pathinfo.rpm($rpm)
          <tr>
            <td></td>
            #if $rpm.metadata_only
            <td>$rpmfile (<a href="rpminfo?rpmID=$rpm.id">info</a>) (metadata only)</td>
            #else
            <td>$rpmfile (<a href="rpminfo?rpmID=$rpm.id">info</a>) (<a href="$nvrpath/$rpmpath">download</a>)</td>
            #end if
          </tr>
          #end for
          #end if
          #set $arches = $rpmsByArch.keys()
          #silent $arches.sort()
          #for $arch in $arches
          #if $arch == 'src'
          #silent continue
          #end if
          <tr>
            <th>$arch</th>
            <td>
              #if $task
              #if $arch == 'noarch'
              (<a href="$nvrpath/data/logs/$noarch_log_dest/">build logs</a>)
              #else
              (<a href="$nvrpath/data/logs/$arch/">build logs</a>)
              #end if
              #end if
            </td>
          </tr>
          #for $rpm in $rpmsByArch[$arch]
          <tr>
            #set $rpmfile = '%(name)s-%(version)s-%(release)s.%(arch)s.rpm' % $rpm
            #set $rpmpath = $pathinfo.rpm($rpm)
            <td></td>
            <td>
              $rpmfile (<a href="rpminfo?rpmID=$rpm.id">info</a>) (<a href="$nvrpath/$rpmpath">download</a>)
            </td>
          </tr>
          #end for
          #end for
        </table>
        #else
        No RPMs
        #end if
      </td>
    </tr>
    #for btype in $archiveIndex
    #set $archivesByExt = $archiveIndex[btype]
    #if not $archivesByExt
    #continue
    #end if
    <tr>
      <th>$btype.capitalize() Archives</th>
      <td class="container">
        <table class="nested">
          #set $exts = $archivesByExt.keys()
          #for ext in $exts
          <tr>
            <th>$ext</th>
            <td>
          #if $task and $ext == $exts[0]
            #if $btype == 'maven'
                (<a href="$nvrpath/data/logs/maven/">build logs</a>)
            #elif $btype == 'win'
                (<a href="$nvrpath/data/logs/win/">build logs</a>)
            #elif $btype == 'image'
                (<a href="$nvrpath/data/logs/image">build logs</a>)
            #else
                (<a href="$nvrpath/data/logs">build logs</a>)
            #end if
          #end if
            </td>
          </tr>
          #for $archive in $archivesByExt[$ext]
          <tr>
            <td/>
            <td>
            #if $archive.metadata_only
            $archive.display (<a href="archiveinfo?archiveID=$archive.id">info</a>)
            #else
            $archive.display (<a href="archiveinfo?archiveID=$archive.id">info</a>) (<a href="$archive.dl_url">download</a>)
            #end if
            </td>
          </tr>
          #end for
          #end for
        </table>
      </td>
    </tr>
    #end for
    #if $changelog
    <tr>
      <th>Changelog</th>
      <td class="changelog">$util.escapeHTML($koji.util.formatChangelog($changelog))</td>
    </tr>
    #end if
  </table>

#include "includes/footer.chtml"
