]> git.donarmstrong.com Git - debian/debian-policy.git/blob - perl-policy.sgml
abe04d9a47d63c537a75dc9a8b5fcad150e233a3
[debian/debian-policy.git] / perl-policy.sgml
1 <!doctype debiandoc system [
2 <!-- include version information so we don't have to hard code it
3      within the document -->
4 <!entity % versiondata SYSTEM "version.ent"> %versiondata;
5 ]>
6
7 <debiandoc>
8   <book>
9     <titlepag>
10       <title>Debian Perl Policy</title>
11       <author>
12         <name>Rapha&euml;l Hertzog</name>
13       </author>
14       <author>
15         <name>Brendan O'Dea</name>
16       </author>
17       <author>
18         <name>The Debian Policy mailing list</name>
19         <email>debian-policy@lists.debian.org</email>
20       </author>
21       <version>version &version;, &date;</version>
22
23       <abstract>
24         This document describes the packaging of Perl within the Debian
25         distribution and the policy requirements for packaged
26         Perl programs and modules.
27       </abstract>
28
29       <copyright>
30         <copyrightsummary>
31           Copyright &copy; 1999, 2001 Software in the Public Interest
32         </copyrightsummary>
33         <p>
34           This manual is free software; you can redistribute it and/or
35           modify it under the terms of the GNU General Public License
36           as published by the Free Software Foundation; either version
37           2 of the License, or (at your option) any later version.
38         </p>
39         <p>
40           This is distributed in the hope that it will be useful, but
41           WITHOUT ANY WARRANTY; without even the implied warranty of
42           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
43           the GNU General Public License for more details.
44         </p>
45         <p>
46           A copy of the GNU General Public License is available as
47           <tt>/usr/share/common-licenses/GPL</tt> in the Debian
48           distribution or on the World Wide Web at 
49           <url id="http://www.gnu.org/copyleft/gpl.html"
50           name="The GNU Public Licence">.
51         </p>
52         <p>
53           You can also obtain it by writing to the
54           Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
55           Boston, MA 02110-1301, USA. 
56         </p>
57       </copyright>
58     </titlepag>
59
60     <toc detail="sect">
61
62     <chapt>
63       <heading>About this document</heading>
64       <p>
65         This document is distributed as the <tt>perl-policy</tt> files
66         in the Debian package
67         <package><url name="debian-policy" id="http://packages.debian.org/debian-policy"></package>.
68         It is also available from the Debian web mirrors at
69         <tt><url name="/doc/packaging-manuals/perl-policy/"
70                 id="http://www.debian.org/doc/packaging-manuals/perl-policy/"></tt>.
71       </p>
72     </chapt>
73
74     <chapt id="perl">
75       <heading>Perl Packaging</heading>
76       <sect id="versions">
77         <heading>Versions</heading>
78         <p>
79           At any given time, the package <package>perl</package> should
80           represent the current stable upstream version of Perl revision
81           5 (see <ref id="perl6">).
82         </p>
83         <p>
84           Only one package may contain the <file>/usr/bin/perl</file>
85           binary and that package must either be <package>perl</package>
86           or a dependency of that package (see <ref id="base">).
87         </p>
88         <p>
89           Where possible, Perl should be compiled to provide binary
90           compatibility to at least the last released package version to
91           allow a grace period over which binary module packages may be
92           re-built against the new package (see <ref id="binary_modules">).
93         </p>
94         <p>
95           The <package>perl-base</package> package must provide
96           <package>perlapi-<var>abiname</var></package> for all released
97           package versions it is compatible with. The choice of
98           <var>abiname</var> is arbitrary, but if it differs from
99           <tt>$Config{version}</tt>, it must be specified in
100           <tt>$Config{debian_abi}</tt>.
101         </p>
102       </sect>
103
104       <sect id="base">
105         <heading>Base Package</heading>
106         <p>
107           In order to provide a minimal installation of Perl for use by
108           applications without requiring the whole of Perl to be
109           installed, the <package>perl-base</package> package contains
110           the binary and a basic set of modules.
111         </p>
112         <p>
113           As Perl has been part of the essential set for some time and is
114           used without dependencies by such things as package maintainer
115           scripts, <package>perl-base</package> must be
116           priority <em>required</em> and marked as <em>essential</em>.
117         </p>
118         <p>
119           Note that the <package>perl-base</package> package is intended
120           only to provide for exceptional circumstances and the contents
121           may change.  In general, only packages which form part of the
122           base system should use only the facilities
123           of <package>perl-base</package> rather than declaring a
124           dependency on <package>perl</package>.
125         </p>
126       </sect>
127
128       <sect id="paths">
129         <heading>Module Path</heading>
130         <p>
131           Perl searches three different locations for modules, referred
132           to in this document as <var>core</var> in which modules
133           distributed with Perl are installed, <var>vendor</var> for
134           packaged modules and <var>site</var> for modules installed by
135           the local administrator.
136         </p>
137         <p>
138           The module search path (<tt>@INC</tt>) in the Debian packages
139           has been ordered to include these locations in the following
140           order:
141           <taglist>
142             <tag><var>site</var> (current)</tag>
143             <item>
144               <p>
145                 Modules installed by the local administrator for the
146                 current version of Perl (see <ref id="site">).
147                 <example>
148 /usr/local/lib/perl/<var>version</var>
149 /usr/local/share/perl/<var>version</var>
150                 </example>
151                 Where <var>version</var> indicates the current Perl
152                 version (<tt>$Config{version}</tt><footnote>see the
153                 <tt>Config</tt> module</footnote>).
154               </p>
155             </item>
156             <tag><var>vendor</var></tag>
157             <item>
158               <p>
159                 Packaged modules (see <ref id="module_packages">).
160                 <example>
161 /usr/lib/perl5
162 /usr/share/perl5
163                 </example>
164               </p>
165             </item>
166             <tag><var>core</var></tag>
167             <item>
168               <p>
169                 Modules included in the core Perl distribution.
170                 <example>
171 /usr/lib/perl/<var>shortversion</var>
172 /usr/share/perl/<var>shortversion</var>
173                 </example>
174                 Where <var>shortversion</var> indicates the current Perl major
175                 version (for example <tt>5.18</tt>).
176               </p>
177             </item>
178             <tag><var>site</var> (old)</tag>
179             <item>
180               <p>
181                 <var>site</var> directories (as above) for modules
182                 installed with previously released
183                 <package>perl</package> packages for which the current
184                 package is binary compatible are included if present.
185               </p>
186             </item>
187           </taglist>
188           In each of the directory pairs above, the <file>lib</file>
189           component is for binary (XS) modules, and <file>share</file>
190           for architecture-independent (pure-perl) modules.
191         </p>
192       </sect>
193
194       <sect id="docs">
195         <heading>Documentation</heading>
196         <p>
197           The POD files and manual pages which do not refer to programs
198           may be split out into a separate <package>perl-doc</package>
199           package.
200         </p>
201         <p>
202           Manual pages distributed with packages built from the perl
203           source package must be installed into the standard directories:
204           <taglist>
205             <tag>Programs</tag>
206             <item>
207               <p>
208                 Manual pages for programs and scripts are installed into
209                 <file>/usr/share/man/man1</file> with the extension
210                 <tt>.1</tt>.
211               </p>
212             </item>
213             <tag>Modules</tag>
214             <item>
215               <p>
216                 Manual pages for modules are installed into
217                 <file>/usr/share/man/man3</file> with the extension
218                 <tt>.3perl</tt>.
219               </p>
220             </item>
221           </taglist>
222           The extensions used for manual pages distributed with module
223           packages are different.  See <ref id="vendor_dirs">.
224         </p>
225       </sect>
226     </chapt>
227
228     <chapt id="site">
229       <heading>Locally Installed Modules</heading>
230       <sect id="site_dirs">
231         <heading>Site Directories</heading>
232         <p>
233           The Perl packages must provide a mechanism for the local
234           administrator to install modules under <file>/usr/local</file>
235           but must not create or remove those directories.
236         </p>
237         <p>
238           Modules should be installed to the directories described above
239           in <ref id="paths"> as <var>site</var> (current), programs to
240           <file>/usr/local/bin</file> and manual pages under
241           <file>/usr/local/man</file>.
242         </p>
243       </sect>
244
245       <sect id="site_install">
246         <heading>Site Installation</heading>
247         <p>
248           The following commands should be sufficient in the majority of
249           cases for the local administrator to install modules and must
250           create directories as required:
251           <example>
252 perl Makefile.PL
253 make install
254           </example>
255         </p>
256       </sect>
257     </chapt>
258
259     <chapt id="module_packages">
260       <heading>Packaged Modules</heading>
261       <sect id="vendor_dirs">
262         <heading>Vendor Directories</heading>
263         <p>
264           The installation directory for Debian modules must be
265           different from that for <var>core</var> and <var>site</var>
266           modules.
267         </p>
268         <p>
269           The current Perl packaging uses the <var>vendor</var>
270           directories for this purpose, which are at present as
271           described in <ref id="paths"> as <var>vendor</var>.
272         </p>
273         <p>
274           No version subdirectory exists on these directories as the
275           dependencies for packaged modules (see <ref id="module_deps">)
276           should ensure that all work with the current
277           <package>perl</package> package.
278         </p>
279         <p>
280           The Perl distribution includes many modules available
281           separately from CPAN<footnote><url
282           id="http://www.perl.com/CPAN"></footnote>, which may have a
283           newer version.  The intent of the <tt>@INC</tt> ordering
284           (described in <ref id="paths">) is to allow such modules to be
285           packaged to <var>vendor</var> which take precedence over the
286           version in <var>core</var>.  A packaged module which shadows a
287           <var>core</var> module in this way must be a newer version.
288         </p>
289         <p>
290           Module packages must install manual pages into the standard
291           directories (see <ref id="docs">) using the extensions
292           <tt>.1p</tt> and <tt>.3pm</tt> to ensure that no conflict
293           arises where a packaged module duplicates a <var>core</var>
294           module.
295         </p>
296         <p>
297           <file>.packlist</file> files should not be installed.
298         </p>
299       </sect>
300
301       <sect id="package_names">
302         <heading>Module Package Names</heading>
303         <p>
304           Perl module packages should be named for the primary module
305           provided.  The naming convention is to lowercase the Perl module
306           name, prepend, <tt>lib</tt>, change all occurrences
307           of <tt>::</tt> to <tt>-</tt>, and append <tt>-perl</tt>.  For
308           example:
309           <example>
310 Foo::Bar        libfoo-bar-perl
311 Foo::Bar::Baz   libfoo-bar-baz-perl
312 Foo::BarBaz     libfoo-barbaz-perl
313           </example>
314           Packages which include multiple modules may additionally include
315           provides for the additional modules using the same convention.
316         </p>
317       </sect>
318
319       <sect id="vendor_install">
320         <heading>Vendor Installation</heading>
321         <p>
322           A module should use the following lines in the
323           <file>debian/rules</file> <tt>build</tt>
324           target<footnote>The environment variable <tt>PERL_MM_OPT</tt>
325           may be used to pass the <tt>INSTALLDIRS=vendor</tt> option in
326           cases where <file>Makefile.PL</file> is not invoked directly
327           from <file>debian/rules</file></footnote>:
328           <example>
329 perl Makefile.PL INSTALLDIRS=vendor
330 $(MAKE) OPTIMIZE="-O2 -g -Wall"
331           </example>
332           and this one to install the results into the temporary tree:
333           <example>
334 $(MAKE) install DESTDIR=$(CURDIR)/debian/&lt;tmp&gt;
335           </example><footnote>
336             <p>Replace &lt;tmp&gt; with the appropriate directory
337             (nominally just tmp)</p>
338           </footnote>
339         </p>
340       </sect>
341
342       <sect id="module_deps">
343         <heading>Module Dependencies</heading>
344         <sect1 id="indep_modules">
345           <heading>Architecture-Independent Modules</heading>
346           <p>
347             Architecture-independent modules which require
348             <var>core</var> modules from the <package>perl</package>
349             package must specify a dependency on that package.
350           </p>
351           <p>
352             Modules which contain explicit <tt>require
353             <var>version</var></tt> or <tt>use <var>version</var></tt>
354             statements must specify a dependency on
355             <package>perl</package> or <package>perl-base</package> with
356             the minimum required version, or more simply the current
357             version.
358           </p>
359         </sect1>
360
361         <sect1 id="binary_modules">
362           <heading>Binary Modules</heading>
363           <p>
364             Binary modules must specify a dependency on either
365             <package>perl</package> or <package>perl-base</package> with
366             a minimum version of the <package>perl</package> package
367             used to build the module, and must additionally depend on
368             the expansion of
369             <package>perlapi-$Config{debian_abi}</package> using
370             the <tt>Config</tt> module. If <tt>$Config{debian_abi}</tt>
371             is empty or not set, <tt>$Config{version}</tt> must be used.
372           </p>
373         </sect1>
374
375         <sect1 id="dh_perl">
376           <heading>Automating Perl Dependencies</heading>
377           <p>
378             Rather than hard-coding the dependencies into the control
379             file, using a substitution such as <tt>${perl:Depends}</tt>
380             is suggested.  This allows the dependencies to be determined
381             at build time and written to the <file>substvars</file> file
382             in the form
383             <tt>perl:Depends=<var>deps</var></tt>.<footnote>
384               <p>Please note that dependencies caused by versioned
385               uses and on separately packaged modules are not included
386               in this variable and must be explicitly included.</p>
387             </footnote>
388           </p>
389           <p>
390             Packages built with <prgn>debhelper</prgn> may use
391
392             <manref name="dh_perl" section="1"> to generate this
393             substitution automatically.  This additionally requires a
394             versioned <tt>Build-Depends</tt> (or
395             <tt>Build-Depends-Indep</tt>) on <tt>debhelper (>=
396             3.0.18)</tt>.
397           </p>
398         </sect1>
399       </sect>
400     </chapt>
401
402     <chapt id="programs">
403       <heading>Perl Programs</heading>
404       <sect id="hash_bang">
405         <heading>Script Magic</heading>
406         <p>
407           All packaged perl programs must start with
408           <tt>#!/usr/bin/perl</tt> and may append such flags as are
409           required.
410         </p>
411       </sect>
412
413       <sect id="program_deps">
414         <heading>Program Dependencies</heading>
415         <p>
416           Programs which require <var>core</var> modules from the
417           <package>perl</package> package must specify a dependency on
418           that package.
419         </p>
420         <p>
421           Programs which contain explicit <tt>require
422           <var>version</var></tt> or <tt>use <var>version</var></tt>
423           statements must specify a dependency on
424           <package>perl</package> or <package>perl-base</package> with
425           the minimum required version, or more simply the current
426           version.
427         </p>
428         <p>
429           As with modules, packages using <prgn>debhelper</prgn> may use
430           <manref name="dh_perl" section="1"> to automatically generate
431           dependences (see <ref id="dh_perl">).
432         </p>
433       </sect>
434     </chapt>
435
436     <chapt id="embed">
437       <heading>Programs Embedding Perl</heading>
438       <sect id="build_embedded">
439         <heading>Building Embedded Programs</heading>
440         <p>
441           Programs which embed a perl interpreter must declare a
442           <tt>Build-Depends</tt> on <package>libperl-dev</package>.
443         </p>
444         <p>
445           The default linker options produced by
446           <example>
447 perl -MExtUtils::Embed -e ldopts
448           </example>
449           will link against the dynamic <tt>libperl</tt>.  If programs
450           wish to link to the static library, then <tt>-lperl</tt>
451           should be changed to <file>/usr/lib/libperl.a</file> in those
452           options.
453         </p>
454       </sect>
455
456       <sect id="embedded_deps">
457         <heading>Embedded Perl Dependencies</heading>
458         <p>
459           Dependencies for programs linking against the shared Perl
460           library will be automatically created by
461           <prgn>dpkg-shlibdeps</prgn>.  Note however that the shared
462           perl library package only suggests
463           <package>perl-base</package> and packages requiring any
464           <var>core</var> modules from the <package>perl</package>
465           package must depend upon it explicitly.
466         </p>
467       </sect>
468
469       <sect id="perl_upgrades">
470         <heading>Perl Package Upgrades</heading>
471         <p>
472           Starting from <package>perl</package> 5.12.3-2, a dpkg trigger
473           named <var>perl-major-upgrade</var> will be triggered by the
474           postinst of the <package>perl</package> package during major
475           upgrades. Some examples of things which constitute a major upgrade
476           are an upgrade which would change the value of versioned
477           directories in <tt>@INC</tt>, or one which changes <tt>abiname</tt>.
478           Any package may declare an interest in the trigger, especially
479           packages including long-running daemons which would stop working
480           until restart.
481         </p>
482         <p>
483           It is suggested that such packages include an appropriate section
484           in their postinst to handle the trigger by restarting relevant
485           daemons or notifying users of further action.
486         </p>
487       </sect>
488     </chapt>
489
490     <appendix id="perl6">
491       <heading>Perl 6</heading>
492       <p>
493         The current stable upstream version at the time of this writing
494         is 5.6.0.  There is currently work in progress on the next major
495         revision, although the specifications have yet to be finalised.
496       </p>
497       <p>
498         It is anticipated that when Perl 6 is released it will initially
499         be packaged as <package>perl6</package>, install the binary as
500         <file>/usr/bin/perl6</file> and use different directories for
501         packaged modules to <package>perl</package>:
502         <example>
503 /usr/lib/perl6
504 /usr/share/perl6
505         </example>
506         This will allow Perl 5 and 6 packages and modules (which should
507         be packaged as <package>libfoo-bar-perl6</package>), to co-exist
508         for as long as required.
509       </p>
510       <p>
511         At some stage in the future when Perl 6 is sufficiently mature,
512         the package naming may be reversed such that the
513         <package>perl</package> package contains Perl 6 and the current
514         package becomes <package>perl5</package>.
515       </p>
516     </appendix>
517   </book>
518 </debiandoc>
519 <!-- Local variables: -->
520 <!-- indent-tabs-mode: t -->
521 <!-- End: -->