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

<!--
# Copyright 2002-2008 Raphaël Hertzog and others
# Copyright 2007-2008 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"
  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="hasoldstable-security" select="''"/>
<xsl:param name="hasstable-security" select="''"/>
<xsl:param name="hastesting-security" select="''"/>
<xsl:param name="hassecure-testing" select="''"/>
<xsl:param name="hasvolatile" 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"/>

<!-- Those variables controls the todo and problem item concerning
     standards-version not being up to date -->
<xsl:variable name="lastsv" select="'3.8.0'"/>
<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/reports/maintainer/</xsl:text>
  <xsl:value-of select="$lintian_email" />
  <xsl:text>.html#</xsl:text>
  <xsl:value-of select="$package" />
</xsl:template>

<xsl:template name="mirror">
  <xsl:text>http://ftp.debian.org/debian</xsl:text>  
</xsl:template>

<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: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">
    <tr>
      <td class="labelcell">
        <xsl:text>Version Control</xsl:text>
      </td>
      <td class="contentcell">
        <xsl:if test="repository/vcs[@kind='browser']">
          <a href="{repository/vcs[@kind='browser']/@url}">
            <xsl:text>browser</xsl:text>
          </a>
          <br />
        </xsl:if>
        <xsl:if test="repository/vcs[@kind!='browser']">
          <xsl:text>raw: </xsl:text>
          <xsl:for-each select="repository/vcs[@kind!='browser']">
            <xsl:sort select="@kind" />
            <a href="{@url}">
              <xsl:value-of select="@kind" />
            </a>
            <xsl:if test="position()!=last()">
              <xsl:text>, </xsl:text>
            </xsl:if>
          </xsl:for-each>
        </xsl:if>
      </td>
    </tr>
  </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)!=''">
    <tr>
      <td class="labelcell">
	<xsl:text>Maintenance info</xsl:text>
      </td>
      <td class="contentcell">

	<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: can be uploaded by Debian Maintainers">DMUA</acronym></a>
	  </span>
          <xsl:text> </xsl:text>
	</xsl:if>

        <xsl:if test="string($lownmu)!=''">
	  <span class="lownmu-tag">
            <a href="http://wiki.debian.org/LowThresholdNmu"><acronym
                title="maintainer agrees with Low Threshold NMU, see wiki page for details">LowNMU</acronym></a>
	  </span>
          <xsl:text> </xsl:text>
        </xsl:if>
      </td>
    </tr>
  </xsl:if>
</xsl:template>

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

  <xsl:if test="count($news)>0 and string($news)!=''">
    <tr class="titlerow">
    <td class="titlecell">
      Latest news <a class="feedlink" href="{$package}/news.rss20.xml">RSS</a>
    </td></tr>
    <tr class="normalrow">
    <td class="contentcell2">
    <ul id="news-list"><xsl:copy-of select="$news"/></ul>
    </td>
    </tr>
  </xsl:if>
</xsl:template>

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

  <xsl:if test="count($static)>0 and string($static)!=''">
    <tr class="titlerow">
    <td class="titlecell">
    Static Information
    </td></tr>
    <tr class="normalrow">
    <td class="contentcell2">
    <ul><xsl:copy-of select="$static"/></ul>
    </td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="categorize-srcfile">
  <!-- used to recognize (and tag afterwards) well-known type of source package
    components: dsc, diff, orig -->
  <xsl:choose>
    <xsl:when test="substring(filename,string-length(filename)-2, 3)='dsc'">
      <xsl:text>dsc</xsl:text>
    </xsl:when>
    <xsl:when test="substring(filename,string-length(filename)-6, 7)='diff.gz'">
      <xsl:text>diff</xsl:text>
    </xsl:when>
    <xsl:when test="substring(filename,string-length(filename)-5, 3)='tar'">
      <xsl:text>orig</xsl:text>
    </xsl:when>
    <xsl:otherwise><xsl:text></xsl:text></xsl:otherwise>
  </xsl:choose>
</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">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">General information</td>
  </tr>
  <tr class="normalrow">
    <td class="labelcell">Latest version</td>
    <td class="contentcell"><xsl:value-of select="version"/></td>
  </tr>
  <xsl:if test="@release!='unstable'">
    <tr class="normalrow">
      <td class="labelcell">Distribution</td>
      <td class="contentcell"><xsl:value-of select="@release"/></td>
    </tr>
  </xsl:if>
  <tr class="normalrow">
    <td class="labelcell">Maintainer</td>
    <td class="contentcell">
      <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>
	<xsl:value-of select="maintainer/name"/>
      </xsl:element>
      <xsl:text> </xsl:text>
      <xsl:call-template name="maintainer-email">
	<xsl:with-param name="email" select="maintainer/email" />
      </xsl:call-template>
    </td>
  </tr>
  <xsl:if test="uploaders">
    <tr class="normalrow">
      <td class="labelcell"><a href="http://www.debian.org/doc/manuals/developers-reference/ch-pkgs.en.html#s-collaborative-maint">Uploaders</a></td>
      <td class="contentcell">
        <xsl:for-each select="uploaders/item">
          <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>
            <xsl:value-of select="name"/>
          </xsl:element>
          <xsl:text> </xsl:text>
          <xsl:call-template name="maintainer-email">
            <xsl:with-param name="email" select="email" />
          </xsl:call-template>
          <br />
        </xsl:for-each>
        <xsl:call-template name='add-maintenance-info'>
          <xsl:with-param name="email" select="maintainer/email" />
        </xsl:call-template>
    </td></tr>
  </xsl:if>
  <tr class="normalrow">
    <td class="labelcell">Standards version</td>
    <td class="contentcell"><xsl:value-of select="standards-version"/></td>
  </tr>
  <tr class="normalrow">
    <td class="labelcell">Priority</td>
    <td class="contentcell"> <xsl:value-of select="priority"/> </td>
  </tr>
  <tr class="normalrow">
    <td class="labelcell">Section</td>
    <td class="contentcell"> <xsl:value-of select="section"/> </td>
  </tr>
  <xsl:call-template name='add-vcs-info' />
  <xsl:if test="architecture!='any' and architecture!='all'">
    <tr class="normalrow">
      <td class="labelcell">Architecture</td>
      <td class="contentcell"><xsl:value-of select="architecture"/></td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="bugs-count">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">Bugs count</td>
  </tr>
  <tr class="normalrow" id="bugs_all">
    <td class="labelcell">All bugs
       (<xsl:element name="a">
	<xsl:attribute name="href">
	  <xsl:text>http://people.debian.org/~glandium/bts/</xsl:text>
	  <xsl:value-of select="substring($package, 1, 1)"/>
	  <xsl:text>/</xsl:text>
	  <xsl:value-of select="$escaped-package" />
	  <xsl:text>.png</xsl:text>
	</xsl:attribute>
	<xsl:text>graph</xsl:text>
      </xsl:element>
      <xsl:text>)</xsl:text>
    </td>
    <td class="contentcell">
      <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">
	  <xsl:value-of select="$other/bugs/@all"/>
	</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>
    </td>
  </tr>
  <tr class="normalrow" id="bugs_rc">
    <td class="labelcell"><span class="indented"><acronym title="Release Critical">RC</acronym> bugs</span></td>
    <td class="contentcell">
      <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">
	  <xsl:value-of select="$other/bugs/@rc"/>
	</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>
    </td>
  </tr>
  <tr class="normalrow" id="bugs_in">
    <td class="labelcell"><span class="indented"><acronym title="Important and Normal">I&amp;N</acronym> bugs</span></td>
    <td class="contentcell">
      <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">
	  <xsl:value-of select="$other/bugs/@normal"/>
	</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>
    </td>
  </tr>
  <tr class="normalrow" id="bugs_mw">
    <td class="labelcell"><span class="indented"><acronym title="Minor and Wishlist">M&amp;W</acronym> bugs</span></td>
    <td class="contentcell">
      <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">
	  <xsl:value-of select="$other/bugs/@wishlist"/>
	</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>
    </td>
  </tr>
  <tr class="normalrow" id="bugs_fp">
    <td class="labelcell"><span class="indented"><acronym title="Fixed and Pending">F&amp;P</acronym> bugs</span></td>
    <td class="contentcell">
      <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">
	  <xsl:value-of select="$other/bugs/@fixed"/>
	</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>
    </td>
  </tr>
  <xsl:if test="$other/bugs/@gift > 0">
    <tr class="normalrow" id="bugs_gift">
      <td class="labelcell"><span class="indented"><a
	    href="http://wiki.debian.org/qa.debian.org/GiftTag">Gift</a>
	  bugs</span></td>
      <td class="contentcell">
	<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>
	  <xsl:value-of select="$other/bugs/@gift" />
	</xsl:element>
      </td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="pts-subscription">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">
      <a class="titlelink" href="http://www.debian.org/doc/manuals/developers-reference/ch-resources.en.html#s-pkg-tracking-system"><acronym title="Package Tracking System">PTS</acronym></a> subscription
  </td></tr>
  <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>
  <tr class="normalrow">
    <td class="contentcell" colspan="2">
      <form method="post" action="/cgi-bin/pts.cgi">
	<p>
	  <input type="hidden" name="package" value="{$package}"/>
	  <select name="what">
	    <option value="subscribe">Subscribe</option>
	    <option value="unsubscribe">Unsubscribe</option>
	    <option value="advanced">Advanced mode</option>
	  </select>
          <input type="text" name="email" size="15" value="your email"
            onfocus="if(email.value=='your email'){{email.value=''}}"/>
	  <input type="submit" name="submit" value="Send"/>
	</p>
      </form>
    </td>
  </tr>
</xsl:template>

<xsl:template name="binary-packages">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">Binary packages</td>
  </tr>
  <tr class="normalrow">
    <td class="normalcell" colspan="2" style="text-align: left">
      <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()}"><xsl:value-of select="text()"/></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></td></tr>
</xsl:template>

<xsl:template name="available-versions">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">
      Available versions
  </td></tr>

  <!-- oldstable -->
  <xsl:if test="$hasoldstable">  
    <tr class="normalrow">
      <td class="labelcell"><a href="http://www.debian.org/releases/sarge/">Oldstable</a></td>
      <td class="contentcell">
        <a href="http://packages.debian.org/source/oldstable/{$package}"><xsl:value-of
            select="document(concat('../base/', $dir, '/oldstable.xml'))/source/version"/></a>
      </td>
    </tr>
  </xsl:if>
  <xsl:if test="$hasoldstable-security">
    <tr class="normalrow">
      <td class="labelcell"><small>Oldstable Security Updates</small></td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/oldstable-security.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>

  <!-- stable -->
  <xsl:if test="$hasstable">  
    <tr class="normalrow">
      <td class="labelcell"><a href="http://www.debian.org/releases/stable/">Stable</a></td>
      <td class="contentcell">
        <a href="http://packages.debian.org/source/stable/{$package}"><xsl:value-of
            select="document(concat('../base/', $dir, '/stable.xml'))/source/version"/></a>
      </td>
    </tr>
  </xsl:if>
  <xsl:if test="$hasstable-security">
    <tr class="normalrow">
      <td class="labelcell"><small>Stable Security Updates</small></td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/stable-security.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>
  <xsl:if test="$hasstable-proposed-updates">  
    <tr class="normalrow">
      <td class="labelcell"><small>Stable Proposed Updates</small></td>
      <td class="contentcell">
        <xsl:value-of select="document(concat('../base/', $dir,
            '/stable-proposed-updates.xml'))/source/version" />
      </td>
    </tr>
  </xsl:if>

  <!-- testing -->
  <xsl:if test="$hastesting">
    <tr class="normalrow">
      <td class="labelcell"><a href="http://www.debian.org/releases/testing/">Testing</a></td>
      <td class="contentcell">
        <a href="http://packages.debian.org/source/testing/{$package}"><xsl:value-of
            select="document(concat('../base/', $dir, '/testing.xml'))/source/version"/></a>
      </td>
    </tr>
  </xsl:if>
  <xsl:if test="$hastesting-security">
    <tr class="normalrow">
      <td class="labelcell"><small>Testing Security Updates</small></td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/testing-security.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>
  <xsl:if test="$hastesting-proposed-updates">
    <tr class="normalrow">
      <td class="labelcell"><small>Testing Proposed Updates</small></td>
      <td class="contentcell">
        <xsl:value-of select="document(concat('../base/', $dir,
            '/testing-proposed-updates.xml'))/source/version" />
      </td>
    </tr>
  </xsl:if>

  <!-- unstable -->
  <xsl:if test="$hasunstable">
    <tr class="normalrow">
      <td class="labelcell">Unstable</td>
      <td class="contentcell">
        <a href="http://packages.debian.org/source/unstable/{$package}"><xsl:value-of
            select="document(concat('../base/', $dir, '/unstable.xml'))/source/version"/></a>
      </td>
    </tr>
  </xsl:if>

  <!-- experimental -->
  <xsl:if test="$hasexperimental">
    <tr class="normalrow">
      <td class="labelcell">Experimental</td>
      <td class="contentcell">
        <a href="http://packages.debian.org/source/experimental/{$package}"><xsl:value-of
            select="document(concat('../base/', $dir, '/experimental.xml'))/source/version"/></a>
      </td>
    </tr>
  </xsl:if>

  <!-- secure-testing -->
  <xsl:if test="$hassecure-testing">
    <tr class="normalrow">
      <td class="labelcell">Secure testing</td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/secure-testing.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>

  <!-- volatile -->
  <xsl:if test="$hasvolatile">
    <tr class="normalrow">
      <td class="labelcell">Volatile</td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/volatile.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="ubuntu">
  <!-- Patches list [FG] -->
  <xsl:if test="$other/@ubuntu='yes'">
    <tr class="titlerow">
      <td class="titlecell" colspan="2">
	Ubuntu
    </td></tr>
    <tr>
      <td class="contentcell" colspan="2" style="text-align: left">
	<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}">Patch for version <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"/> open bugs</a>
	    </li>
	  </xsl:if>
	</ul>
      </td>
    </tr>
  </xsl:if> 
</xsl:template>

<xsl:template name="other-links">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">
      Other links
  </td></tr>
  <tr>
    <td class="contentcell" colspan="2" style="text-align: left">
      <ul>
        <xsl:if test="homepage">
          <li> <a href="{homepage}">Upstream 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="http://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="http://buildd.debian.org/~jeroen/status/package.php?p={$escaped-package}"
              title="jeroen's build logs on buildd.debian.org">more</a>
            <xsl:text>, </xsl:text>
            <a href="http://experimental.debian.net/build.php?pkg={$escaped-package}"
              title="experimental.debian.net build logs">exp</a>
            <xsl:text>, </xsl:text>
            <a href="http://buildd.debian-ports.org/status/package.php?p={$escaped-package}"
              title="debian ports build logs">ports</a>
	  </li>
	</xsl:if>
	<!-- DISABLED until ddtp.debian.org is back up
	<li>
	  <xsl:element name="a">
	    <xsl:attribute name="href">
	      <xsl:text>http://ddtp.debian.org/stats/pdesc/report.cgi?package=</xsl:text>
	      <xsl:call-template name="escape-name">
		<xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
	      </xsl:call-template>
	      <xsl:text>&amp;lang=all&amp;type=src-drvbin&amp;subword=0</xsl:text>
	    </xsl:attribute>
	    Description's translations (DDTP)
	  </xsl:element>
	</li>
	<xsl:if test="$other/@debconf='yes'">
	  <li>
	    <xsl:element name="a">
	      <xsl:attribute name="href">
		<xsl:text>http://ddtp.debian.org/cgi-bin/ddtp.cgi?part=debconf&amp;package=</xsl:text>
		<xsl:call-template name="escape-name">
		  <xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
		</xsl:call-template>
	      </xsl:attribute>
	      Debconf templates's translations (DDTP)
	    </xsl:element>
	  </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 on:
	    <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 href="{$lintian_url}">Lintian report</a>
	    <xsl:if test="$lin_errs + $lin_warns > 0">
	      <xsl:text> </xsl:text>
	      <small><span title="(errors, warnings)">(<xsl:value-of select="$lin_errs" />,
		  <xsl:value-of select="$lin_warns" />)</span></small>
	    </xsl:if>
	  </li>
	</xsl:if>
	<li>
          <a href="http://qa.debian.org/developer.php?popcon={$escaped-package}">Popcon stats</a>
	</li>
        <xsl:if test="$other/@svnbuildstat='yes'">
          <li>
            <a href="http://svnbuildstat.debian.net/packages/info/{$escaped-package}">Svnbuildstat</a>
          </li>
        </xsl:if>
      </ul>
    </td>
  </tr>
</xsl:template>

<xsl:template name="package-files">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">Source package</td>
  </tr>
  <tr class="titlerow">
    <td class="labelcell">
      <xsl:element name="a">
	<xsl:attribute name="href">
	  <xsl:call-template name="mirror"/>
	  <xsl:text>/</xsl:text>
	  <xsl:value-of select="directory"/>
	  <xsl:text>/</xsl:text>
	</xsl:attribute>
	<xsl:text>Files</xsl:text>
      </xsl:element>
    </td>
    <td class="contentcell" id="src_files">
      <ul>
	<xsl:for-each select="files/item">
	  <xsl:variable name="filetype">
	    <xsl:call-template name="categorize-srcfile" />
	  </xsl:variable>
	  <xsl:element name="li">
	    <xsl:attribute name="class">srcfile</xsl:attribute>
	    <xsl:if test="string($filetype)!=''">
	      <xsl:attribute name="id">
		<xsl:text>srcfile_</xsl:text>
		<xsl:value-of select="$filetype" />
	      </xsl:attribute>
	    </xsl:if>
	    <xsl:element name="a">
	      <xsl:attribute name="class">srcfile</xsl:attribute>
	      <xsl:attribute name="href">
		<xsl:call-template name="mirror"/>	  
		<xsl:text>/</xsl:text>
		<xsl:value-of select="../../directory"/>
		<xsl:text>/</xsl:text>
		<xsl:value-of select="filename"/>
	      </xsl:attribute>
	      <xsl:attribute name="title">
		<xsl:value-of select="filename" />
		<xsl:text>: </xsl:text>
		<xsl:value-of select="size"/>
		<xsl:text> bytes</xsl:text>
	      </xsl:attribute>
	      <xsl:text>.</xsl:text>
	      <xsl:value-of select="$filetype"/>
	    </xsl:element>
	  </xsl:element>
	</xsl:for-each>
      </ul>
    </td>
  </tr>
</xsl:template>

<xsl:template name="todo-list">
  <xsl:variable name="todo">
    <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: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)!=''">  
    <tr class="titlerow">
      <td class="titlecell" id="todo">Todo</td>
    </tr>
    <tr class="normalrow">
      <td class="contentcell2"><ul><xsl:copy-of select="$todo"/></ul></td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="problems">
  <xsl:variable name="problems">
    <xsl:call-template name="issue-testing-excuses" />
    <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)!=''">
    <tr class="titlerow">
      <td class="titlecell" id="problems">Problems</td>
    </tr>
    <tr class="normalrow">
      <td class="contentcell2"><ul><xsl:copy-of select="$problems"/></ul></td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="testing-status">
  <xsl:if test="$hasexcuse or $other/@transitions='yes'">
    <tr class="titlerow">
      <td class="titlecell">
	Testing status
    </td></tr>
  </xsl:if>
  <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)" />
    <tr class="normalrow">
      <td class="contentcell2" style="text-align: left">
	<ul>
	  <!-- XXX unappropriate <ul>, just to make the text looks like other
	    boxes, should be fixed on the CSS side (getting rid of <ul>) -->
	      <li>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.
	      </li>
	    </ul>
	  </td>
	</tr>
      </xsl:if>
      <xsl:if test="$hasexcuse">
	<tr class="normalrow">
	  <td class="contentcell2" style="text-align: left">
	    <ul>
	      <xsl:for-each select="document(concat('../base/', $dir, '/excuse.xml'))/excuse/item">
		<xsl:call-template name="outputitem"/>
	      </xsl:for-each>
	    </ul>
	  </td>
	</tr>
      </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>Overview of <xsl:value-of select="$package"/> source package</title>
	</head>
	<body onload="javascript:onLoad();">

	  <div id="quickforms" style="float: right;">
	    <form method="get" action="/common/index.html">
	      <p><span title="Jump to package">Go:</span> 
		<input type="text" name="src" value=""/></p>
	    </form>
	    <form id="csspref-form" method="get" action="/common/set-csspref.php">
	      <p>Switch style: <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>
	  <h1>Overview of
	    <xsl:element name="a">
	      <xsl:attribute name="href">
		<xsl:text>http://packages.debian.org/src:</xsl:text>
		<xsl:value-of select="$package"/>
	      </xsl:attribute>
	      <xsl:value-of select="$package"/>
	    </xsl:element>
	    source package</h1>

	  <div id="body">
	    <xsl:choose>
	      <xsl:when test="$removed='yes'">
		<!-- REMOVED PACKAGE -->
		<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>

		<table class="righttable">
		  <xsl:call-template name="static-info" />
		  <xsl:call-template name="latest-news" />
		</table>

		<!-- END REMOVED PACKAGE -->
	      </xsl:when>
	      <xsl:otherwise>
		<!-- NON REMOVED PACKAGE -->

		<table class="containertable">
		  <tr class="containerrow" valign="top">
		    <td class="containercell">
		      <!-- LEFT SIDE -->
		      <table class="lefttable">
			<xsl:call-template name="general-information" />
			<xsl:call-template name="available-versions" />
		      </table>
		      <table class="lefttable">
			<xsl:call-template name="package-files" />
			<xsl:call-template name="binary-packages" />
		      </table>
		      <!-- END LEFT SIDE -->
		      </td><td class="containercell">
		      <!-- RIGHT SIDE -->
		      <table class="righttable">
			<xsl:call-template name="todo-list" />
			<xsl:call-template name="problems" />
		      </table>
		      <table class="righttable">
			<xsl:call-template name="testing-status" />
			<xsl:call-template name="static-info" />
			<xsl:call-template name="latest-news" />
		      </table>
		      <!-- END RIGHT SIDE -->
		      </td><td class="containercell">
		      <table class="lefttable">
			<xsl:call-template name="bugs-count" />
			<xsl:call-template name="pts-subscription" />
		      </table>
		      <table class="lefttable">
			<xsl:call-template name="other-links" />
		      </table>
		      <table class="lefttable" id="ubuntubox">
			<xsl:call-template name="ubuntu" />
		      </table>
		  </td></tr>
		</table>

		<!-- END NON REMOVED PACKAGE -->
	      </xsl:otherwise>
	    </xsl:choose>

	    <hr/>
	    <div class="footer">
              <table width="100%">
                <tr>
                  <td>
                    <p>
                      <em><a href="http://www.debian.org">Debian</a> Package
                        Tracking System</em> - Copyright 2002-2008 Raphaël
                      Hertzog 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>
