#import koji
#from kojiweb import util
#from pprint import pformat
#import time
#import urllib

#attr _PASSTHROUGH = ['rpmID', 'fileOrder', 'fileStart', 'buildrootOrder', 'buildrootStart']

#include "includes/header.chtml"
  #set $epoch = ($rpm.epoch != None and $str($rpm.epoch) + ':' or '')
  <h4>Information for RPM <a href="rpminfo?rpmID=$rpm.id">$rpm.name-$epoch$rpm.version-$rpm.release.${rpm.arch}.rpm</a></h4>

  <table>
    <tr>
      <th>ID</th><td>$rpm.id</td>
    </tr>
    <tr>
      #if $build
      <th>Name</th><td><a href="packageinfo?packageID=$build.package_id">$rpm.name</a></td>
      #else
      <th>Name</th><td>$rpm.name</td>
      #end if
    </tr>
    <tr>
      #if $build
      <th>Version</th><td><a href="buildinfo?buildID=$build.id">$rpm.version</a></td>
      #else
      <th>Version</th><td>$rpm.version</td>
      #end if
    </tr>
    <tr>
      <th>Release</th><td>$rpm.release</td>
    </tr>
    <tr>
      <th>Epoch</th><td>$rpm.epoch</td>
    </tr>
    <tr>
      <th>Arch</th><td>$rpm.arch</td>
    </tr>
    #if $rpm.external_repo_id == 0
    <tr>
      <th>Summary</th><td class="rpmheader">$util.escapeHTML($summary)</td>
    </tr>
    <tr>
      <th>Description</th><td class="rpmheader">$util.escapeHTML($description)</td>
    </tr>
    #end if
    <tr>
      <th>Build Time</th><td>$time.strftime('%Y-%m-%d %H:%M:%S', $time.gmtime($rpm.buildtime)) GMT</td>
    </tr>
    #if $build and $build.state == $koji.BUILD_STATES.DELETED
    <tr>
      <th>State</th><td class="deleted">deleted</td>
    </tr>
    #end if
    #if $rpm.external_repo_id
    <tr>
      <th>External Repository</th><td><a href="externalrepoinfo?extrepoID=$rpm.external_repo_id">$rpm.external_repo_name</a></td>
    </tr>
    #end if
    <tr>
      <th>Size</th><td>$rpm.size</td>
    </tr>
    <tr>
      <th><label title="The MD5 digest of the combined header and payload contents. You can query it by `rpmkeys -Kv foo.rpm`">SIGMD5</label></th><td>$rpm.payloadhash</td>
    </tr>
    #if $builtInRoot
    <tr>
      <th>Buildroot</th><td><a href="buildrootinfo?buildrootID=$builtInRoot.id">$util.brLabel($builtInRoot)</a></td>
    </tr>
    #end if
    #if $rpm.get('extra')
    <tr>
      <th>Extra</th><td class="usertext">$util.escapeHTML($pformat($rpm.extra))</td>
    </tr>
    #end if
    #if $rpm.external_repo_id == 0
    <tr>
      <th>Provides</th>
      <td class="container">
        #if $len($provides) > 0
        <table class="nested">
          #for $dep in $provides
          <tr>
            <td>$util.escapeHTML($util.formatDep($dep.name, $dep.version, $dep.flags))</td>
          </tr>
          #end for
        </table>
        #else
        No Provides
        #end if
      </td>
    </tr>
    <tr>
      <th>Obsoletes</th>
      <td class="container">
        #if $len($obsoletes) > 0
        <table class="nested">
          #for $dep in $obsoletes
          <tr>
            <td>$util.escapeHTML($util.formatDep($dep.name, $dep.version, $dep.flags))</td>
          </tr>
          #end for
        </table>
        #else
        No Obsoletes
        #end if
      </td>
    </tr>
    <tr>
      <th>Conflicts</th>
      <td class="container">
        #if $len($conflicts) > 0
        <table class="nested">
          #for $dep in $conflicts
          <tr>
            <td>$util.escapeHTML($util.formatDep($dep.name, $dep.version, $dep.flags))</td>
          </tr>
          #end for
        </table>
        #else
        No Conflicts
        #end if
      </td>
    </tr>
    <tr>
      <th>Requires</th>
      <td class="container">
        #if $len($requires) > 0
        <table class="nested">
          #for $dep in $requires
          <tr>
            <td>$util.escapeHTML($util.formatDep($dep.name, $dep.version, $dep.flags))</td>
          </tr>
          #end for
        </table>
        #else
        No Requires
        #end if
      </td>
    </tr>
    #if $optional_deps
    <tr>
      <th>Recommends</th>
      <td class="container">
        #if $len($recommends) > 0
        <table class="nested">
          #for $dep in $recommends
          <tr>
            <td>$util.escapeHTML($util.formatDep($dep.name, $dep.version, $dep.flags))</td>
          </tr>
          #end for
        </table>
        #else
        No Recommends
        #end if
      </td>
    </tr>
    <tr>
      <th>Suggests</th>
      <td class="container">
        #if $len($suggests) > 0
        <table class="nested">
          #for $dep in $suggests
          <tr>
            <td>$util.escapeHTML($util.formatDep($dep.name, $dep.version, $dep.flags))</td>
          </tr>
          #end for
        </table>
        #else
        No Suggests
        #end if
      </td>
    </tr>
    <tr>
      <th>Supplements</th>
      <td class="container">
        #if $len($supplements) > 0
        <table class="nested">
          #for $dep in $supplements
          <tr>
            <td>$util.escapeHTML($util.formatDep($dep.name, $dep.version, $dep.flags))</td>
          </tr>
          #end for
        </table>
        #else
        No Supplements
        #end if
      </td>
    </tr>
    <tr>
      <th>Enhances</th>
      <td class="container">
        #if $len($enhances) > 0
        <table class="nested">
          #for $dep in $enhances
          <tr>
            <td>$util.escapeHTML($util.formatDep($dep.name, $dep.version, $dep.flags))</td>
          </tr>
          #end for
        </table>
        #else
        No Enhances
        #end if
      </td>
    </tr>
    #end if
    <tr>
      <th id="filelist">Files</th>
      <td class="container">
        #if $len($files) > 0
        <table class="nested data-list">
          <tr>
            <td class="paginate" colspan="2">
              #if $len($filePages) > 1
              <form class="pageJump" action="">
                Page:
                <select onchange="javascript: window.location = 'rpminfo?fileStart=' + this.value * $fileRange + '$util.passthrough_except($self, 'fileStart')#filelist';">
                  #for $pageNum in $filePages
                  <option value="$pageNum"#if $pageNum == $fileCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
                  #end for
                </select>
              </form>
              #end if
              #if $fileStart > 0
              <a href="rpminfo?fileStart=#echo $fileStart - $fileRange #$util.passthrough_except($self, 'fileStart')#filelist">&lt;&lt;&lt;</a>
              #end if
              <strong>#echo $fileStart + 1 # through #echo $fileStart + $fileCount # of $totalFiles</strong>
              #if $fileStart + $fileCount < $totalFiles
              <a href="rpminfo?fileStart=#echo $fileStart + $fileRange#$util.passthrough_except($self, 'fileStart')#filelist">&gt;&gt;&gt;</a>
              #end if
            </td>
          </tr>
          <tr class="list-header">
            <th><a href="rpminfo?fileOrder=$util.toggleOrder($self, 'name', 'fileOrder')$util.passthrough_except($self, 'fileOrder', 'fileStart')#filelist">Name</a> $util.sortImage($self, 'name', 'fileOrder')</th>
            <th><a href="rpminfo?fileOrder=$util.toggleOrder($self, 'size', 'fileOrder')$util.passthrough_except($self, 'fileOrder', 'fileStart')#filelist">Size</a> $util.sortImage($self, 'size', 'fileOrder')</th>
          </tr>
          #for $file in $files
          <tr class="$util.rowToggle($self)">
            <td><a href="fileinfo?rpmID=$rpm.id&amp;filename=$urllib.quote($file.name)">$util.escapeHTML($file.name)</a></td><td>$file.size</td>
          </tr>
          #end for
        </table>
        #else
        No Files
        #end if
      </td>
    </tr>
    #end if
    <tr>
      <th id="buildrootlist">Component&nbsp;of</th>
      <td class="container">
        #if $len($buildroots) > 0
        <table class="nested data-list">
          <tr>
            <td class="paginate" colspan="3">
              #if $len($buildrootPages) > 1
              <form class="pageJump" action="">
                Page:
                <select onchange="javascript: window.location = 'rpminfo?buildrootStart=' + this.value * $buildrootRange + '$util.passthrough_except($self, 'buildrootStart')#buildrootlist';">
                  #for $pageNum in $buildrootPages
                  <option value="$pageNum"#if $pageNum == $buildrootCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
                  #end for
                </select>
              </form>
              #end if
              #if $buildrootStart > 0
              <a href="rpminfo?buildrootStart=#echo $buildrootStart - $buildrootRange #$util.passthrough_except($self, 'buildrootStart')#buildrootlist">&lt;&lt;&lt;</a>
              #end if
              <strong>#echo $buildrootStart + 1 # through #echo $buildrootStart + $buildrootCount # of $totalBuildroots</strong>
              #if $buildrootStart + $buildrootCount < $totalBuildroots
              <a href="rpminfo?buildrootStart=#echo $buildrootStart + $buildrootRange#$util.passthrough_except($self, 'buildrootStart')#buildrootlist">&gt;&gt;&gt;</a>
              #end if
            </td>
          </tr>
          <tr class="list-header">
            <th><a href="rpminfo?buildrootOrder=$util.toggleOrder($self, 'id', 'buildrootOrder')$util.passthrough_except($self, 'buildrootOrder', 'buildrootStart')#buildrootlist">Buildroot</a> $util.sortImage($self, 'id', 'buildrootOrder')</th>
            <th><a href="rpminfo?buildrootOrder=$util.toggleOrder($self, 'create_event_time', 'buildrootOrder')$util.passthrough_except($self, 'buildrootOrder', 'buildrootStart')#buildrootlist">Created</a> $util.sortImage($self, 'create_event_time', 'buildrootOrder')</th>
            <th><a href="rpminfo?buildrootOrder=$util.toggleOrder($self, 'state', 'buildrootOrder')$util.passthrough_except($self, 'buildrootOrder', 'buildrootStart')#buildrootlist">State</a> $util.sortImage($self, 'state', 'buildrootOrder')</th>
          </tr>
          #for $buildroot in $buildroots
          <tr class="$util.rowToggle($self)">
            <td><a href="buildrootinfo?buildrootID=$buildroot.id">$util.brLabel($buildroot)</a></td>
            <td>$util.formatTime($buildroot.create_event_time)</td>
            <td>$util.imageTag($util.brStateName($buildroot.state))</td>
          </tr>
          #end for
        </table>
        #else
        No Buildroots
        #end if
      </td>
    </tr>
  </table>

#include "includes/footer.chtml"
