1 <?xml version='1.0' encoding='utf-8'?>
2 <!-- -*- DocBook -*- -->
3 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
5 <!ENTITY % versiondata SYSTEM "version.xml"> %versiondata;
9 <title>Debian Perl Policy</title>
15 <firstname>Raphaël</firstname><surname>Hertzog</surname>
20 <firstname>Brendan</firstname><surname>O'Dea</surname>
24 <othername>The Debian Policy Mailing List</othername>
25 <email>debian-policy@lists.debian.org</email>
29 <releaseinfo>version &version;</releaseinfo>
30 <pubdate>&date;</pubdate>
34 This document describes the packaging of Perl within the Debian
35 distribution and the policy requirements for packaged Perl
43 <holder>Raphaël Hertzog</holder>
44 <holder>Brendan O'Dea</holder>
48 These are the copyright dates of the original Debian Perl Policy.
49 Since then, this document has been updated by many others. No
50 comprehensive collection of copyright notices for subsequent work
54 This manual is free software; you may redistribute it and/or
55 modify it under the terms of the GNU General Public License as
56 published by the Free Software Foundation; either version 2 of the
57 License, or (at your option) any later version.
60 This is distributed in the hope that it will be useful, but
61 WITHOUT ANY WARRANTY; without even the implied warranty of
62 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
63 General Public License for more details.
66 A copy of the GNU General Public License is available as
67 <filename>/usr/share/common-licenses/GPL</filename> in the Debian
68 distribution or on the World Wide Web at <ulink
69 url="https://www.gnu.org/licenses/">https://www.gnu.org/licenses/</ulink>.
75 <title>About this document</title>
77 This document is distributed as the <literal>perl-policy</literal>
78 files in the Debian package <systemitem role="package"><ulink
79 url="https://packages.debian.org/debian-policy">debian-policy</ulink></systemitem>.
80 It is also available from the Debian web mirrors at <ulink
81 url="https://www.debian.org/doc/packaging-manuals/perl-policy/">https://www.debian.org/doc/packaging-manuals/perl-policy/</ulink>.
85 <chapter id="ch-perl">
86 <title>Perl Packaging</title>
88 <section id="s-versions">
89 <title>Versions</title>
92 At any given time, the package <systemitem
93 role="package">perl</systemitem> should represent the current
94 stable upstream version of Perl revision 5 (see <xref
95 linkend="ap-perl6"/>).
98 Only one package may contain the
99 <filename>/usr/bin/perl</filename> binary and that package must
100 either be <systemitem role="package">perl</systemitem> or a
101 dependency of that package (see <xref linkend="s-base"/>).
104 Where possible, Perl should be compiled to provide binary
105 compatibility to at least the last released package version to
106 allow a grace period over which binary module packages may be
107 re-built against the new package (see <xref
108 linkend="s-binary-modules"/>).
111 The <systemitem role="package">perl-base</systemitem> package must
113 role="package">perlapi-<replaceable>abiname</replaceable></systemitem>
114 for all released package versions it is compatible with. The
115 choice of <replaceable>abiname</replaceable> is arbitrary, but if
117 <literal>$Config{version}</literal><footnote><para> see the
118 <literal>Config</literal> module </para> </footnote>, it must be
119 specified in <literal>$Config{debian_abi}</literal>.
123 <section id="s-base">
124 <title>Base Package</title>
127 In order to provide a minimal installation of Perl for use by
128 applications without requiring the whole of Perl to be installed,
129 the <systemitem role="package">perl-base</systemitem> package
130 contains the binary and a basic set of modules.
133 As Perl has been part of the essential set for some time and is
134 used without dependencies by such things as package maintainer
135 scripts, <systemitem role="package">perl-base</systemitem> must be
136 priority <emphasis>required</emphasis> and marked as
137 <emphasis>essential</emphasis>.
140 Note that the <systemitem role="package">perl-base</systemitem>
141 package is intended only to provide for exceptional circumstances
142 and the contents may change. In general, only packages which form
143 part of the base system should use only the facilities of
144 <systemitem role="package">perl-base</systemitem> rather than
145 declaring a dependency on <systemitem
146 role="package">perl</systemitem>.
150 <section id="s-paths">
151 <title>Module Path</title>
154 Perl searches several different locations for modules, referred to
155 in this document as <replaceable>core</replaceable> in which
156 modules distributed with Perl are installed,
157 <replaceable>vendor</replaceable> for packaged modules and
158 <replaceable>site</replaceable> for modules installed by the local
162 The module search path (<literal>@INC</literal>) in the current
163 Debian packages has been ordered to include these locations in the
164 following order<footnote><para>@INC contains other paths which
165 should be considered internal to the implementation of the perl
166 packaging</para></footnote>
170 <term><replaceable>site</replaceable> (current)</term>
173 Modules installed by the local administrator for the current
174 version of Perl (see <xref linkend="ch-site"/>).
177 $Config{sitearch} (currently /usr/local/lib/<replaceable>arch-triplet</replaceable>/perl/<replaceable>version</replaceable>)
178 $Config{sitelib} (currently /usr/local/share/perl/<replaceable>version</replaceable>)</screen>
180 Where <replaceable>version</replaceable> indicates the
181 current Perl version (<literal>$Config{version}</literal>).
184 These locations, particularly
185 <literal>$Config{sitearch}</literal>, may change if the
186 binary interface between the Perl interpreter and compiled
187 modules has to be changed in an incompatible way without a
188 change in <replaceable>version</replaceable>. While this
189 will only be done as a last resort, packages should use
190 <literal>$Config{sitelib}</literal> and
191 <literal>$Config{sitearch}</literal>, not hardcode the
192 current locations.<footnote><para> Build systems based on
193 <literal>ExtUtils::MakeMaker</literal> and
194 <literal>Module::Build</literal> do this
195 automatically.</para></footnote>
200 <term><replaceable>vendor</replaceable></term>
203 Packaged modules (see <xref linkend="ch-module_packages"/>).
206 $Config{vendorarch} (currently /usr/lib/<replaceable>arch-triplet</replaceable>/perl5/<replaceable>shortversion</replaceable>)
207 $Config{vendorlib} (currently /usr/share/perl5)</screen>
209 Where <replaceable>shortversion</replaceable> indicates the
210 current Perl major version (for example
211 <literal>5.22</literal>).
214 These locations, particularly
215 <literal>$Config{vendorarch}</literal>, may change if
216 necessary<footnote><para> For example, to include the
217 multiarch triplet </para> </footnote>. Packages should use
218 <literal>$Config{vendorlib}</literal> and
219 <literal>$Config{vendorarch}</literal>, not hardcode the
220 current locations.<footnote><para> Build systems based on
221 <literal>ExtUtils::MakeMaker</literal> and
222 <literal>Module::Build</literal> do this automatically.
228 <term><replaceable>core</replaceable></term>
231 Modules included in the core Perl distribution.
234 $Config{archlib} (currently /usr/lib/<replaceable>arch-triplet</replaceable>/perl/<replaceable>shortversion</replaceable>)
235 $Config{privlib} (currently /usr/share/perl/<replaceable>shortversion</replaceable>)</screen>
237 Where <replaceable>shortversion</replaceable> indicates the
238 current Perl major version (for example
239 <literal>5.22</literal>).
242 These locations should be considered internal to the
243 <systemitem role="package">perl</systemitem> source package.
244 If necessary, packages should use
245 <literal>$Config{archlib}</literal> and
246 <literal>$Config{privlib}</literal> instead of hardcoding
247 the current locations.<footnote><para> Build systems based
248 on <literal>ExtUtils::MakeMaker</literal> and
249 <literal>Module::Build</literal> do this automatically.
255 <term><replaceable>site</replaceable> (old)</term>
258 <replaceable>site</replaceable> directories (as above) for
259 modules installed with previously released <systemitem
260 role="package">perl</systemitem> packages for which the
261 current package is binary compatible are included if
268 In each of the directory pairs above, the <filename>lib</filename>
269 component is for binary (XS) modules, and
270 <filename>share</filename> for architecture-independent
275 <section id="s-docs">
276 <title>Documentation</title>
279 The POD files and manual pages which do not refer to programs may
280 be split out into a separate <systemitem
281 role="package">perl-doc</systemitem> package.
284 Manual pages distributed with packages built from the perl source
285 package must be installed into the standard directories:
289 <term>Programs</term>
292 Manual pages for programs and scripts are installed into
293 <filename>/usr/share/man/man1</filename> with the extension
294 <literal>.1</literal>.
302 Manual pages for modules are installed into
303 <filename>/usr/share/man/man3</filename> with the extension
304 <literal>.3perl</literal>.
310 The extensions used for manual pages distributed with module
311 packages are different. See <xref linkend="s-vendor-dirs"/>.
317 <chapter id="ch-site">
318 <title>Locally Installed Modules</title>
320 <section id="s-site-dirs">
321 <title>Site Directories</title>
324 The Perl packages must provide a mechanism for the local
325 administrator to install modules under
326 <filename>/usr/local</filename> but must not create or remove
330 Modules should be installed to the directories described above in
331 <xref linkend="s-paths"/> as <replaceable>site</replaceable>
332 (current), programs to <filename>/usr/local/bin</filename> and
333 manual pages under <filename>/usr/local/man</filename>.
337 <section id="s-site-install">
338 <title>Site Installation</title>
341 The following commands should be sufficient in the majority of
342 cases for the local administrator to install modules and must
343 create directories as required:
347 make install</screen>
352 <chapter id="ch-module_packages">
353 <title>Packaged Modules</title>
355 <section id="s-vendor-dirs">
356 <title>Vendor Directories</title>
359 The installation directory for Debian modules must be different
360 from that for <replaceable>core</replaceable> and
361 <replaceable>site</replaceable> modules.
364 The current Perl packaging uses the
365 <replaceable>vendor</replaceable> directories for this purpose,
366 which are at present as described in <xref linkend="s-paths"/> as
367 <replaceable>vendor</replaceable>.
370 The Perl distribution includes many modules available separately
371 from <ulink url="https://www.cpan.org/">CPAN</ulink> which may
372 have a newer version. The intent of the <literal>@INC</literal>
373 ordering (described in <xref linkend="s-paths"/>) is to allow such
374 modules to be packaged to <replaceable>vendor</replaceable> which
375 take precedence over the version in
376 <replaceable>core</replaceable>. A packaged module which shadows
377 a <replaceable>core</replaceable> module in this way must be a
381 Module packages must install manual pages into the standard
382 directories (see <xref linkend="s-docs"/>) using the extensions
383 <literal>.1p</literal> and <literal>.3pm</literal> to ensure that
384 no conflict arises where a packaged module duplicates a
385 <replaceable>core</replaceable> module.
388 <filename>.packlist</filename> files should not be installed.
392 <section id="s-package-names">
393 <title>Module Package Names</title>
395 Perl module packages should be named for the primary module
396 provided. The naming convention is to lowercase the Perl module
397 name, prepend, <literal>lib</literal>, change all occurrences of
398 <literal>::</literal> to <literal>-</literal>, and append
399 <literal>-perl</literal>. For example:
402 <title>Module to package mappings</title>
406 <entry>Module</entry>
407 <entry>Package</entry>
412 <entry>Foo::Bar</entry>
413 <entry>libfoo-bar-perl</entry>
416 <entry>Foo::Bar::Baz</entry>
417 <entry>libfoo-bar-baz-perl</entry>
420 <entry>Foo::BarBaz</entry>
421 <entry>libfoo-barbaz-perl</entry>
427 Packages which include multiple modules may additionally include
428 provides for the additional modules using the same convention.
432 <section id="s-vendor-install">
433 <title>Vendor Installation</title>
435 A module should use the following lines in the
436 <filename>debian/rules</filename> <literal>build</literal>
440 The environment variable <literal>PERL_MM_OPT</literal> may be
441 used to pass the <literal>INSTALLDIRS=vendor</literal> option
442 in cases where <filename>Makefile.PL</filename> is not invoked
444 <filename>debian/rules</filename>
449 perl Makefile.PL INSTALLDIRS=vendor
450 $(MAKE) OPTIMIZE="-O2 -g -Wall"</screen>
452 and this one to install the results into the temporary tree:
454 <screen>$(MAKE) install DESTDIR=$(CURDIR)/debian/<tmp></screen>
456 <footnote><para>Replace <tmp> with the appropriate directory
457 (nominally just tmp)</para></footnote>
461 <section id="s-module-deps">
462 <title>Module Dependencies</title>
464 <section id="s-indep-modules">
465 <title>Architecture-Independent Modules</title>
468 Architecture-independent modules which require
469 <replaceable>core</replaceable> modules from the <systemitem
470 role="package">perl</systemitem> package must specify a
471 dependency on that package.
474 Modules which contain explicit <literal>require
475 <replaceable>version</replaceable></literal> or <literal>use
476 <replaceable>version</replaceable></literal> statements must
477 specify a dependency on <systemitem
478 role="package">perl</systemitem> or <systemitem
479 role="package">perl-base</systemitem> with the minimum required
480 version, or more simply the current version.
484 <section id="s-binary-modules">
485 <title>Binary and Other Architecture Dependent Modules</title>
488 Binary modules must specify a dependency on either <systemitem
489 role="package">perl</systemitem> or <systemitem
490 role="package">perl-base</systemitem> with a minimum version of
491 the <systemitem role="package">perl</systemitem> package used to
492 build the module. Additionally, all binary modules (regardless
493 of their installation directory) and any other modules installed
494 into <literal>$Config{vendorarch}</literal> must depend on the
495 expansion of <systemitem
496 role="package">perlapi-$Config{debian_abi}</systemitem> using
497 the <literal>Config</literal> module. If
498 <literal>$Config{debian_abi}</literal> is empty or not set,
499 <literal>$Config{version}</literal> must be used.
503 <section id="s-dh-perl">
504 <title>Automating Perl Dependencies</title>
507 Rather than hard-coding the dependencies into the control file,
508 using a substitution such as <literal>${perl:Depends}</literal>
509 is suggested. This allows the dependencies to be determined at
510 build time and written to the <filename>substvars</filename>
512 <literal>perl:Depends=<replaceable>deps</replaceable></literal>.<footnote><para>
513 Please note that dependencies caused by versioned uses and on
514 separately packaged modules are not included in this variable
515 and must be explicitly included. </para> </footnote>
518 Packages built with <command>debhelper</command> may use
519 <citerefentry><refentrytitle>dh_perl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
520 to generate this substitution automatically. This additionally
521 requires a versioned <literal>Build-Depends</literal> (or
522 <literal>Build-Depends-Indep</literal>) on <literal>debhelper
523 (>= 3.0.18)</literal>.
529 <chapter id="ch-programs">
530 <title>Perl Programs</title>
532 <section id="s-hash-bang">
533 <title>Script Magic</title>
536 All packaged perl programs must start with
537 <literal>#!/usr/bin/perl</literal> and may append such flags as
542 <section id="s-program-deps">
543 <title>Program Dependencies</title>
546 Programs which require <replaceable>core</replaceable> modules
547 from the <systemitem role="package">perl</systemitem> package must
548 specify a dependency on that package.
551 Programs which contain explicit <literal>require
552 <replaceable>version</replaceable></literal> or <literal>use
553 <replaceable>version</replaceable></literal> statements must
554 specify a dependency on <systemitem
555 role="package">perl</systemitem> or <systemitem
556 role="package">perl-base</systemitem> with the minimum required
557 version, or more simply the current version.
560 As with modules, packages using <command>debhelper</command> may
562 <citerefentry><refentrytitle>dh_perl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
563 to automatically generate dependences (see <xref
564 linkend="s-dh-perl"/>).
570 <chapter id="ch-embed">
571 <title>Programs Embedding Perl</title>
573 <section id="s-build-embedded">
574 <title>Building Embedded Programs</title>
577 Programs which embed a perl interpreter must declare a
578 <literal>Build-Depends</literal> on <systemitem
579 role="package">libperl-dev</systemitem>.
582 The default linker options produced by
584 <screen>perl -MExtUtils::Embed -e ldopts</screen>
586 will link against the dynamic <literal>libperl</literal>. If
587 programs wish to link to the static library, then
588 <literal>-lperl</literal> should be changed to
589 <filename>/usr/lib/libperl.a</filename> in those options.
593 <section id="s-embedded-deps">
594 <title>Embedded Perl Dependencies</title>
597 Dependencies for programs linking against the shared Perl library
598 will be automatically created by
599 <command>dpkg-shlibdeps</command>. Note however that the shared
600 perl library package only suggests <systemitem
601 role="package">perl-base</systemitem> and packages requiring any
602 <replaceable>core</replaceable> modules from the <systemitem
603 role="package">perl</systemitem> package must depend upon it
608 <section id="s-perl-upgrades">
609 <title>Perl Package Upgrades</title>
612 Starting from <systemitem role="package">perl</systemitem>
613 5.12.3-2, a dpkg trigger named
614 <replaceable>perl-major-upgrade</replaceable> will be triggered by
615 the postinst of the <systemitem role="package">perl</systemitem>
616 package during major upgrades. Some examples of things which
617 constitute a major upgrade are an upgrade which would change the
618 value of versioned directories in <literal>@INC</literal>, or one
619 which changes <literal>abiname</literal>. Any package may declare
620 an interest in the trigger, especially packages including
621 long-running daemons which would stop working until restart.
624 It is suggested that such packages include an appropriate section
625 in their postinst to handle the trigger by restarting relevant
626 daemons or notifying users of further action.
632 <appendix id="ap-perl6">
633 <title>Perl 6</title>
636 The current stable upstream version at the time of this writing is
637 5.6.0. There is currently work in progress on the next major
638 revision, although the specifications have yet to be finalised.
641 It is anticipated that when Perl 6 is released it will initially be
642 packaged as <systemitem role="package">perl6</systemitem>, install
643 the binary as <filename>/usr/bin/perl6</filename> and use different
644 directories for packaged modules to <systemitem
645 role="package">perl</systemitem>:
649 /usr/share/perl6</screen>
651 This will allow Perl 5 and 6 packages and modules (which should be
652 packaged as <systemitem
653 role="package">libfoo-bar-perl6</systemitem>), to co-exist for as
657 At some stage in the future when Perl 6 is sufficiently mature, the
658 package naming may be reversed such that the <systemitem
659 role="package">perl</systemitem> package contains Perl 6 and the
660 current package becomes <systemitem
661 role="package">perl5</systemitem>.