<?xml version="1.0" encoding="utf-8" ?>

<!--
# Copyright © 2002-2008 Raphaël Hertzog and others
# Copyright © 2007-2009 Stefano Zacchiroli
# This file is distributed under the terms of the General Public License
# version 2 or (at your option) any later version.
-->

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:str="http://exslt.org/strings"
  version="1.0">

<xsl:output
  method="xml"
  encoding="UTF-8"
  omit-xml-declaration="yes"
  doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  indent="yes" />

<xsl:include href="pts-issues.xsl" />

<xsl:param name="package"/>
<xsl:param name="dir"/>
<xsl:param name="date"/>
<xsl:param name="hasoldstable" select="''"/>
<xsl:param name="hasstable" select="''"/>
<xsl:param name="hastesting" select="''"/>
<xsl:param name="hasunstable" select="''"/>
<xsl:param name="hasexperimental" select="''"/>
<xsl:param name="hasmentors" select="''"/>
<xsl:param name="hasother" select="''"/>
<xsl:param name="hasstable-proposed-updates" select="''"/>
<xsl:param name="hastesting-proposed-updates" select="''"/>
<xsl:param name="hassecurity-oldstable" select="''"/>
<xsl:param name="hassecurity-stable" select="''"/>
<xsl:param name="hassecurity-testing" select="''"/>
<xsl:param name="hasoldstable-updates" select="''"/>
<xsl:param name="hasstable-updates" select="''"/>
<xsl:param name="hasnews" select="''"/>
<xsl:param name="hasexcuse" select="''"/>

<xsl:variable name="other"
  select="document(concat('../base/', $dir, '/other.xml'))/other"/>
<xsl:variable name="low-nmu-emails"
  select="document('../base/low_threshold_nmu.emails.xml')/emails"/>
<xsl:variable name="mostrecentsuite">
  <!-- name of the most recent suite in which the package is available
  -->
  <xsl:choose>
    <xsl:when test="$hasexperimental">
      <xsl:text>experimental</xsl:text>
    </xsl:when>
    <xsl:when test="$hasunstable">
      <xsl:text>unstable</xsl:text>
    </xsl:when>
    <xsl:when test="$hastesting">
      <xsl:text>testing</xsl:text>
    </xsl:when>
    <xsl:when test="$hasstable">
      <xsl:text>stable</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text />
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>
<xsl:variable name="pooldir">
  <xsl:if test="$mostrecentsuite != ''">
    <xsl:value-of
       select="document(concat('../base/', $dir, '/',
	       $mostrecentsuite, '.xml'))/source/directory" />
  </xsl:if>
</xsl:variable>

<!-- Those variables controls the todo and problem item concerning
     standards-version not being up to date -->
<xsl:variable name="lastsv" select="'3.9.1'"/>
<xsl:variable name="lastmajorsv" select="'3.'"/>

<!-- lintian summary -->
<xsl:variable name="lin_errs" select="$other/lintian/@errors" />
<xsl:variable name="lin_warns" select="$other/lintian/@warnings" />

<!-- Named templates aka functions -->

<xsl:template name="mk_lintian_url">
  <!-- convert maintainer/name to follow lintian.debian.org convention -->
  <xsl:variable name="lintian_pattern" select="concat('àáèéëêòöøîìùñ~/()&#34; ', &quot;'&quot;)"/>
  <xsl:variable name="lintian_email" select="translate(maintainer/email, $lintian_pattern, '_____________________')"/>

  <xsl:text>http://lintian.debian.org/maintainer/</xsl:text>
  <xsl:value-of select="$lintian_email" />
  <xsl:text>.html#</xsl:text>
  <xsl:value-of select="$package" />
</xsl:template>

<xsl:variable name="mirror">http://cdn.debian.net/debian</xsl:variable>
<xsl:variable name="security-mirror">http://security.debian.org/debian-security</xsl:variable>

<xsl:template name="outputitem">
  <xsl:choose>
    <xsl:when test="@url">
      <li><xsl:if test="@date">
        <xsl:text>[</xsl:text>
	<xsl:value-of select="@date"/>
        <xsl:text>] </xsl:text>
      </xsl:if><a href="{@url}">
      <xsl:value-of select="text()"/></a><xsl:if test="@from">
        <xsl:text> (</xsl:text>
	<xsl:value-of select="@from"/>
        <xsl:text>)</xsl:text></xsl:if></li>
    </xsl:when>
    <xsl:when test="@type='raw'">
      <li>
	<xsl:copy-of select="node()" />
      </li>
    </xsl:when>
    <xsl:otherwise>
      <li><xsl:if test="@date">
        <xsl:text>[</xsl:text>
	<xsl:value-of select="@date"/>
        <xsl:text>] </xsl:text>
      </xsl:if><xsl:value-of select="text()"/></li>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- Convert + in %2b for URL escaping. Should actually first also do
other-to-%xx, especially % to %25... Fortunately, that's rare -->
<xsl:template name="escape-name">
  <xsl:param name="text"/>
  <xsl:if test="contains($text,'+')">
    <xsl:value-of select="substring-before($text,'+')"/>
    <xsl:text>%2b</xsl:text>
    <xsl:call-template name="escape-name">
    <xsl:with-param name="text"><xsl:value-of select="substring-after($text,'+')"/></xsl:with-param>
    </xsl:call-template>
  </xsl:if>
  <xsl:if test="not(contains($text,'+'))">
    <xsl:value-of select="$text"/>
  </xsl:if>
</xsl:template>

<xsl:variable name="escaped-package">
  <xsl:call-template name="escape-name">
    <xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
  </xsl:call-template>
</xsl:variable>

<!-- Strip epoch -->
<xsl:template name="strip-epoch">
  <xsl:param name="version"/>
  <xsl:if test="contains($version,':')">
    <xsl:value-of select="substring-after($version,':')"/>
  </xsl:if>
  <xsl:if test="not(contains($version,':'))">
    <xsl:value-of select="$version"/>
  </xsl:if>
</xsl:template>

<xsl:template name="add-vcs-info">
  <xsl:if test="repository">
    <dt title="Version Control System">VCS</dt>
    <dd>
      <xsl:if test="repository/vcs[@kind!='browser']">
        <xsl:for-each select="repository/vcs[@kind!='browser']">
          <xsl:sort select="@kind" />
          <a title="raw {@kind} repository" href="{@url}">
            <xsl:value-of select="@kind" />
          </a>
          <xsl:if test="position()!=last()"><xsl:text>, </xsl:text></xsl:if>
        </xsl:for-each>
      </xsl:if>
      <xsl:if test="repository/vcs[@kind='browser']">
        <xsl:text> (</xsl:text>
        <a title="browse the repository"
           href="{repository/vcs[@kind='browser']/@url}">browse</a>
          <xsl:text>)</xsl:text>
      </xsl:if>
    </dd>
  </xsl:if>
</xsl:template>

<xsl:template name="add-maintenance-info">
  <xsl:param name="email" />
  <xsl:variable name="dm">
    <xsl:if test="dm-upload-allowed and string(dm-upload-allowed)='yes'">
      <xsl:text>true</xsl:text>
    </xsl:if>
  </xsl:variable>
  <xsl:variable name="lownmu">
    <xsl:if test="$low-nmu-emails/email[text()=$email]">
      <xsl:text>true</xsl:text>
    </xsl:if>
  </xsl:variable>

  <xsl:if test="string($dm)!='' or string($lownmu)!=''">
    <div class="maint-markers">
    <xsl:if test="string($dm)!=''">
      <span class="dm-tag">
	<a href="http://www.debian.org/vote/2007/vote_003">
	  <acronym title="Debian Maintainer Upload Allowed: this package can be uploaded by Debian Maintainers">DMUA</acronym>
	</a>
      </span>
    </xsl:if>
    <xsl:if test="string($lownmu)!=''">
      <xsl:if test="string($dm)!=''">
	<xsl:text>, </xsl:text>
      </xsl:if>
      <span class="lownmu-tag">
	<a href="http://wiki.debian.org/LowThresholdNmu">
	  <acronym title="maintainer agrees with Low Threshold NMU">LowNMU</acronym>
	</a>
      </span>
    </xsl:if>
    </div>
  </xsl:if>
</xsl:template>

<xsl:template name="output-news">
  <xsl:param name="news" />

  <xsl:if test="count($news)>0 and string($news)!=''">
    <div class="block news">
      <a name="news" />
      <h2>news <a class="feedlink" href="{$package}/news.rss20.xml">RSS</a></h2>
      <ul id="news-list">
	<xsl:copy-of select="$news" />
      </ul>
    </div>
  </xsl:if>
</xsl:template>

<xsl:template name="output-static">
  <xsl:param name="static" />

  <xsl:if test="count($static)>0 and string($static)!=''">
    <div class="block static">
      <a name="static" />
      <h2>static info</h2>
      <ul>
	<xsl:copy-of select="$static" />
      </ul>
    </div>
  </xsl:if>
</xsl:template>

<xsl:template name="maintainer-email">
  <xsl:param name="email" />
  <a class="email" href="mailto:{$email}">
    <img alt="[email]" src="../common/email.png" title="email" />
  </a>
</xsl:template>

<xsl:template name="general-information">
  <div class="block info">
    <a name="general" />
    <h2>general</h2>
    <dl>
      <dt>source</dt>
      <dd>
	<a href="http://packages.debian.org/src:{$package}">
	  <xsl:value-of select="$package" />
	</a>
	(<span id="priority" title="priority">
	  <small><xsl:value-of select="priority"/></small>
	</span>,
	<span id="section" title="section">
	  <small><xsl:value-of select="section"/></small>
	</span>)
      </dd>

      <dt>version</dt>
      <dd>
	<span id="latest_version"><xsl:value-of select="version"/></span>
      </dd>

      <xsl:if test="@release!='unstable'">
	<dt>distro</dt>
	<dd><xsl:value-of select="@release"/></dd>
      </xsl:if>

      <dt title="Maintainer and Uploaders">maint</dt>
      <dd class="maintainer">
	<xsl:element name="a">
	  <xsl:attribute name="href">
	    <xsl:text>http://qa.debian.org/developer.php?login=</xsl:text>
	    <xsl:call-template name="escape-name">
	      <xsl:with-param name="text"><xsl:value-of select="maintainer/email"/></xsl:with-param>
	    </xsl:call-template>
	  </xsl:attribute>
	  <span class="name" title="maintainer">
	    <xsl:value-of select="maintainer/name"/>
	  </span>
	</xsl:element>
	<xsl:if test="uploaders">
          <xsl:for-each select="uploaders/item">
	    <xsl:text>, </xsl:text>
	    <span class="uploader">
	      <small>
	      <xsl:element name="a">
		<xsl:attribute name="href">
		  <xsl:text>http://qa.debian.org/developer.php?login=</xsl:text>
		  <xsl:call-template name="escape-name">
		    <xsl:with-param name="text">
		      <xsl:value-of select="email"/>
		    </xsl:with-param>
		  </xsl:call-template>
		</xsl:attribute>
		<span class="name" title="uploader">
		  <xsl:value-of select="name"/>
		</span>
	      </xsl:element>
	      <xsl:text> (u)</xsl:text>
	      </small>
	    </span>
          </xsl:for-each>
	</xsl:if>
	<xsl:call-template name='add-maintenance-info'>
	  <xsl:with-param name="email" select="maintainer/email" />
	</xsl:call-template>
      </dd>

      <xsl:if test="architecture!='any' and architecture!='all'">
	<dt>arch</dt>
	<dd><xsl:value-of select="architecture"/></dd>
      </xsl:if>

      <dt title="Standards-Version">std-ver</dt>
      <dd>
	<span id="standards_version">
	  <xsl:value-of select="standards-version"/>
	</span>
      </dd>

      <xsl:call-template name='add-vcs-info' />
    </dl>
  </div>
</xsl:template>

<xsl:template name="bugs-count">
  <div class="block bugs">
    <a name="bugs" />
    <h2>bugs</h2>
    <dl>
      <dt id="bugs_all">
	all
	<xsl:element name="a">
	  <xsl:attribute name="href">
	    <xsl:text>http://qa.debian.org/data/bts/graphs/</xsl:text>
	    <xsl:value-of select="$dir"/>
	    <xsl:text>.png</xsl:text>
	  </xsl:attribute>
	  <xsl:attribute name="title">bug history graph</xsl:attribute>
	  <img alt="bug history graph" src="../common/bug-graph.png" />
	</xsl:element>
      </dt>
      <dd>
	<xsl:element name="a">
	  <xsl:attribute name="href">
	    <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?repeatmerged=no&amp;src=</xsl:text>
	    <xsl:value-of select="$escaped-package" />
	  </xsl:attribute>
	  <xsl:if test="$hasother">
	    <span class="bugcount" title="all">
	      <xsl:value-of select="$other/bugs/@all"/>
	    </span>
	  </xsl:if>
	</xsl:element>
	<xsl:if test="$hasother and $other/bugs/@all_m">
	  (<xsl:element name="a">
	    <xsl:attribute name="href">
	      <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?repeatmerged=yes&amp;src=</xsl:text>
	      <xsl:value-of select="$escaped-package" />
	    </xsl:attribute>
	    <xsl:value-of select="$other/bugs/@all_m"/>
	  </xsl:element>)
	</xsl:if>
      </dd>
      <dt id="bugs_rc" title="Release Critical">
	<span class="indented">RC</span>
      </dt>
      <dd>
	<xsl:element name="a">
	  <xsl:attribute name="href">
	    <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=</xsl:text>
	    <xsl:value-of select="$escaped-package" />
	    <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=critical&amp;sev-inc=grave&amp;sev-inc=serious&amp;repeatmerged=no</xsl:text>
	  </xsl:attribute>
	  <xsl:if test="$hasother">
	    <span class="bugcount" title="rc">
	      <xsl:value-of select="$other/bugs/@rc"/>
	    </span>
	  </xsl:if>
	</xsl:element>
	<xsl:if test="$hasother and $other/bugs/@rc_m">
	  (<xsl:element name="a">
	    <xsl:attribute name="href">
	      <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=</xsl:text>
	      <xsl:value-of select="$escaped-package" />
	      <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=critical&amp;sev-inc=grave&amp;sev-inc=serious&amp;repeatmerged=yes</xsl:text>
	    </xsl:attribute>
	    <xsl:value-of select="$other/bugs/@rc_m"/>
	  </xsl:element>)
	</xsl:if>
      </dd>
      <dt id="bugs_in" title="Important and Normal">
	<span class="indented">I&amp;N</span>
      </dt>
      <dd>
	<xsl:element name="a">
	  <xsl:attribute name="href">
	    <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=</xsl:text>
	    <xsl:value-of select="$escaped-package" />
	    <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=important&amp;sev-inc=normal&amp;repeatmerged=no</xsl:text>
	  </xsl:attribute>
	  <xsl:if test="$hasother">
	    <span class="bugcount" title="in">
	      <xsl:value-of select="$other/bugs/@normal"/>
	    </span>
	  </xsl:if>
	</xsl:element>
	<xsl:if test="$hasother and $other/bugs/@normal_m">
	  (<xsl:element name="a">
	    <xsl:attribute name="href">
	      <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=</xsl:text>
	      <xsl:value-of select="$escaped-package" />
	      <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=important&amp;sev-inc=normal&amp;repeatmerged=yes</xsl:text>
	    </xsl:attribute>
	    <xsl:value-of select="$other/bugs/@normal_m"/>
	  </xsl:element>)
	</xsl:if>
      </dd>
      <dt id="bugs_mw" title="Minor and Wishlist">
	<span class="indented">M&amp;W</span>
      </dt>
      <dd>
	<xsl:element name="a">
	  <xsl:attribute name="href">
	    <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=</xsl:text>
	    <xsl:value-of select="$escaped-package" />
	    <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=minor&amp;sev-inc=wishlist&amp;repeatmerged=no</xsl:text>
	  </xsl:attribute>
	  <xsl:if test="$hasother">
	    <span class="bugcount" title="mw">
	      <xsl:value-of select="$other/bugs/@wishlist"/>
	    </span>
	  </xsl:if>
	</xsl:element>
	<xsl:if test="$hasother and $other/bugs/@wishlist_m">
	  (<xsl:element name="a">
	    <xsl:attribute name="href">
	      <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=</xsl:text>
	      <xsl:value-of select="$escaped-package" />
	      <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=minor&amp;sev-inc=wishlist&amp;repeatmerged=yes</xsl:text>
	    </xsl:attribute>
	    <xsl:value-of select="$other/bugs/@wishlist_m"/>
	  </xsl:element>)
	</xsl:if>
      </dd>
      <dt id="bugs_fp" title="Fixed and Pending">
	<span class="indented">F&amp;P</span>
      </dt>
      <dd>
	<xsl:element name="a">
	  <xsl:attribute name="href">
	    <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=</xsl:text>
	    <xsl:value-of select="$escaped-package" />
	    <xsl:text>&amp;archive=no&amp;pend-inc=pending-fixed&amp;pend-inc=fixed&amp;repeatmerged=no</xsl:text>
	  </xsl:attribute>
	  <xsl:if test="$hasother">
	    <span class="bugcount" title="fp">
	      <xsl:value-of select="$other/bugs/@fixed"/>
	    </span>
	  </xsl:if>
	</xsl:element>
	<xsl:if test="$hasother and $other/bugs/@fixed_m">
	  (<xsl:element name="a">
	    <xsl:attribute name="href">
	      <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=</xsl:text>
	      <xsl:value-of select="$escaped-package" />
	      <xsl:text>&amp;archive=no&amp;pend-inc=pending-fixed&amp;pend-inc=fixed&amp;repeatmerged=yes</xsl:text>
	    </xsl:attribute>
	    <xsl:value-of select="$other/bugs/@fixed_m"/>
	  </xsl:element>)
	</xsl:if>
      </dd>
      <xsl:if test="$other/bugs/@gift &gt; 0">
	<dt id="bugs_gift">
	  <span class="indented">
	    <a href="http://wiki.debian.org/qa.debian.org/GiftTag">gift</a>
	  </span>
	</dt>
	<dd>
	  <xsl:element name="a">
	    <xsl:attribute name="href">
	      <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=</xsl:text>
	      <xsl:value-of select="$escaped-package" />
	    <xsl:text>&amp;users=debian-qa@lists.debian.org;tag=gift</xsl:text>
	    </xsl:attribute>
	    <span class="bugcount" title="gift">
	      <xsl:value-of select="$other/bugs/@gift" />
	    </span>
	  </xsl:element>
	</dd>
      </xsl:if>
    </dl>
  </div>
</xsl:template>

<xsl:template name="pts-subscription">
  <!-- <acronym title="Package Tracking System">PTS</acronym> subscription -->
  <!-- <tr class="normalrow"> -->
  <!--   <td class="labelcell">Subscribers count</td> -->
  <!--   <td class="contentcell"><xsl:if test="$hasother"> -->
  <!-- 	<xsl:value-of select="$other/pts/@count"/> -->
  <!--   </xsl:if></td> -->
  <!-- </tr> -->
  <form method="post" action="/cgi-bin/pts.cgi">
    <p>
      <input type="hidden" name="package" value="{$package}"/>
      subscribe to this package<br />
      <input type="text" name="email" size="10" value="email"
	     onfocus="if(email.value=='your email'){{email.value=''}}"/>
      <select name="what">
	<option value="subscribe">sub</option>
	<option value="unsubscribe">unsub</option>
	<option value="advanced">opts</option>
      </select>
      <input type="submit" name="submit" value="go"/>
    </p>
  </form>
</xsl:template>

<xsl:template name="binary-packages">
  <div class="block binaries">
    <a name="binaries" />
    <h2>binaries</h2>
    <ul>
      <xsl:for-each select="binary/item">
	<xsl:sort select="text()"/>
	<xsl:variable name="pkg" select="text()"/>
	<xsl:variable name="tooltip"
		      select="concat($pkg, ': ',
			      $other/descriptions/shortdesc[@package=$pkg])" />
	<li class="binpkg">
          <a class="binpkg" title="{$tooltip}"
             href="http://packages.debian.org/{text()}">
	    <span class="binpkg"><xsl:value-of select="text()"/></span>
	  </a>
	  <span style="font-size: 70%">
	    (<a href="http://bugs.debian.org/{text()}"><xsl:value-of select="$other/bugs/item[@name=$pkg]/@all"/> bugs</a>: 
	    <xsl:element name="a">
	      <xsl:attribute name="title">critical, grave and serious</xsl:attribute>
	      <xsl:attribute name="href">
		<xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data=</xsl:text>
		<xsl:call-template name="escape-name">
		  <xsl:with-param name="text"><xsl:value-of select="text()"/></xsl:with-param>
		</xsl:call-template>
		<xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=critical&amp;sev-inc=grave&amp;sev-inc=serious</xsl:text>
	      </xsl:attribute>
	      <xsl:value-of select="$other/bugs/item[@name=$pkg]/@rc"/>
	    </xsl:element>, 
	    <xsl:element name="a">
	      <xsl:attribute name="title">important and normal</xsl:attribute>
	      <xsl:attribute name="href">
		<xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data=</xsl:text>
		<xsl:call-template name="escape-name">
		  <xsl:with-param name="text"><xsl:value-of select="text()"/></xsl:with-param>
		</xsl:call-template>
		<xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=important&amp;sev-inc=normal</xsl:text>
	      </xsl:attribute>
	      <xsl:value-of select="$other/bugs/item[@name=$pkg]/@normal"/>
	    </xsl:element>, 
	    <xsl:element name="a">
	      <xsl:attribute name="title">wishlist and minor</xsl:attribute>
	      <xsl:attribute name="href">
		<xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data=</xsl:text>
		<xsl:call-template name="escape-name">
		  <xsl:with-param name="text"><xsl:value-of select="text()"/></xsl:with-param>
		</xsl:call-template>
		<xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=minor&amp;sev-inc=wishlist</xsl:text>
	      </xsl:attribute>
	      <xsl:value-of select="$other/bugs/item[@name=$pkg]/@wishlist"/>
	    </xsl:element>, 
	    <xsl:element name="a">
	      <xsl:attribute name="title">pending and fixed</xsl:attribute>
	      <xsl:attribute name="href">
		<xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data=</xsl:text>
		<xsl:call-template name="escape-name">
		  <xsl:with-param name="text"><xsl:value-of select="text()"/></xsl:with-param>
		</xsl:call-template>
		<xsl:text>&amp;archive=no&amp;pend-inc=pending-fixed&amp;pend-inc=fixed</xsl:text>
	      </xsl:attribute>
	      <xsl:value-of select="$other/bugs/item[@name=$pkg]/@fixed"/>
	    </xsl:element>)
	  </span>
	</li>
      </xsl:for-each>
    </ul>
  </div>
</xsl:template>

<xsl:template name="output-version">
  <xsl:param name="suite" select="''" />
  <xsl:param name="link" select="'yes'" />
  <xsl:variable name="version">
    <span class="srcversion" title="{$suite}">
      <xsl:value-of select="document(concat('../base/', $dir, '/', $suite,
			    '.xml'))/source/version"/>
    </span>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="$link='yes'">
      <xsl:element name="a">
	<xsl:attribute name="class">dsc</xsl:attribute>
        <xsl:attribute name="href">
          <xsl:choose>
            <xsl:when test="starts-with($suite, 'security-')">
              <xsl:value-of select="$security-mirror"/>
              <xsl:text>/</xsl:text>
              <xsl:value-of
                 select="document(concat('../base/', $dir, '/',
                         $suite, '.xml'))/source/directory" />
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$mirror"/>
              <xsl:text>/</xsl:text>
              <xsl:value-of select="$pooldir"/>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:text>/</xsl:text>
          <xsl:value-of select="document(concat('../base/', $dir, '/',
                                $suite, '.xml'))/source/files/item[1]/filename"/>
	</xsl:attribute>
	<xsl:attribute name="title">.dsc, use dget on this link to retrieve source package</xsl:attribute>
	<img src="../common/save.png" alt="save" />
      </xsl:element>
      <xsl:choose>
        <xsl:when test="starts-with($suite, 'security-')">
          <xsl:element name="a">
            <xsl:attribute name="href">
              <xsl:text>http://packages.debian.org/source/</xsl:text>
              <xsl:value-of select="str:replace($suite, 'security-', '')" />
              <xsl:text>/</xsl:text>
              <xsl:copy-of select="$package" />
            </xsl:attribute>
            <xsl:copy-of select="$version" />
          </xsl:element>
        </xsl:when>
        <xsl:when test="str:replace($suite, '-updates', '') != $suite">
          <xsl:copy-of select="$version" />
        </xsl:when>
        <xsl:otherwise>
          <a href="http://packages.debian.org/source/{$suite}/{$package}">
            <xsl:copy-of select="$version" />
          </a>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:copy-of select="$version" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="more-info-marker">
  <xsl:param name="href" />
  <xsl:param name="title">more information are available on an external web page</xsl:param>
  <a href="{$href}">
    <img src="../common/external.png" title="{$title}" alt="..." />
  </a>
</xsl:template>

<xsl:template name="available-versions">
  <div class="block versions">
    <a name="versions" />
    <h2>versions
      <xsl:call-template name="more-info-marker">
	<xsl:with-param name="href">
	  <xsl:text>http://qa.debian.org/madison.php?package=</xsl:text>
	  <xsl:value-of select="$package" />
	</xsl:with-param>
	<xsl:with-param name="title">more versions can be listed by madison</xsl:with-param>
      </xsl:call-template>
      <a class="dsc" href="{$mirror}/{$pooldir}">
	<img src="../common/folder.png" alt="pool" title="pool directory" />
      </a>
    </h2>

    <dl>
      <xsl:if test="$hasoldstable">  
	<dt title="old stable release">oldstable</dt>
	<dd>
	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">oldstable</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hassecurity-oldstable">
	<dt title="security updates for the old stable release">old-sec</dt>
	<dd>
	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">security-oldstable</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hasoldstable-updates">
	<dt title="updates for the old stable release">oldstable-upd</dt>
	<dd>
      	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">oldstable-updates</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hasstable">  
	<dt>stable</dt>
	<dd>
	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">stable</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hassecurity-stable">
	<dt title="security updates for the stable release">stable-sec</dt>
	<dd>
      	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">security-stable</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hasstable-updates">
	<dt title="updates for the stable release">stable-upd</dt>
	<dd>
      	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">stable-updates</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hasstable-proposed-updates">  
	<dt title="stable proposed updates">s-p-u</dt>
	<dd>
	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">stable-proposed-updates</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hastesting">
	<dt>testing</dt>
	<dd>
	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">testing</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hassecurity-testing">
	<dt title="security updates for the testing release">testing-sec</dt>
	<dd>
	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">security-testing</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hastesting-proposed-updates">
	<dt title="testing proposed updates">t-p-u</dt>
	<dd>
	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">testing-proposed-updates</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hasunstable">
	<dt>unstable</dt>
	<dd>
	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">unstable</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hasexperimental">
	<dt title="experimental release">exp</dt>
	<dd>
	  <xsl:call-template name="output-version">
	    <xsl:with-param name="suite">experimental</xsl:with-param>
	  </xsl:call-template>
	</dd>
      </xsl:if>
      <xsl:if test="$hasother and $other/@new_version">
	<dt title="waiting in the NEW queue for FTP master review">
	  <a href="http://ftp-master.debian.org/new.html">NEW</a>
	</dt>
	<dd>
	  <xsl:value-of select="$other/@new_version" />
	</dd>
      </xsl:if>
    </dl>
  </div>
</xsl:template>

<xsl:template name="ubuntu">
  <xsl:if test="$other/@ubuntu='yes'">
    <div class="block ubuntu">
      <a name="ubuntu" />
      <h2>ubuntu
	<img src="../common/ubuntu.png" alt="ubuntu" />
	<xsl:text> </xsl:text>
	<xsl:call-template name="more-info-marker">
	  <xsl:with-param name="href">https://wiki.ubuntu.com/Ubuntu/ForDebianDevelopers</xsl:with-param>
	  <xsl:with-param name="title">Information about Ubuntu for Debian Developers</xsl:with-param>
	</xsl:call-template>
      </h2>
      <ul>
	<li>
	  version: <a href="{$other/ubuntu/@url}"><xsl:value-of select="$other/ubuntu/@version"/></a>
	</li>
	<xsl:if test="$other/ubuntu/patch">
	  <li>
	    <a href="{$other/ubuntu/patch/@url}">patches for
	    <xsl:value-of select="$other/ubuntu/patch/@version"/></a>
	  </li>
	</xsl:if>
	<xsl:if test="$other/ubuntu/bugs">
	  <li>
	    <a href="{$other/ubuntu/bugs/@url}"><xsl:value-of select="$other/ubuntu/bugs/@count"/>
	    bugs</a>
	    <xsl:if test="$other/ubuntu/bugpatches">
	      (<a href="{$other/ubuntu/bugpatches/@url}"><xsl:value-of select="$other/ubuntu/bugpatches/@count"/>
	      patches</a>)
	    </xsl:if>
	  </li>
	</xsl:if>
      </ul>
    </div>
  </xsl:if> 
</xsl:template>

<xsl:template name="other-links">
  <div class="block links">
    <a name="links" />
    <h2>links</h2>
    <ul>
      <xsl:if test="homepage">
        <li><a title="upstream web homepage" href="{homepage}">homepage</a></li>
      </xsl:if>
      <li>
	<xsl:element name="a">
	  <xsl:attribute name="href">
	    <xsl:text>http://packages.debian.org/changelogs/</xsl:text>
	    <xsl:value-of select="directory"/>
	    <xsl:text>/current/changelog</xsl:text>
	  </xsl:attribute>
	  <xsl:text>changelog</xsl:text>
	</xsl:element>
	/
	<xsl:element name="a">
	  <xsl:attribute name="href">
	    <xsl:text>http://packages.debian.org/changelogs/</xsl:text>
	    <xsl:value-of select="directory"/>
	    <xsl:text>/current/copyright</xsl:text>
	  </xsl:attribute>
	  <xsl:text>copyright</xsl:text>
	</xsl:element>
      </li>
      <xsl:if test="architecture!='all'">
	<li>
          <xsl:text>buildd: </xsl:text>
          <a href="https://buildd.debian.org/pkg.cgi?pkg={$escaped-package}"
             title="buildd.debian.org build logs">logs</a>
          <xsl:text>, </xsl:text>
          <!-- <a href="http://people.debian.org/~igloo/status.php?packages={$escaped-package}"
		  title="igloo's build logs on people.debian.org">more</a> -->
          <a href="https://buildd.debian.org/status/package.php?p={$escaped-package}"
             title="build logs on buildd.debian.org">more</a>
          <xsl:text>, </xsl:text>
	       <xsl:if test="$hasexperimental">
                 <!--
		 <a href="http://experimental.debian.net/new/package.php?p={$escaped-package}&amp;suite=experimental"
		    title="experimental.debian.net build logs">exp</a>
                  -->
                 <a href="https://buildd.debian.org/status/package.php?p={$escaped-package}&amp;suite=experimental"
		    title="experimental build logs">exp</a>
		 <xsl:text>, </xsl:text>
	       </xsl:if>
               <a href="http://buildd.debian-ports.org/status/package.php?p={$escaped-package}"
		  title="debian ports build logs">ports</a>
	</li>
      </xsl:if>
      <xsl:if test="$hasother and $other/@piuparts='yes'">
	<li>
	  <a title="report about errors found while stressing package installation"
	     href="http://piuparts.debian.org/sid/source/{$hash}/{$package}.html">piuparts</a>
	</li>
      </xsl:if>
      <xsl:if test="($hasunstable and $other/debcheck/@unstable='yes')
		    or ($hastesting and $other/debcheck/@testing='yes')
		    or ($hasstable and $other/debcheck/@stable='yes')">
	<li>
	  debcheck:
	  <xsl:if test="$hasunstable">
	    <xsl:text> </xsl:text>
            <a href="http://qa.debian.org/debcheck.php?dist=unstable&amp;package={$escaped-package}">unstable</a>
	  </xsl:if>
	  <xsl:if test="$hastesting">
	    <xsl:text> </xsl:text>
            <a href="http://qa.debian.org/debcheck.php?dist=testing&amp;package={$escaped-package}">testing</a>
	  </xsl:if>
	  <xsl:if test="$hasstable">
	    <xsl:text> </xsl:text>
            <a href="http://qa.debian.org/debcheck.php?dist=stable&amp;package={$escaped-package}">stable</a>
	  </xsl:if>
	</li>
      </xsl:if>
      <xsl:if test="$other/@lintian='yes'">
	<xsl:variable name="lintian_url"><xsl:call-template name="mk_lintian_url" /></xsl:variable>
	<li>
	  <a title="report about packaging issues spotted by lintian"
	     href="{$lintian_url}">lintian</a>
	  <!-- <xsl:if test="$lin_errs + $lin_warns > 0"> -->
	  <!--   <xsl:text> </xsl:text> -->
	  <!--   <small><span title="(errors, warnings)">(<span id="lintian_errors"><xsl:value-of select="$lin_errs" /></span>, -->
	  <!-- 	<span id="lintian_warnings"><xsl:value-of select="$lin_warns" /></span>)</span></small> -->
	  <!-- </xsl:if> -->
	</li>
      </xsl:if>
      <li>
        <a title="package popularity"
	   href="http://qa.debian.org/popcon.php?package={$escaped-package}">popcon</a>
      </li>
      <xsl:if test="$other/@svnbuildstat='yes'">
        <li>
          <a href="http://svnbuildstat.debian.net/packages/info/{$escaped-package}">Svnbuildstat</a>
        </li>
      </xsl:if>
      <xsl:if test="$other/i18n/@href">
	<li>
	  <a title="translation status"
	     href="{$other/i18n/@href}">l10n</a>
	  <small>
	    (<span title="completeness of Debian string translation">
	      <xsl:value-of select="$other/i18n/@deb" />
	    </span>,
	    <span title="completeness of non-Debian string translation">
	      <xsl:value-of select="$other/i18n/@nondeb" />
	    </span>)
	  </small>
	</li>
      </xsl:if>
      <xsl:if test="$other/@fonts='yes'">
	<li>
	  <a title="fonts review" href="{$other/fonts/@href}">fonts</a>
	</li>
      </xsl:if>
    </ul>
  </div>
</xsl:template>

<xsl:template name="todo-list">
  <xsl:variable name="todo">
    <xsl:call-template name="issue-security" />
    <xsl:call-template name="issue-nmu" />
    <xsl:call-template name="issue-lintian" />
    <xsl:call-template name="issue-mentors-pending" />
    <xsl:call-template name="issue-comaintenance" />
    <xsl:call-template name="issue-outdate-stdver" />
    <xsl:call-template name="issue-new-upstream" />
    <xsl:call-template name="issue-patches" />
    <xsl:call-template name="issue-l10n" />
    <xsl:if test="$hasother">
      <xsl:for-each select="$other/todo/item">
	<xsl:call-template name="outputitem" />
      </xsl:for-each>
    </xsl:if>
  </xsl:variable>

  <xsl:if test="count($todo)>0 and string($todo)!=''">  
    <div class="block todo">
      <a name="todo" />
      <h2>todo</h2>
      <ul>
	<xsl:copy-of select="$todo" />
      </ul>
    </div>
  </xsl:if>
</xsl:template>

<xsl:template name="problems">
  <xsl:variable name="problems">
    <xsl:call-template name="issue-testing-excuses" />
    <xsl:call-template name="issue-piuparts" />
    <xsl:call-template name="issue-ancient-stdver" />
    <xsl:call-template name="issue-item-dead-package" />
    <xsl:call-template name="issue-item-override-disparity" />
    <xsl:call-template name="issue-item-help-bugs" />
    <xsl:call-template name="issue-item-wnpp" />
    <!-- <xsl:call-template name="issue-item-watch-failure" /> -->
    <xsl:call-template name="issue-item-dehs-failure" />
    <xsl:if test="$hasother">
      <xsl:for-each select="$other/problems/item">
	<xsl:call-template name="outputitem"/>
      </xsl:for-each>
    </xsl:if>
  </xsl:variable>

  <xsl:if test="count($problems)>0 and string($problems)!=''">
    <div class="block problems">
      <a name="problems" />
      <h2>problems</h2>
      <ul>
	<xsl:copy-of select="$problems" />
      </ul>
    </div>
  </xsl:if>
</xsl:template>

<xsl:template name="testing-status">
  <xsl:if test="$hasexcuse or $other/@transitions='yes'">
    <div class="block testing">
      <a name="testing" />
      <h2>testing migration</h2>
      <xsl:if test="$other/@transitions='yes'">
	<xsl:variable name="translist">
	  <xsl:for-each select="$other/transitions/transition">
	    <xsl:value-of select="@name" />
	    <xsl:if test="position() != last()"> <xsl:text> </xsl:text>
	    </xsl:if>
	  </xsl:for-each>
	</xsl:variable>
	<xsl:variable name="transno"
		      select="count($other/transitions/transition)" />
	<div class="warning">
	  <!-- XXX unappropriate <ul>, just to make the text looks like other
	       boxes, should be fixed on the CSS side (getting rid of <ul>) -->
	  <p>This package is part of <em><xsl:value-of select="$transno" /> ongoing
	      testing transition<xsl:if test="$transno != '1'">s</xsl:if></em>
	    (namely: <tt><xsl:value-of select="$translist" /></tt>). For
	    more information see the
	    <a href="http://ftp-master.debian.org/transitions.yaml">transition
	      status file</a>.<br />
	    <em>Uploads to unstable will be rejected</em> while
	    transitions are ongoing; you might want to upload to
	    experimental in the meantime, or
	    contact <tt><a href="mailto:debian-release@lists.debian.org">debian-release</a></tt>
	    if an upload is really necessary.
	  </p>
	</div>
      </xsl:if>
      <xsl:if test="$hasexcuse">
        <a title="reasons why the package is not moving to testing"
           href="http://qa.debian.org/excuses.php?package={$package}">excuses</a>:
	<ul class="testing-excuses">
	  <xsl:for-each select="document(concat('../base/', $dir, '/excuse.xml'))/excuse/item">
	    <xsl:call-template name="outputitem"/>
	  </xsl:for-each>
	</ul>
      </xsl:if>
    </div>
  </xsl:if>
</xsl:template>

<xsl:template name="static-info">
  <xsl:call-template name="output-static">
    <xsl:with-param name="static" select="$static" />
  </xsl:call-template>
</xsl:template>

<xsl:template name="latest-news">
  <xsl:call-template name="output-news">
    <xsl:with-param name="news" select="$news" />
  </xsl:call-template>
</xsl:template>

<xsl:variable name="static">
  <xsl:if test="$hasnews">
    <xsl:for-each select="document(concat('../base/', $dir, '/news.xml'))/news/static/item">
      <xsl:call-template name="outputitem"/>
    </xsl:for-each>
  </xsl:if>
</xsl:variable>

<xsl:variable name="news">
  <xsl:if test="$hasnews">
    <xsl:for-each select="document(concat('../base/', $dir, '/news.xml'))/news/news/item">
      <xsl:call-template name="outputitem"/>
    </xsl:for-each>
  </xsl:if>
</xsl:variable>

<!-- All the work is done in a single template -->
<xsl:template match="source">

  <!-- Start of html -->
  <html>
    <head>
      <meta name="ROBOTS" content="NOFOLLOW"/>
      <link type="text/css" title="User selected" rel="stylesheet" href="../common/default.css"/>
      <link type="text/css" title="Official" rel="alternate stylesheet" href="../common/revamp.css"/>
      <link type="text/css" title="Legacy PTS" rel="alternate stylesheet" href="../common/pts.css"/>
      <link type="text/css" title="Compact rendering" rel="alternate stylesheet" href="../common/compact.css"/>
      <script type="text/javascript" src="../common/pts.js"></script>
      <xsl:if test="count($news)>0 and string($news)!=''">
	<link rel="alternate" type="application/rss+xml" title="RSS"
	      href="{$package}/news.rss20.xml" />
      </xsl:if>
      <title>Debian Package Tracking System -
	<xsl:value-of select="$package"/></title>
    </head>
    <body onload="javascript:onLoad();">
      <div class="quickform" style="float: right;">
	<form title="jump to the PTS page of another source package"
	      method="get" action="/common/index.html">
	  <p>
	    <input type="text" size="14" name="src" value=""/>
	    <input type="submit" value="jump to" />
	  </p>
	</form>
      </div>

      <h1>
	<xsl:value-of select="$package"/><br />
	<small>source package</small>
      </h1>

      <div id="body">
	<xsl:choose>
	  <xsl:when test="$removed='yes'">
	    <div class="block removed">
	      <p>This package is not part of any Debian
		distribution. Thus you won't find much information
		here. The package is either very new and hasn't
		appeared on mirrors yet, or it's an old package that
		eventually got removed.  The old news are kept for
		historic purpose only.</p>
	      <xsl:call-template name="static-info" />
	      <xsl:call-template name="latest-news" />
	    </div>
	  </xsl:when>
	  <xsl:otherwise>	<!-- non removed package -->
	    <div class="left maincol">
	      <xsl:call-template name="general-information" />
	      <xsl:call-template name="available-versions" />
	      <xsl:call-template name="binary-packages" />
	    </div>
	    <div class="center maincol">
	      <xsl:call-template name="todo-list" />
	      <xsl:call-template name="problems" />
	      <xsl:call-template name="testing-status" />
	      <xsl:call-template name="static-info" />
	      <xsl:call-template name="latest-news" />
	    </div>
	    <div class="right maincol">
	      <xsl:call-template name="bugs-count" />
	      <xsl:call-template name="other-links" />
	      <xsl:call-template name="ubuntu" />
	    </div>
	  </xsl:otherwise>
	</xsl:choose>

	<hr/>
	<div class="footer">
          <table width="100%">
            <tr>
	      <td>
              <!--
		<div class="quickform">
		  <form id="csspref-form" method="get"
			action="/common/set-csspref.php">
		    <p>
		      change skin:
		      <select name="csspref" onchange="javascript:onChangeStyle();">
			<option value="revamp.css">default</option>
			<option value="compact.css">compact</option>
			<option value="pts.css">legacy</option>
		      </select>
		    </p>
		  </form>
		</div>
              -->
		<div class="quickform">
		  <xsl:call-template name="pts-subscription" />
		</div>
	      </td>
              <td>
                <p>
                  <em><a href="http://www.debian.org">Debian</a>
                    Package Tracking System</em> - Copyright ©
                    2002-2009 Raphaël Hertzog, Stefano Zacchiroli and
                    others.<br/> Report problems to the
                  <a href="http://bugs.debian.org/qa.debian.org"><tt>qa.debian.org</tt>
                    pseudopackage</a> in the <a href="http://bugs.debian.org">Debian
                    <acronym title="Bug Tracking System">BTS</acronym></a>.<br/>
                  Last modified: <xsl:value-of select="$date"/>.
                </p>
              </td>
              <td>
                <a href="http://validator.w3.org/check?uri=referer">
		  <img
		     src="http://www.w3.org/Icons/valid-xhtml10-blue"
		     alt="Valid XHTML 1.0 Strict" height="31" width="88" />
		</a>
              </td>
            </tr>
          </table>
	</div>
      </div>
    </body>
  </html>
</xsl:template>

</xsl:stylesheet>
