<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type="text/xsl"
	href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
        "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<article xml:base="http://debian-med.alioth.debian.org/">
	<title>Debian Med Group Policy</title>
  <articleinfo>
		<authorgroup>
			<author>
        <firstname>Andreas</firstname>
        <surname>Tille</surname>
				<contrib>First review </contrib>
				<email>tille@debian.org</email>
			</author>
			<author>
        <firstname>David</firstname>
        <surname>Paleino</surname>
				<contrib>Initial writing </contrib>
				<email>d.paleino@gmail.com</email>
			</author>
			<author>
        <firstname>Charles</firstname>
        <surname>Plessy</surname>
				<contrib>Contributions in 2008 and 2011</contrib>
				<email>plessy@debian.org</email>
			</author>
		</authorgroup>
		<releaseinfo>
			$ policy.xml rev. @REV@ - @DATE@ (@AUTHOR@) $
		</releaseinfo>
		<releaseinfo>
			Source: svn://svn.debian.org/debian-med/trunk/community/website/docs/policy.xml
		</releaseinfo>
  </articleinfo>
	<mediaobject>
    <objectinfo>
      <title>Debian Med Group</title>
    </objectinfo>
		<imageobject>
			<imagedata fileref="/img/debian-med.jpg" format="JPG" align="center" />
		</imageobject>
	</mediaobject>
	<sect1 id="introduction">
		<title>Introduction</title>
		<para>Debian Med is a <quote><ulink url="http://blends.alioth.debian.org/blends">Debian Pure Blend</ulink></quote>
		with the aim to develop Debian into an operating system that is particularly
		well fit for the requirements for medical practice and research.</para>
		<para>The Debian Med project presents packages that are associated
		with medicine, pre-clinical research, and life sciences. Its developments
		are mostly focused on three areas for the moment: medical practice,
		imaging and bioinformatics.</para>
		<para>Over the previous years, several initiatives have spawned that
		address the scientific disciplines like chemistry or bioinformatics.
		Debian Med is not a competition to these efforts but a platform to
		present the packages to the community as a Debian Pure Blend.</para>
	</sect1>
	<sect1 id="contribute">
		<title>How to Contribute</title>
		<para>From the developer to the user, there is a long chain of tasks
		in which we always welcome participation. First we must keep ourselves
		informed about the software landscape in biology and medicine. Software
		to be packaged is chosen according to criteria such as users' need and
		the consistency of the distribution.</para>
		<para>Once in Debian, the software is monitored for its quality and bugs
		are fixed, if possible in collaboration with the upstream maintainer(s).
		All this work would not be very useful if it remains confidential.</para>
		<para>We also dedicate some time to advertise it to the world via
		<ulink url="http://www.debian.org">www.debian.org</ulink>
		and to ease the integration of new members.</para>
		<para>Please contact us on <ulink url="mailto:debian-med@lists.debian.org">debian-med@lists.debian.org</ulink>
		if you want to help to make medical and biological software available
		to Debian users. Read the <link linkend="membership">Membership</link> section if you're
		interested in joining us.</para>
		<para>If you speak a language other than English, you can contribute
		rightaway with translations of package descriptions at
		<ulink url="http://ddtp.debian.net">ddtp.debian.net</ulink>.</para>
		<para>When working on these, you will find immediate targets for improvements
		of the original English versions, too. For these, though, you need access
		to Debian Med's source code repository. Very welcome are tutorials that
		guide Debian users towards the use of packages to their immediate benefit.
		You may also consider to write respective articles for Magazines, be they
		online or in print.</para>
		<sect2 id="membership">
			<title>Membership</title>
			<para>To request membership to this group, please go on our
			<ulink url="http://alioth.debian.org/projects/debian-med">Alioth page</ulink>,
			or directly follow this <ulink url="http://alioth.debian.org/project/request.php?group_id=30063">link</ulink>.
			Remember that you must have an Alioth account before requesting
			membership (see <ulink url="http://alioth.debian.org/account/register.php">here</ulink>
			to request an Alioth account).</para>
		</sect2>
		<sect2 id="readings">
			<title>Essential readings</title>
			<itemizedlist>
				<listitem><para>The <ulink url="http://www.debian.org/doc/debian-policy/">Debian Policy</ulink>: packages must conform to it.</para></listitem>
				<listitem><para>The <ulink url="http://www.debian.org/doc/developers-reference/">Developers Reference</ulink>: details best packaging practices.</para></listitem>
				<listitem><para>The <ulink url="http://www.debian.org/doc/maint-guide/">New Maintainer's Guide</ulink>: puts a bit of the two above in practice.</para></listitem>
				<listitem><para>The <ulink url="http://debian-med.alioth.debian.org/docs/policy.html">Debian Med Policy</ulink> (this document): explains how the work is organised in our team..</para></listitem>
			</itemizedlist>
		</sect2>
	</sect1>
	<sect1 id="repositories">
		<title>Repositories</title>
		<para>We use Subversion (SVN) and Git repositories, hosted 
		by Debian. You can have a look at
		each repository through Alioth's web interfaces: <ulink url="http://svn.debian.org/wsvn/debian-med/trunk/?rev=0&amp;sc=0">wsvn</ulink>
		<ulink url="http://svn.debian.org/viewsvn/debian-med">viewsvn</ulink> and
		<ulink url="http://git.debian.org/">gitweb</ulink>.</para>
		<para>The Subversion repository is the primary location for our source packages.
		  However, the Git repository is free to use for special cases, for instance when
		  the Subversion tags take a disproportionated size, when the maintainer is
		  much more comfortable with Git than Subversion, when some special features of
		  Git or git-buildpackage are desired, or more simply when the maintainer wants
		  to take the opportunity to familiarise with Git.
		</para>
		<warning id="umask">
			<para>
				For most direct operations on the repositories in Alioth, an <command>umask</command> of <literal>002</literal> is necessary to avoid problems of missing write permission to the other team members.
			</para>
		</warning>
		<sect2 id="source">
			<title>Give me the source!</title>
			<para>
				To check the sources of a package (referred as
				<emphasis>&lt;package&gt;</emphasis> below) in our repositories, use the
				<command>debcheckout</command> command, from the
				<ulink url="http://packages.debian.org/devscripts">devscripts</ulink>
				package.
				<itemizedlist>
					<listitem>
						<para>
							If you are a member of Debian Med or a Debian developer, with
							account name <emphasis>&lt;username&gt;</emphasis>, you have
							write permission:<programlisting>
<command>debcheckout</command> <option>--user</option><replaceable>&lt;username&gt;</replaceable> <replaceable>&lt;package&gt;</replaceable>   # When the package is already in the archive
<command>debcheckout</command> <option>--user</option> <replaceable>&lt;username&gt;</replaceable> <replaceable>ssh://svn.debian.org/debian-med/trunk/packages/&lt;package&gt;/trunk</replaceable> <replaceable>&lt;package&gt;</replaceable>
<command>debcheckout</command> <option>--user</option> <replaceable>&lt;username&gt;</replaceable> <replaceable>git://git.debian.org/debian-med/&lt;package&gt;.git</replaceable> <option>--git-track<replaceable>'*'</replaceable></option></programlisting> 
						</para>
					</listitem>
					<listitem>
						<para>
							For read-only access, remove the <option>--user</option> option.
						</para>
					</listitem>
				</itemizedlist>
			</para>
		</sect2>
		<sect2 id="ssh-tips">
			<title>SSH tips</title>
			<para id="ssh-config">
				You can avoid specifying your Alioth user name by setting it in
				<filename>~/.ssh/config</filename> as follows.  Note that in that case,
				with <command>debcheckout</command> you will can replace the
				<option>--user</option> option by the <option>-a</option> option, for a
				shorter typing.<programlisting>
Host *.debian.org
	User your-user-name</programlisting>
			</para>
			<para id="ssh-add">
				You can avoid typing your SSH password again and again using the
				<code><command>ssh-add</command></code> command.  On remote connections
				the SSH agent needs to be enabled with the command
				<code><command>eval</command>
				<option>$(</option><command>ssh-agent</command><option>)</option></code>.
			</para>
			<para id="wiki-alioth">
				In case of trouble getting SSH working it is a good idea to read
				<ulink url="http://wiki.debian.org/Alioth/SSH">this wiki article</ulink>.
			</para>
		</sect2>
		<sect2 id="svn-repository-structure">
			<title>Subversion repository structure</title>
			<para>The SVN repository is structured as follows:<programlisting>
debian-med/
 └ trunk/
    ├ community/
    │  ├ debtags/
    │  ├ infrastructure/
    │  └ website/
    └ packages/
       ├ &lt;package A&gt;/
       │  ├ branches/
       │  ├ tags/
       │  └ trunk/
       │     └ debian/
       ├ &lt;package B&gt;/
       │  ├ branches/
       │  ├ tags/
       │  └ trunk/
       │     └ debian/
       …</programlisting>
      </para>
			<note><para>We are currently considering an alternative layout in which all
			the <filename>trunk</filename>, <filename>tags</filename> and
			<filename>branches</filename> directories are grouped together, so that developers can checkout trunks without tags.</para></note>
		</sect2>
		<sect2 id="subversion-tips">
			<title>Subversion tips</title>
			<para id="svn-buildpackage-aliases">
				Suggested aliases for
				<command>svn-buildpackage</command>:<programlisting>
alias <command>svn-b</command>='svn-buildpackage -us -uc --svn-ignore'
alias <command>svn-br</command>='svn-b --svn-dont-purge --svn-reuse'
alias <command>svn-bt</command>='svn-buildpackage --svn-tag'</programlisting>
			</para>
			<para id="svn-mergewithupstream">
				<command>svn-inject <replaceable>-o</replaceable></command> sets up the
				<literal>mergeWithUpstream</literal> property for the SVN directories
				where packages are stored.  In case <command>svn-inject</command> was
				not used, you can do it by hand with the command
				<code><command>svn propset</command>
				<replaceable>mergeWithUpstream</replaceable>
				<replaceable>1</replaceable> <replaceable>debian</replaceable></code>.
			</para>
			<para id="download-upstream-source">
				To download the upstream sources (if there is a
				<filename>debian/watch</filename> file): <code><command>echo
				"origDir=.." &gt;&gt; .svn/deb-layout &amp;&amp; uscan
				--force-download</command></code>. Alternatively, you can try
				<code><command>debian/rules get-orig-source</command></code>.
			</para>
			<para id="svn-write-access">
				If you're a Debian developer or a member of the Debian Med group on
				Alioth, you can commit your changes: <command>svn commit</command> (also
				<command>svn ci</command>).  Otherwise, you can ask to be added to the
				group (see the <link linkend="membership">Membership</link> section), or
				send the result of <command>svn diff</command> to the <ulink
				url="mailto:debian-med@lists.debian.org">mailing list</ulink>
				(<command>gzip -9</command> it, if it's too large).
			</para>
			<para id="svn-tag-release">
				It may happen that a package version has been uploaded to Debian
				repositories, and you forgot to tag the last build with
				<command>svn-buildpackage --svn-tag</command>.  You can tag this package
				also retroactively.  A first step, creating
				the tags directory, can be achieved in two ways: either create it
				locally as sibling of <filename class="directory">trunk/</filename> with
				<code><command>svn mkdir</command> <filename class="directory">tags</filename></code>, and commit with
				<code><command>svn commit</command></code>, or create it remotely with
				<code><command>svn mkdir</command> <filename class="directory">svn+ssh://user@svn.debian.org/svn/debian-med/trunk/packages/&lt;package&gt;/tags</filename></code>.
				After the tags directory has been created, you're ready to tag the
				package: <code><command>svn-buildpackage</command> <option>--svn-tag-only</option> <option>--svn-no-autodch</option></code>.
				The <option>--svn-no-autodch</option> avoids
				<filename>debian/changelog</filename> to be marked as <literal>UNRELEASED</literal>.
			</para>
			<para id="example-svn-session">
				Here is an example session where a package is prepared manually:<programlisting>
# Check out debian-med/trunk, cd to debian-med/trunk/packages
# Create new project folder with
svn mkdir projectname
svn mkdir projectname/trunk

# Put orig.tar.gz in place
mv some_version.orig.tar.gz projectname

# Inform svn-buildpackage about the location of the orig.tar.gz
echo "origDir=.." > projectname/trunk/.svn/deb-layout

# Untar source tree for development
cd projectname
tar xzvf some_version.orig.tar.gz
cd some-version # entering the unpackaged source tree
if [ ! -d debian ]; then dh_make ; fi
mv debian ../trunk
ln -s ../trunk/debian .

# continue development
fakeroot ./debian/rules binary

# until it works, finally
cd ..

# debian directory is the only thing that is stored in svn, to be merged with upstream
svn propset mergeWithUpstream 1 trunk/debian

# See if things can be compiled via svn-buildpackage
cd trunk
svn-buildpackage -uc -us

# check build
lintian ../build-area/*changes</programlisting>
			</para>
		</sect2>
		<sect2 id="git-repository-structures">
			<title>Common Git repository structures</title>
			<para>
				The area on Alioth that contains the Git repositories (<filename
				class="directory">/git/debian-med</filename>) is not itself structured,
				but the repositories can be arranged in different possible layouts.
			</para>
			<sect3 id="git-buildpackage">
				<title><command>git-buildpackage</command></title>
				<para>
					Most of our packages using Git and stored in Alioth are managed with
					the <command>git-buildpackage</command> helper.  The
					<literal>master</literal> branch contains the full source package. 
					The <literal>upstream</literal> branch contains the upstream source, 
					after repacking when necessary (non-free files, large convenience code
					copies, …). The <literal>pristine-tar</literal> contains the data
					necessary to recreate an original tarball from the repository with a
					reproducible checksum.
				</para>
				<para>
					Debian releases are tagged with names like
					<literal>debian/debianversion</literal> and upstream releases are
					tagged with names like <literal>upstream/upstreamversion</literal>.
				</para>
			</sect3>
			<sect3 id="git-without-tarball">
				<title>Social Git</title>
				<para>
				  For some projects, like the ones hosted on <ulink
				  url="http://www.github.com">GitHub</ulink> or <ulink
				  url="http://www.gitorious.com">Gitorious</ulink>, it may be easier to
				  forward changes made in the Debian package if this one is itself
				  hosted on the same platform, as a clone. In that case, the layouts
				  may vary from package to packages.  However, there are good chances
				  that the branch that contains the Debian source package is called
				  <literal>debian</literal>.
				 </para>
			</sect3>
		</sect2>
		
		<sect2 id="git-tips">
			<title>Git tips</title>
			<para id="new-repository-with-gbp">
				Example to create a new git repository for a package where the upstream
				sources are distributed as file archives (tar, zip, …):<programlisting>
<command>mkdir</command> <filename class="directory">package</filename>
<command>cd</command> <filename class="directory">package</filename>
<command>git init</command>
<command>git import-orig</command> <option>--pristine-tar</option> <filename>/path/to/package_version.orig.tar.gz</filename>
<command>dh_make</command> <option>-p package_x.y.z</option></programlisting>
				The above steps will create a repository with the appropriate layout for
				<command>git-buildpackage</command>, with three branches:
				<literal>master</literal> (where the Debian development will happen),
				<literal>pristine-tar</literal> used by the
				<literal>pristine-tar</literal> tool during the package build process to
				recreate the original tarball, and <literal>upstream</literal>, which
				will contain the upstream source.
			</para>
			<para id="debcheckout-sets-git-options">
				To display your name and more nicely in the Git log, you should instruct
				Git to do so (the <option>--global</option> option is to say Git these
				are the default parameters for every Git repository you commit to,
				without it the settings will be per-repository only):<programlisting>
<command>git config</command> <option><optional>--global</optional></option> <option>user.name "$DEBFULLNAME"</option>
<command>git config</command> <option><optional>--global</optional></option> <option>user.email "$DEBEMAIL"</option></programlisting>
			</para>
			<para id="debcheckout-git-track">
				To clone and follow every branch of a git repository containing a
				package that is already in the Debian archive, you can use the
				<command>debcheckout</command> command with its
				<command><option>--git-track='*'</option></command> option. To restrict
				the tracked branch to the standard ones used by
				<command>git-buildpackage</command>, <literal>master upstream
				pristine-tar</literal> can be passed instead of the wildcard.
			</para>
			<para id="git-track-new-branches">
				Example commands to track new branches: <programlisting>
<command>git branch</command> <option>-t <replaceable>upstream</replaceable> <replaceable>origin/upstream</replaceable></option>
<command>git branch</command> <option>-t <replaceable>pristine-tar</replaceable> <replaceable>origin/pristine-tar</replaceable></option></programlisting>
  		</para>
			<para id="git-options-devscripts">
				If the <package>devscripts</package> variables
				<varname>DEBEMAIL</varname> and <varname>DEBFULLNAME</varname> are set,
				<command>debcheckout</command> will set <command>git</command>'s options
				<varname>user.email</varname> and <varname>user.name</varname>
				accordingly.
			</para>
			<para id="git-add-alioth-branch">
				To push changes to Alioth, a remote branch needs to be configured.  This
				is done automatically after cloning a repository, for instance with
				<link linkend="debcheckout-git-track">debcheckout</link>.  The default
				remote branch is called <quote>origin</quote>.  Here are example
				commands to set up Alioth as a remote branch on a freshly created
				repository:<programlisting>
<command>git remote add</command> <literal>origin</literal> <filename class="directory">git+ssh://git.debian.org/git/debian-med/package.git</filename></programlisting>
			</para>
			<para id="create-git-repository-on-alioth">
				There is a small script called <command>setup-repository</command> in
				the	<filename class="directory">/git/debian-med</filename> directory on
				Alioth. <code><command>./setup-repository</command>
				<option>packagename</option> <option>"Description of the
				package"</option></code> will create a <filename
				class="directory">packagename.git</filename> repository on with the
				proper hooks set up for our team.
			</para>
			<para id="push-package-to-alioth">
				To push the package (make sure you've added the alioth remote!), do the
				following:<code><command>git push</command> <option>origin
				master</option></code>.  For the first push, it's necessary to specify
				<option>origin master</option>. The next time you will push, a
				<command>git push</command> will suffice.
			</para>
			<para id="git-push-all-tags">
				<command>git push</command>this will only push the
				<literal>master</literal> branch unless it is somehow related to other
				branches), so be sure to also do a run with <option>--all</option>, and one with <option>--tags</option> if you created new tags.
			</para>
			<para id="git-tag-release">
				To tag a release:
				<code><command>git tag</command> <option>debian/x.y-z</option></code>.
				You can also easily retroactively make tags:
				<code><command>git tag</command> <option>debian/x.y-z</option> <option>&lt;commit hash&gt;</option></code>.
				Remember to <code><command>git push --tags</command></code>.
			</para>
			<para id="git-layout-variants">
				In particular for Git repositories that are not stored in Alioth, the
				layout can differ from <command>git-buildpackage</command> conventions.
				In that case, look for instance for a branch called <literal>debian</literal>.
			</para>
			<para id="git-debian-version-from-commit">
				If upstream manages his sources with Git, the following makefile
				script can help producing a version number when no Git tag is
				available:<programlisting>
SOURCEPKG=$(shell dpkg-parsechangelog | sed  -n 's/^Source: \(.*\)/\1/p')
UPSTREAM=$(shell dpkg-parsechangelog |  sed -n 's/^Version: \(.*\)-[^-]*/\1/p')
SHA1=$(lastword $(subst ~g, ,$(UPSTREAM)))
ORIG=${SOURCEPKG}_${UPSTREAM}.orig.tar.gz

describe-current-version:
	git describe --tags upstream | sed 's,^release-,,;s,-,+,;s,-,~,;'

get-orig-source:
	git archive --format=tar $(SHA1) | gzip -9 > ../$(ORIG)</programlisting>
			</para>
			<para>
				To make <command>git-buildpackage</command> builds the package with a
				chroot, you can add the following to the configuration file <filename>~/.gbp.conf</filename> or <filename>debian/gbp.conf</filename>:<programlisting>
[DEFAULT]
builder = ~/bin/git-pbuilder
cleaner = fakeroot debian/rules clean
pristine-tar = True

[git-buildpackage]
# use this for more svn-buildpackage like behaviour:
export-dir = ../build-area/
tarball-dir = ../tarballs/</programlisting>
				With this configuration file you're specifying that
				<command>git-buildpackage</command> will use
				<filename>~/bin/git-pbuilder</filename> as the builder script.  This is
				an example script you can use:<programlisting>
#!/bin/sh
set -e

pdebuild --pbuilder cowbuilder --debbuildopts "-i\.git -I.git $*"
rm ../*_source.changes</programlisting>
				This will build the package inside the default cowbuilder chroot, while
				passing any more parameters directly do	 <command>dpkg-buildpackage</command>.
			</para>
		</sect2>
		
		<sect2 id="subversion-to-git">
		  <title>Migration of a source package from Subversion to Git.</title>
		  <para>
		    For packages were we set the <literal>mergeWithUpstream</literal>
		    property, which excludes the upstream sources, there is no easy way to
		    prepare a Git repository from our Subversion repository that would look
		    like the package was always managed in Git. Nevertheless, the following
		    recipe will generate a Git repository that contains all the history of
		    the debian directory, plus a collection of selected upstream source
		    releases.
		  </para>
		    <itemizedlist>
		      <listitem>
		        <para>Start the conversion as explained in the <ulink url="http://wiki.debian.org/Alioth/Git#ConvertaSVNAliothrepositorytoGit">Alioth/Git</ulink> page of the Debian wiki. To be consistent with a later usage of <command>git-buildpackage</command>, it is preferable to prefix the tag names <quote>debian</quote>. During this conversion, you can take advantage of the file <filename>/trunk/community/infrastructure/comitters</filename> in the Subversion repository, and expand it if necessary.</para>
		      </listitem>
		      <listitem>
		        <para>Import of the upstream original tarballs that you find relevant, for instance the ones that were part of a stable release). When this paragraph was written, it was necessary to follow special instruction detailed in <ulink url="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=471560">bug 471560</ulink>.
			</para>
		      </listitem>
		      <listitem>
		        <para>Upload to git.debian.org/git/debian-med and set up the hooks and other meta-data as explained in the <ulink url="http://wiki.debian.org/Alioth/Git">Alioth/Git</ulink> page of the Debian wiki.
		      </para>
		      </listitem>
		      <listitem>
		        <para>Document in the Subversion repository that the package has been transferred elsewhere, for instance with a file named <filename>README.status</filename> containing the new VCS URL.</para>
		      </listitem>
		      <listitem>
		        <para>Delete the package in the Subversion repository after its VCS URL in Stable has been updated by the next release.</para>
		      </listitem>
		    </itemizedlist>
		      <para>It is also possible to prepare a Git repository containing some of the package's history using the command <command>git-import-dscs --debsnap</command> from the helper toolkit <command>git-buildpackage</command>. This will download all the versions of a package available in <ulink url="http://snapshot.debian.org">snapshots.debian.org</ulink> and create tags for each of them. Note that as this paragraph is written, the tool is not aware that <emphasis>backports</emphasis> should be a different branch</para>
		</sect2>
		<sect2 id="updating-git-package">
		  <title>Updating a source package managed with Git</title>
		  <para>Most source packages maintained as Git repositories in Debian Med are using the <command>git-buildpackage</command> helper toolkit. In doubt, try this one first.</para>
		  <para><command>git-buildpackage</command>'s command <command>git-import-orig</command> allows very easy update of the <emphasis>upstream</emphasis> branch when the original sources are distributed as a compressed archive. Its option <command>--pristine-tar</command> is useful for stabilizing the MD5 sum of the “<filename>orig.tar.gz</filename>” produced when building a source package from the repository alone (not doing so results in archive rejection of package updates). With recent versions of git-buildpackage, it is often unnecessary to rename the freshly downloaded original upstream archive.</para>
		</sect2>
	</sect1>
	<sect1 id="packaging">
		<title>Packaging</title>
		<sect2 id="itp">
			<title>Announcing intent to package</title>
			<para>If you intent to work on a Debian package you should follow
			the <ulink url="http://www.debian.org/devel/wnpp/#l1">normal Debian rules</ulink> and file a <acronym>WNPP</acronym> bug report.</para>
			<para>It is a good idea to keep the Debian Med mailing list
			<ulink url="mailto:debian-med@lists.debian.org">debian-med@lists.debian.org</ulink>
			<ulink url="http://www.debian.org/Bugs/Reporting#xcc"> in CC</ulink> and to set it
			as the owner of the ITP	to keep your co-workers informed. This will ensure that we notice
			if for some reason the package has not been uploaded.</para>
			<para>In addition, please add the package to the <quote>task</quote> file where it fits
			the best, and document your ITP number using the <command>WNPP</command> field name.</para>
		</sect2>
		<sect2 id="backports">
			<title>Backports</title>
			<para>
				Debian offers <ulink url="http://backports.debian.org">backports</ulink> to its stable version.  Backports of Debian Med packages should be kept as branches in our <link linkend="svn-repository-structure">Subversion</link> or <link linkend="git-repository-structures">Git</link> repositories.
			</para>
		</sect2>
		<sect2 id="ppa">
			<title>PPA for Ubuntu</title>
			<para>
				Debian Med operates a <ulink url="https://launchpad.net/~debian-med/+archive/ppa">Personal Package Archive</ulink> (PPA) on Launchpad, where packages are backported for Ubuntu.  There is currently no team policy on what to build.
			</para>
			<para>
				Please keep in mind issues like the possibility to upgrade to the next Ubuntu stable release.  Packages that are backports can be made <ulink url="http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version">inferior in version by using a tilde</ulink>.  If the package contains additional development, a version number without the tilde will make it higher, but not as high as the next Debian revision.  For example: <code>2.12.0-1~natty1</code> (backport in PPA) &lt; <code>2.12.0-1</code> (from Debian in Ubuntu) &lt; <code>2.12.0-1natty1</code> (in PPA, containing additions) &lt; <code>2.12.0-2</code> (from Debian in Ubuntu).
			</para>
			<para>
				Packages sent to this PPA may be kept as branches in our repositories.
			</para>
		</sect2>
		<sect2 id="r-packages">
			<title>R packages</title>
			<para>
				<ulink url="http://packages.debian.org/r-base">GNU R</ulink> sometimes introduces backward incompatibilities, so the current practice is to make packages depend on versions equal or higher to the one against which they were built.  When using <code>r-dev</code>, this can be acheived by adding the following command in <filename>debian/rules</filename>.  Note the tilde, that ensures that pre-releases can be used as well.
			</para>
			<programlisting>install/r-$(debRreposname)-$(cranName)::
	echo "R:Depends=r-base-core (&gt;= $(shell R --version | head -n1 | perl -ne 'print / +([0-9]\.[0-9]+\.[0-9])/')~)" &gt;&gt; debian/r-$(debRreposname)-$(cranName).substvars</programlisting>
		</sect2>
	</sect1>
	<sect1 id="tasks">
		<title>Tasks</title>
		<para>The Debian Med <ulink url="http://blends.alioth.debian.org/blends">Debian Pure Blend</ulink> is organised by <ulink url="http://debian-med.alioth.debian.org/tasks/index">tasks</ulink>, that group packages around broad themes such as <ulink url="http://debian-med.alioth.debian.org/tasks/imaging">medical imaging</ulink> for instance. The tasks list programs that are already packaged in Debian as well as packages in preparation.</para>
		<para>The tasks files are not hosted in the Debian Med repositories, but in the Debian Blends repository. Nevertheless, all members of the Debian Med project on the Alioth forge have write access to the Blends subversion repository. You can easily check out its sources with the command <command>debcheckout -a debian-med</command>.</para>
		<para>The syntax of the tasks files is very similar to Debian control files, and described in the <ulink url="http://blends.alioth.debian.org/blends/ch-sentinel.en.html">Debian Blends website</ulink>.</para>
	</sect1>
	<sect1 id="policy">
		<title>Policy</title>
		<sect2 id="debian-control">
			<title><filename>debian/control</filename></title>
			<orderedlist>
				<listitem>
				<formalpara>
					<title>Section</title>
					<para>Should be <quote>science</quote> for the source package.</para>
				</formalpara>
				</listitem>
				
				<listitem>
				<formalpara>
					<title>Priority</title>
					<para>Should be <quote>optional</quote> unless forbidden by the Debian policy (<ulink url="http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities">see §2.5</ulink>). Packages of priority <quote>extra</quote> are excluded from some QA tests.</para>
				</formalpara>
				</listitem>
				
				<listitem>
				<formalpara>
					<title>Maintainer</title>
					<para>Maintainer should be <code>Debian Med Packaging Team <email>debian-med-packaging@lists.alioth.debian.org</email></code>. Please subscribe to this list if you list yourself in the <code>Uploaders:</code> field of one of Debian Med's packages. You can refer to the <ulink url="http://qa.debian.org/developer.php?login=debian-med-packaging@lists.alioth.debian.org">QA page</ulink> corresponding to this email to gather information about the packages.</para>
				</formalpara>
				</listitem>
				
				<listitem>
				<formalpara>
					<title>Upload by Debian Maintainers</title>
					<para>Should be enabled with the field <code>DM-Upload-Allowed: yes</code>. This means that when an Uploader becomes Debian Maintainer, he will immediately get the possibility to upload the package to Debian. Please consider this when you sponsor packages in which some Uploaders are added.</para>
				</formalpara>
				</listitem>
				
				<listitem>
				<formalpara>
					<title>Uploaders</title>
					<para>Please add yourself as an uploader when you have a significant interest in a package. Being Uploader means that you are expected to answer to the bug reports. For more occasional works, you can do a <ulink url="http://www.debian.org/doc/developers-reference/pkgs#nmu-team-upload">team upload</ulink>.
					</para>
				</formalpara>
				</listitem>
				
				<listitem>
				<formalpara>
					<title>Standards-Version</title>
					<para>Please always use the latest unless there are concerns for backporting. If no changes are needed, please indicate this fact in the changelog, and increment the value of the field.</para>
				</formalpara>
				</listitem>
				
				<listitem>
				<formalpara>
					<title>Homepage</title>
					<para>should be documented whenever possible</para>
				</formalpara>
				</listitem>
				
				<listitem>
				<formalpara>
					<title>Vcs-Svn: and Vcs-Browser:</title>
					<para>Please use the following templates:
					<programlisting>
Vcs-Svn: svn://svn.debian.org/debian-med/trunk/packages/&lt;package&gt;/trunk/
Vcs-Browser: http://svn.debian.org/wsvn/debian-med/trunk/packages/&lt;package&gt;/trunk/
					</programlisting>or
					<programlisting>
Vcs-Git: git://git.debian.org/debian-med/&lt;package&gt;.git
Vcs-Browser: http://git.debian.org/?p=debian-med/&lt;package&gt;.git
					</programlisting>
					</para>
				</formalpara>
				</listitem>
			</orderedlist>
		</sect2>
		
		<sect2 id="debian-copyright">
			<title><filename>debian/copyright</filename></title>
			<para>
				We use the <ulink url="http://dep.debian.net/deps/dep5/">proposed machine-readable format</ulink> for the <filename>debian/copyright</filename> file. The <computeroutput>Source</computeroutput> field does not need to contain the full URL to the particular version that is being packaged, since this can be determined by the <command>uscan</command> program with the <filename>debian/watch</filename> file. Please list yourself in the <computeroutput>Files: debian/*</computeroutput> section if you think that your contributions are not trivial and therefore subjected to copyright. Please chose a license that is compatible with the program you package. You can also use <quote>same as if it were in the public domain</quote> or <quote>same as the packaged program itself</quote>. 
			</para>
			<para>
				To verify the correct syntax of the <filename>debian/copyright</filename> file you can use: <command>config-edit</command> <option>-application <replaceable>dpkg-copyright</replaceable></option> <option>-ui <replaceable>none</replaceable></option>.
			</para>
		</sect2>
		
		<sect2 id="debian-changelog">
			<title><filename>debian/changelog</filename></title>
			<para>Packages hosted in our Subversion repository, that have been modified but not uploaded must use <literal>UNRELEASED</literal> as a distribution name. This can be done automatically by declaring <literal><varname>DEBCHANGE_RELEASE_HEURISTIC</varname>=<replaceable>changelog</replaceable></literal> in <filename>~/.devscripts</filename> and using <command>dch</command>.</para>
		</sect2>
		
		<sect2 id="debian-gbp.conf">
		  <title><filename>debian/gbp.conf</filename></title>
			<para>
			  Packages managed with <command>git-buildpackage</command> may mark this
			  by including a <filename>debian/gbp.conf</filename> configuration
			  file.  The following recommended values will make
			  <command>pristine-tar</command> used by default, and otherwise set a
			  directory layout similar to the one we use with
			  <command>svn-buildpackage</command>.<programlisting>
[DEFAULT]
pristine-tar = True

[git-buildpackage]
# use this for more svn-buildpackage like behaviour:
export-dir = ../build-area/
tarball-dir = ../tarballs/</programlisting>
			</para>
		</sect2>
		
		<sect2 id="debian-readme-source">
			<title><filename>debian/README.source</filename></title>
			<para>This file is recommended by the Policy (<ulink url="http://www.debian.org/doc/debian-policy/ch-source.html#s-readmesource">§ 4.14</ulink>) from version 3.8.0 for documenting source package handling. Please follow the recommendation. For instance, this file is needed when we use a patch system, when the upstream sources are in another format than gzipped tar archive, when we repack the sources,…</para>
		</sect2>
				
		<sect2 id="debian-readme-test">
			<title><filename>debian/README.test</filename></title>
			<para>This file was (<ulink url="http://lists.debian.org/debian-devel-announce/2011/01/msg00006.html">recommended by the Security team</ulink>) for describing to others than the regular maintainer how the package's functionality can properly be tested.</para>
		</sect2>
		
		<sect2 id="debhelper">
			<title>Debhelper</title>
			<para>Debhelper uses compatibility levels to control the behaviour of its commands.  We currently recommend to use the level <emphasis>8</emphasis> which
			is available in current <emphasis>Stable</emphasis> (Squeeze) and backported to <emphasis>Oldstable</emphasis>.  However, there is no urgent need to
			touch packages only because it has an older Debhelper version.</para>
			<para>
			It is strongly recommended to use the short <emphasis>dh</emphasis> notation in <filename>debian/rules</filename> files which makes code factorisation very
			simple and easy to understand the packaging for other members of the team.  Even complex packaging becomes quite transparent this way.
			</para>
		</sect2>
		
		<sect2 id="cdbs">
			<title>CDBS</title>
			<para>Before the short <emphasis>dh</emphasis> notation of debhelper existed CDBS was the only way to factorise code in <filename>debian/rules</filename> files.
			So it was recommended in the past but it turned out that CDBS is badly documented and recently introduced incompatible changes.  So it is sometimes reasonable
			to switch from CDBS to <emphasis>dh</emphasis> if some problems in the packaging might occure.</para>
			<para>It is technically possible to build CDBS packages using Debhelper without the <filename>debian/compat</filename> file. Please do not, and always include such a file according to the above guidelines.</para>
		</sect2>
		
		<sect2 id="vcs">
			<title>Version control systems</title>
			<para>
				We are currently using two different version control systems, Subversion and Git.
			</para>
			<sect3 id="vcs-svn">
				<title>Source package stored in a Subversion repository</title>
				<para>
					We often use the <literal>mergeWithUpstream</literal> workflow. In
					that case, please keep all the modifications in the <filename
					class="directory">debian</filename> directory, and use the
					<option>-o</option> option of <command>svn-buildpackage</command>, as
					in the following example: <code><command>svn-inject</command>
					<option>-o</option> <filename>package.dsc</filename> <filename
					class="directory">svn+ssh://svn.debian.org/svn/debian-med/trunk/packages/</filename></code>.
				</para>
			</sect3>
			<sect3 id="vcs-git">
				<title>Source package stored in a Git repository</title>
				<para>
					Git repositories should be stored in the <filename
					class="directory">/git/debian-med</filename> directory on Alioth and
					created with the <link
					linkend="create-git-repository-on-alioth"><command>setup-repository</command></link>
					script available there.  There, they must give write access to the
					<literal>debian-med</literal> Alioth group and all the Debian
					Developers, with appropriate Unix permissions (including SGID bit on
					directories) and ACLs.  See <filename class="directory">/git/debian-med</filename>
					itself as an example.  <command>setup-repository</command> does this
					automatically.
				</para>
				<para>
					Git repositories managed with a helper tool should announce it.  For
					instance, to show that <command>git-buildpackage</command> is used,
					the package can contain a configuration file in
					<filename>debian/gbp.conf</filename>.
				</para>
			</sect3>
			<sect3 id="vcs-tags">
				<title>Tags</title>
				<para>
					Tags indicate the revision corresponding to uploaded packages. For
					Subversion, the version number is used, and for Git,
					<literal>debian/</literal> is added before the version number.  In the
					Subversion repository, older tags may be deleted to save space.
				</para>
			</sect3>
		</sect2>
		<sect2 id="new-package">
			<title>New package</title>
			<para>
				Try to inject a new package only after successfully building it with
				<command>dpkg-buildpackage</command> (or any wrapper around it).  Use a
				file like <filename>debian/DRAFT</filename> to mention when the package
				is a draft.
			</para>
		</sect2>
		<sect2 id="new-packages-in-tasks">
			<title>The Debian Med Blend tasks</title>
			<para>
				Once you injected a new package please make sure that it is mentioned
				in the appropriate <link linkend="tasks">tasks</link> file in the SVN
				source of the <package>debian-med</package> Blend package.  Some team
				members watch the changes in the Debian Med packaging pool but it helps
				if the maintainer of a new package verifies that everything is in the
				right place.
			</para>
		</sect2>
		<sect2 id="building-and-tagging">
			<title>Building and tagging the packages</title>
			<para>
				We prefer that uploaded packages are built in a chroot, to provide
				similar build environment to the whole team.  After upload, please <link linkend="vcs-tags">tag</link>
				the <link linkend="svn-tag-release">Suvbersion</link> or <link linkend="git-tag-release">Git</link> repository.
			</para>
		</sect2>
		<sect2 id="patches">
			<title>Handling patches</title>
			<para>
				Often happens that the upstream code doesn't fit well into the
				Debian distribution: be this wrong paths, missing features, anything
				that implies editing the source files.  When you directly edit
				upstream's source files, your changes will be put into a .diff.gz file
				if you use the <literal>1.0</literal> source format and in a monolithic
				patch if you use the <literal>3.0 (quilt)</literal> format.  To better
				organise the patches and group the by function, please use a patch
				handling system	which keeps patches under the <filename
				class="directory">debian/patches</filename> directory.
			</para>
			<para>
				The <literal>3.0 (quilt)</literal> Dpkg source format provides its own
				patch system.  Apart from this, the most popular is
				<command>quilt</command>.  <emphasis>simple-patchsys</emphasis>, from
				the <package>CDBS</package> package, is deprecated since version
				<literal>0.4.85</literal>.  <command>dpatch</command> has been popular
				as well, but is not compatible with the <literal>3.0 (quilt)</literal>
				source format and is <ulink	url="http://lists.debian.org/878vqt6was.fsf@luthien.mhp">
				planned to be removed	2017</ulink>.  Please don't use any other patch
				system in Debian Med,	unless absolutely necessary.
			</para>
			<sect3 id="quilt">
				<title>Using <command>quilt</command></title>
				<para>Using quilt is rather easy.</para>
				<para>First, make sure you have correctly setup quilt: open
				<filename>.quiltrc</filename> in your home directory (create
				it if you don't have one), and make sure it looks like this:</para>
				<blockquote>
					<programlisting>QUILT_DIFF_ARGS="--no-timestamps --no-index"
QUILT_REFRESH_ARGS="--no-timestamps --no-index"
QUILT_PATCHES="debian/patches"</programlisting>
				</blockquote>
				<para>After this, you're ready to start working with quilt.</para>
				<sect4 id="quilt-create">
					<title>Creating a patch</title>
					<para>To create a patch, use the <command>new</command> command.
					Run:</para>
					<blockquote>
						<para><userinput>
							<command>quilt new</command> <filename>&lt;patch_name&gt;.patch</filename>
						</userinput></para>
					</blockquote>
					<para>This will create (if it doesn't exist yet) a
					<filename>debian/patches/series</filename> file, which
					contains all the patches to be applied by quilt. Moreover,
					the new patch is also the topmost (the currently
					applied).</para>
					<para>Now start editing files, with:</para>
					<blockquote>
						<para><userinput>
							<command>quilt edit</command> <filename>&lt;file&gt;</filename>
						</userinput></para>
					</blockquote>
					<para>and repeat the process for each file the patch is
					involved with. At the end, run</para>
					<blockquote>
						<para><userinput>
							<command>quilt refresh</command>
						</userinput></para>
					</blockquote>
					<para>This will compare the noted state of the edited files
					with the current state, and will produce a patch in
					<filename>debian/patches</filename>. Remember: the patch
					is currently applied (you can check this with
					<command>quilt applied</command>).</para>
				</sect4>
				<sect4 id="quilt-apply">
					<title>Applying and unapplying patches</title>
					<para>Just two easy commands to do the job:</para>
					<itemizedlist>
						<listitem><para><command>quilt pop</command> will unapply the topmost patch.</para></listitem>
						<listitem><para><command>quilt push</command> will apply the next patch in debian/patches/series.</para></listitem>
					</itemizedlist>
					<para>You can just add a "-a" flag to the commands above, to
					respectively apply/unapply all patches in the series.</para>
					<tip>
						<para>You can check which patches are applied/unapplied
						with, respectively, <command>quilt applied</command> and
						<command>quilt unapplied</command>.</para>
					</tip>
				</sect4>
				<sect4 id="quilt-edit">
					<title>Editing patches</title>
					<para>To edit a patch, first make it the topmost:</para>
					<blockquote>
						<para><userinput>
							<command>quilt push</command> <filename>&lt;patch_name&gt;</filename>
						</userinput></para>
					</blockquote>
					<para>If the patch is already applied, but is not the topmost,
					run <command>quilt pop</command> until it becomes the currently
					applied one.</para>
					<para>You can now run <command>quilt edit</command> on the files
					you want to change, and, when you're done, <command>quilt
					refresh</command>.</para>
				</sect4>
				<sect4 id="quilt-rename">
					<title>Renaming patches</title>
					<para>Sometimes it's useful to rename a patch. Without
					any hassle, do:</para>
					<blockquote>
						<para><userinput>
							<command>quilt rename -P</command> <filename>&lt;old_name&gt;.patch</filename>
							<filename>&lt;new_name&gt;.patch</filename>
						</userinput></para>
					</blockquote>
				</sect4>
				<sect4 id="quilt-other">
					<title>Other commands</title>
					<para>Please see <command>man 1 quilt</command> to have a
					comprehensive list of commands.</para>
				</sect4>
				<sect4 id="quilt-integration">
					<title>Integration in the build process</title>
					<para>Add in the very first part of <filename>debian/rules</filename>
					(i.e. before the targets), the line:</para>
					<blockquote>
						<programlisting>include <filename class="headerfile">/usr/share/quilt/quilt.make</filename></programlisting>
					</blockquote>
					<para>Please use this to import patch and unpatch rules instead of writing them, and remember to add the needed dependencies to its
					targets:</para>
					<blockquote>
						<programlisting>...
build: patch build-stamp
build-stamp: configure
...</programlisting>
					</blockquote>
					<para>This kind of dependency will ensure that if you also
					patch the build system, you get a working patched build
					process.</para>
					<caution>
						<para>Don't also put configure as a dependency of
						build (leave it in build-stamp): that may cause problems
						during parallel buildings (i.e. the -j flag of make).</para>
					</caution>
					<para>Now add a dependency to the clean target:</para>
					<blockquote>
						<programlisting>...
clean: unpatch
...</programlisting>
					</blockquote>
					<para>If you've also patched the build system, using upstream's
					clean target might fail. This is what you should do:</para>
					<blockquote>
						<programlisting>...
clean: clean-patched unpatch
clean-patched:
...</programlisting>
					</blockquote>
					<para>Obviously, you could always use an approach like this,
					but it's an useless complication if you don't patch the build
					system, and you should keep <filename>debian/rules</filename>
					the simplest you can.</para>
				</sect4>
			</sect3>
			<sect3 id="dpatch">
				<title>Using <command>dpatch</command></title>
				<para>
					<emphasis>Removal of <command>dpatch</command> is <ulink
					url="http://lists.debian.org/878vqt6was.fsf@luthien.mhp"> planned for
					2017</ulink>.  The commands below are for reference, but the use of
					<command>dpatch</command> in Debian Med is discouraged.  The quilt
					package contains a conversion script,
					<filename>/usr/share/doc/quilt/examples/dpatch2quilt.sh</filename>.</emphasis>
				</para>
				<itemizedlist>
				  <listitem id="dpatch-create-patch">
						<para>Creating a patch: <command>dpatch-edit-patch</command></para>
					</listitem>
					<listitem id="dpatch-apply-unapply">
						<para>Applying and unapplying patches: <command>apply(-all), unapply(-all), status</command></para>
					</listitem>
					<listitem id="dpatch-edit-patch">
						<para>Editing patches: <command>dpatch-edit-patch</command></para>
					</listitem>
					<listitem id="dpatch-rename-patch">
						<para>Renaming patches: is this possible?</para>
					</listitem>
					<listitem id="dpatch-other">
						<para>Other commands: please see <command>man 1 dpatch</command> for a	comprehensive list of commands.</para>
					</listitem>
					<listitem  id="dpatch-integration">
						<para>Integration in the build process: follow the instructions for quilt and adapt the path of inclusion to <filename class="headerfile">/usr/share/dpatch/dpatch.make</filename></para>
					</listitem>
				</itemizedlist>
			</sect3>
		</sect2>
	</sect1>
</article>
