fix 'pgpsignurlmangle'
[debian-policy.git] / perl-policy.xml
blob9888287c372ad05bb955844f62c8fe78c0763f66
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;
6 ]>
8 <book lang="en">
9   <title>Debian Perl Policy</title>
11   <bookinfo>
12     <authorgroup>
13       <author>
14         <personname>
15           <firstname>Rapha&euml;l</firstname><surname>Hertzog</surname>
16         </personname>
17       </author>
18       <author>
19         <personname>
20           <firstname>Brendan</firstname><surname>O'Dea</surname>
21         </personname>
22       </author>
23       <author>
24         <othername>The Debian Policy Mailing List</othername>
25         <email>debian-policy@lists.debian.org</email>
26       </author>
27     </authorgroup>
29     <releaseinfo>version &version;</releaseinfo>
30     <pubdate>&date;</pubdate>
32     <abstract>
33       <para>
34         This document describes the packaging of Perl within the Debian
35         distribution and the policy requirements for packaged Perl
36         programs and modules.
37       </para>
38     </abstract>
40     <copyright>
41       <year>1999</year>
42       <year>2001</year>
43       <holder>Rapha&euml;l Hertzog</holder>
44       <holder>Brendan O'Dea</holder>
45     </copyright>
46     <legalnotice>
47       <para>
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
51         exists.
52       </para>
53       <para>
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.
58       </para>
59       <para>
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.
64       </para>
65       <para>
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>.
70       </para>
71     </legalnotice>
72   </bookinfo>
74   <chapter id="ch1">
75     <title>About this document</title>
76     <para>
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>.
82     </para>
83   </chapter>
85   <chapter id="ch-perl">
86     <title>Perl Packaging</title>
88     <section id="s-versions">
89       <title>Versions</title>
91       <para>
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"/>).
96       </para>
97       <para>
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"/>).
102       </para>
103       <para>
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"/>).
109       </para>
110       <para>
111         The <systemitem role="package">perl-base</systemitem> package must
112         provide <systemitem
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
116         it differs from
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>.
120       </para>
121     </section>
123     <section id="s-base">
124       <title>Base Package</title>
126       <para>
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.
131       </para>
132       <para>
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>.
138       </para>
139       <para>
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>.
147       </para>
148     </section>
150     <section id="s-paths">
151       <title>Module Path</title>
153       <para>
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
159         administrator.
160       </para>
161       <para>
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>
167       </para>
168       <variablelist>
169         <varlistentry>
170           <term><replaceable>site</replaceable> (current)</term>
171           <listitem>
172             <para>
173               Modules installed by the local administrator for the current
174               version of Perl (see <xref linkend="ch-site"/>).
175             </para>
176             <screen>
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>
179             <para>
180               Where <replaceable>version</replaceable> indicates the
181               current Perl version (<literal>$Config{version}</literal>).
182             </para>
183             <para>
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>
196             </para>
197           </listitem>
198         </varlistentry>
199         <varlistentry>
200           <term><replaceable>vendor</replaceable></term>
201           <listitem>
202             <para>
203               Packaged modules (see <xref linkend="ch-module_packages"/>).
204             </para>
205             <screen>
206 $Config{vendorarch} (currently /usr/lib/<replaceable>arch-triplet</replaceable>/perl5/<replaceable>shortversion</replaceable>)
207 $Config{vendorlib}  (currently /usr/share/perl5)</screen>
208             <para>
209               Where <replaceable>shortversion</replaceable> indicates the
210               current Perl major version (for example
211               <literal>5.22</literal>).
212             </para>
213             <para>
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.
223               </para> </footnote>
224             </para>
225           </listitem>
226         </varlistentry>
227         <varlistentry>
228           <term><replaceable>core</replaceable></term>
229           <listitem>
230             <para>
231               Modules included in the core Perl distribution.
232             </para>
233             <screen>
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>
236             <para>
237               Where <replaceable>shortversion</replaceable> indicates the
238               current Perl major version (for example
239               <literal>5.22</literal>).
240             </para>
241             <para>
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.
250               </para> </footnote>
251             </para>
252           </listitem>
253         </varlistentry>
254         <varlistentry>
255           <term><replaceable>site</replaceable> (old)</term>
256           <listitem>
257             <para>
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
262               present.
263             </para>
264           </listitem>
265         </varlistentry>
266       </variablelist>
267       <para>
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
271         (pure-perl) modules.
272       </para>
273     </section>
275     <section id="s-docs">
276       <title>Documentation</title>
278       <para>
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.
282       </para>
283       <para>
284         Manual pages distributed with packages built from the perl source
285         package must be installed into the standard directories:
286       </para>
287       <variablelist>
288         <varlistentry>
289           <term>Programs</term>
290           <listitem>
291             <para>
292               Manual pages for programs and scripts are installed into
293               <filename>/usr/share/man/man1</filename> with the extension
294               <literal>.1</literal>.
295             </para>
296           </listitem>
297         </varlistentry>
298         <varlistentry>
299           <term>Modules</term>
300           <listitem>
301             <para>
302               Manual pages for modules are installed into
303               <filename>/usr/share/man/man3</filename> with the extension
304               <literal>.3perl</literal>.
305             </para>
306           </listitem>
307         </varlistentry>
308       </variablelist>
309       <para>
310         The extensions used for manual pages distributed with module
311         packages are different.  See <xref linkend="s-vendor-dirs"/>.
312       </para>
313     </section>
315   </chapter>
317   <chapter id="ch-site">
318     <title>Locally Installed Modules</title>
320     <section id="s-site-dirs">
321       <title>Site Directories</title>
323       <para>
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
327         those directories.
328       </para>
329       <para>
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>.
334       </para>
335     </section>
337     <section id="s-site-install">
338       <title>Site Installation</title>
340       <para>
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:
344       </para>
345       <screen>
346 perl Makefile.PL
347 make install</screen>
348     </section>
350   </chapter>
352   <chapter id="ch-module_packages">
353     <title>Packaged Modules</title>
355     <section id="s-vendor-dirs">
356       <title>Vendor Directories</title>
358       <para>
359         The installation directory for Debian modules must be different
360         from that for <replaceable>core</replaceable> and
361         <replaceable>site</replaceable> modules.
362       </para>
363       <para>
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>.
368       </para>
369       <para>
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
378         newer version.
379       </para>
380       <para>
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.
386       </para>
387       <para>
388         <filename>.packlist</filename> files should not be installed.
389       </para>
390     </section>
392     <section id="s-package-names">
393       <title>Module Package Names</title>
394       <para>
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:
400       </para>
401       <table frame="all">
402         <title>Module to package mappings</title>
403         <tgroup cols="2">
404           <thead>
405             <row>
406               <entry>Module</entry>
407               <entry>Package</entry>
408             </row>
409           </thead>
410           <tbody>
411             <row>
412               <entry>Foo::Bar</entry>
413               <entry>libfoo-bar-perl</entry>
414             </row>
415             <row>
416               <entry>Foo::Bar::Baz</entry>
417               <entry>libfoo-bar-baz-perl</entry>
418             </row>
419             <row>
420               <entry>Foo::BarBaz</entry>
421               <entry>libfoo-barbaz-perl</entry>
422             </row>
423           </tbody>
424         </tgroup>
425       </table>
426       <para>
427         Packages which include multiple modules may additionally include
428         provides for the additional modules using the same convention.
429       </para>
430     </section>
432     <section id="s-vendor-install">
433       <title>Vendor Installation</title>
434       <para>
435         A module should use the following lines in the
436         <filename>debian/rules</filename> <literal>build</literal>
437         target:
438         <footnote>
439           <para>
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
443             directly from
444             <filename>debian/rules</filename>
445           </para>
446         </footnote>
447       </para>
448       <screen>
449 perl Makefile.PL INSTALLDIRS=vendor
450 $(MAKE) OPTIMIZE="-O2 -g -Wall"</screen>
451       <para>
452         and this one to install the results into the temporary tree:
453       </para>
454       <screen>$(MAKE) install DESTDIR=$(CURDIR)/debian/&lt;tmp&gt;</screen>
455       <para>
456         <footnote><para>Replace &lt;tmp&gt; with the appropriate directory
457         (nominally just tmp)</para></footnote>
458       </para>
459     </section>
461     <section id="s-module-deps">
462       <title>Module Dependencies</title>
464       <section id="s-indep-modules">
465         <title>Architecture-Independent Modules</title>
467         <para>
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.
472         </para>
473         <para>
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.
481         </para>
482       </section>
484       <section id="s-binary-modules">
485         <title>Binary and Other Architecture Dependent Modules</title>
487         <para>
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.
500         </para>
501       </section>
503       <section id="s-dh-perl">
504         <title>Automating Perl Dependencies</title>
506         <para>
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>
511           file in the form
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>
516         </para>
517         <para>
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>.
524         </para>
525       </section>
526     </section>
527   </chapter>
529   <chapter id="ch-programs">
530     <title>Perl Programs</title>
532     <section id="s-hash-bang">
533       <title>Script Magic</title>
535       <para>
536         All packaged perl programs must start with
537         <literal>#!/usr/bin/perl</literal> and may append such flags as
538         are required.
539       </para>
540     </section>
542     <section id="s-program-deps">
543       <title>Program Dependencies</title>
545       <para>
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.
549       </para>
550       <para>
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.
558       </para>
559       <para>
560         As with modules, packages using <command>debhelper</command> may
561         use
562         <citerefentry><refentrytitle>dh_perl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
563         to automatically generate dependences (see <xref
564         linkend="s-dh-perl"/>).
565       </para>
566     </section>
568   </chapter>
570   <chapter id="ch-embed">
571     <title>Programs Embedding Perl</title>
573     <section id="s-build-embedded">
574       <title>Building Embedded Programs</title>
576       <para>
577         Programs which embed a perl interpreter must declare a
578         <literal>Build-Depends</literal> on <systemitem
579         role="package">libperl-dev</systemitem>.
580       </para>
581       <para>
582         The default linker options produced by
583       </para>
584       <screen>perl -MExtUtils::Embed -e ldopts</screen>
585       <para>
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.
590       </para>
591     </section>
593     <section id="s-embedded-deps">
594       <title>Embedded Perl Dependencies</title>
596       <para>
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
604         explicitly.
605       </para>
606     </section>
608     <section id="s-perl-upgrades">
609       <title>Perl Package Upgrades</title>
611       <para>
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.
622       </para>
623       <para>
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.
627       </para>
628     </section>
630   </chapter>
632   <appendix id="ap-perl6">
633     <title>Perl 6</title>
635     <para>
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.
639     </para>
640     <para>
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>:
646     </para>
647     <screen>
648 /usr/lib/perl6
649 /usr/share/perl6</screen>
650     <para>
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
654       long as required.
655     </para>
656     <para>
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>.
662     </para>
663   </appendix>
664 </book>