Building the Debian Perl package
================================

Build Options
-------------

In addition to the ``nostrip'' and ``noopt'' DEB_BUILD_OPTIONS
required by policy (10.1) the build process also recognises the
following perl-specific options:

  x-perl-shared
  x-perl-static
    Select whether /usr/bin/perl is linked to the shared or static
    perl library.  By default the link type is shared on all
    architectures other than i386 (where the relocations incur a
    measurable performance penalty).

  x-perl-notest (or nocheck)
    The regression test suite is normally run after each of the static
    and shared build phases.  It is occaisionally useful to supress
    these tests (when debugging the build process for example, or to
    allow porters to work around known build chain or kernel bugs).

Patches Applied
----------------

A copy of all patches which have been applied to the source are in the
debian/patches directory of the Debian source package.

There are two classes of patches in the directory: debian/patches/fixes/* are
generally applicable to any Perl installation (and usually back-ported
from upstream, or posted to p5p when applied).

Patches in debian/patches/debian implement changes which are specific to
the Debian packaging, such as our @INC ordering or specific to policy
such as not including standard directories in LD_RUN_PATH.

Packaging Details
-----------------

The Debian build process consists of the following components:

  debian/rules
    makefile which drives the build process as usual with Debian
    packages.  This process is slightly more complex than normal to
    simplify bootstrapping a new port--using only basic shell utils, and
    perl (once built, as perl.static).  To bootstrap a new architecture,
    use:

      DEB_HOST_GNU_TYPE=<arch> debian/rules binary-arch

  debian/config.debian 
    a helper script, invoked by debian/rules to run Configure with
    various options.

  debian/config.over
    used to fiddle some config.sh variables (copied to the source
    directory by the build process where it is picked up by Configure).

  debian/patches
    directory containg the patches applied (see above).  These are maintained
    with git-dpm, but if a standalone way to add a new patch is needed 
    (for instance when NMUing), the recommended way is to use quilt(1).
    Using DEP-3 compatible headers for the patch will improve its description
    in `perl -V' output.

      quilt new debian/myfix
      quilt add <file>
      [ hack <file> ]
      echo 'patch description (Closes: #xxxxxx)' | quilt header -a
      # (or even better provide a full DEP-3 compatible header)
      quilt refresh

  debian/released-versions
    contains a list of released Debian versions, used by the
    debian/mkprovides script to generate a list of perlapi-<ver>
    provides for perl-base indicating the released versions the package
    is compatible with.

  debian/headers
    list of C headers to process with h2ph, which is run with "-a" to
    pick up any required includes--keep this base list as short as
    possible.

  debian/*.{files{,.static,.shared},docs}
    used to split packages; see the comments/code in the install-stamp
    target of debian/rules.

Managing debian/patches with git-dpm 
------------------------------------

This section is targeted at the Debian package maintainers, working with
the Git repository pointed by the Vcs-Git field in debian/control.  NMUers
and the like can use the old way of standalone patch handling described
above, or just hack the source and ignore debian/patches altogether.

First, you need to be running wheezy or later, and have the 'git-dpm'
package installed.

Any upstream modifications need to be done on a special 'patched' branch
that is created with 'git-dpm checkout-patched'. Every commit on this branch
corresponds to one patch in debian/patches. The commits can be handled
with normal git tools like 'git rebase -i'.

When everything is ready, 'git-dpm update-patches' will merge the work into
the master branch with the debian/ directory and remove the 'patched' branch,
which is not supposed to be pushed to the shared repository.

See the git-dpm(1) manual page for more information.

Importing new upstream releases
-------------------------------

Since we use git-dpm to manage patches, that tools is implicitly part of
the process of importing a new upstream version. Since we started using
components (the metaconfig tarball described below) we also need to
take some special steps here, examples of which are described below:

git-dpm import-tar -p upstream-debian-5.28 ../perl_5.28.0.orig.tar.xz
git log|head -1|cut -f2 -d\
[note down the commit]
git checkout debian-5.28
git-dpm import-new-upstream --component ../perl_5.28.0.orig-regen-configure.tar.xz -p [commit hash from above] ../perl_5.28.0.orig.tar.xz
git-dpm rebase-patched

Package maintainer tests
------------------------

There are package maintainer tests in the debian/t/ directory that
are supposed to pass at all times. It is recommended that you add
a git pre-commit hook (.git/hooks/pre-commit) that runs the tests
before releasing, for instance:

#!/bin/sh

if [ -e debian/changelog ] && \
   git diff --cached debian/changelog | grep -q '^-.*UNRELEASED' && \
   git diff --cached debian/changelog | grep -q '^\+.*unstable'
then
    prove debian/t/*.t
fi

A special note on patching Configure
------------------------------------

The Configure and config_h.SH files are autogenerated upstream. The
tooling is based on the 'dist' suite, which (among other things) contains
a collection of probe units and a program called 'metaconfig' that makes
the Configure script. Since 5.26.1-1, the perl source package contains
a fork of these 'dist' probe units along with a set of specialised ones
specific to the Perl Configure. These are in a separate original tarball
component ('perl-regen-configure').

The recommended way to change Configure is to edit these units in
regen-configure/U and run 'debian/rules update-configure' to regenerate
Configure.

(There is also some upstream machinery (mkgloss*, mksample) for
automatically updating Porting/config.sh and Porting/Glossary that is
not integrated to the Debian packaging. These only affect the source
code documentation, not functionality.)

Please see <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=762638>
for a discussion about this issue.

Regenerating the 'perl-regen-configure' original component tarball
------------------------------------------------------------------

This is a snapshot of the upstream git repository at
<https://github.com/perl5-metaconfig/metaconfig>, generated based on
information in debian/watch and debian/copyright (Files-Excluded).
It can be regenerated by running uscan(1), which uses mk-origtargz(1)
behind the scenes.

The initial packaging for 5.26.1 was based on upstream
commit d99ddb45cefcc4ae5fde1787cfbe18e1073f9f54, tagged
as debian/perl-5.26.1 in the above repository.

Credits
-------

Previous maintainers of Debian Perl packages:

  Ray Dassen <jdassen@WI.LeidenUniv.NL>,
  Carl Streeter <streeter@cae.wisc.edu>,
  Robert Sanders <Robert.Sanders@linux.org> and
  Darren Stalder <torin@daft.com>.

 -- Brendan O'Dea <bod@debian.org>  Tue,  8 Mar 2005 19:30:38 +1100

 -- Niko Tyni <ntyni@debian.org> Wed, 03 Feb 2010 14:47:51 +0200

