]> git.donarmstrong.com Git - debian/debian-policy.git/blob - perl-policy.sgml
Merge branch 'master' into bug504880-rra
[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         GNU/Linux 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 GNU/Linux
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>version</var>
172 /usr/share/perl/<var>version</var>
173                 </example>
174               </p>
175             </item>
176             <tag><var>site</var> (old)</tag>
177             <item>
178               <p>
179                 <var>site</var> directories (as above) for modules
180                 installed with previously released
181                 <package>perl</package> packages for which the current
182                 package is binary compatible are included if present.
183               </p>
184             </item>
185           </taglist>
186           In each of the directory pairs above, the <file>lib</file>
187           component is for binary (XS) modules, and <file>share</file>
188           for architecture-independent (pure-perl) modules.
189         </p>
190       </sect>
191
192       <sect id="docs">
193         <heading>Documentation</heading>
194         <p>
195           The POD files and manual pages which do not refer to programs
196           may be split out into a separate <package>perl-doc</package>
197           package.
198         </p>
199         <p>
200           Manual pages distributed with Perl packages must be installed
201           into the standard directories:
202           <taglist>
203             <tag>Programs</tag>
204             <item>
205               <p>
206                 Manual pages for programs and scripts are installed into
207                 <file>/usr/share/man/man1</file> with the extension
208                 <tt>.1</tt>.
209               </p>
210             </item>
211             <tag>Modules</tag>
212             <item>
213               <p>
214                 Manual pages for modules are installed into
215                 <file>/usr/share/man/man3</file> with the extension
216                 <tt>.3perl</tt>.
217               </p>
218             </item>
219           </taglist>
220         </p>
221       </sect>
222     </chapt>
223
224     <chapt id="site">
225       <heading>Locally Installed Modules</heading>
226       <sect id="site_dirs">
227         <heading>Site Directories</heading>
228         <p>
229           The Perl packages must provide a mechanism for the local
230           administrator to install modules under <file>/usr/local</file>
231           but must not create or remove those directories.
232         </p>
233         <p>
234           Modules should be installed to the directories described above
235           in <ref id="paths"> as <var>site</var> (current), programs to
236           <file>/usr/local/bin</file> and manual pages under
237           <file>/usr/local/man</file>.
238         </p>
239       </sect>
240
241       <sect id="site_install">
242         <heading>Site Installation</heading>
243         <p>
244           The following commands should be sufficient in the majority of
245           cases for the local administrator to install modules and must
246           create directories as required:
247           <example>
248 perl Makefile.PL
249 make install
250           </example>
251         </p>
252       </sect>
253     </chapt>
254
255     <chapt id="module_packages">
256       <heading>Packaged Modules</heading>
257       <sect id="vendor_dirs">
258         <heading>Vendor Directories</heading>
259         <p>
260           The installation directory for Debian modules must be
261           different from that for <var>core</var> and <var>site</var>
262           modules.
263         </p>
264         <p>
265           The current Perl packaging uses the <var>vendor</var>
266           directories for this purpose, which are at present as
267           described in <ref id="paths"> as <var>vendor</var>.
268         </p>
269         <p>
270           No version subdirectory exists on these directories as the
271           dependencies for packaged modules (see <ref id="module_deps">)
272           should ensure that all work with the current
273           <package>perl</package> package.
274         </p>
275         <p>
276           The Perl distribution includes many modules available
277           separately from CPAN<footnote><url
278           id="http://www.perl.com/CPAN"></footnote>, which may have a
279           newer version.  The intent of the <tt>@INC</tt> ordering
280           (described in <ref id="paths">) is to allow such modules to be
281           packaged to <var>vendor</var> which take precedence over the
282           version in <var>core</var>.  A packaged module which shadows a
283           <var>core</var> module in this way must be a newer version.
284         </p>
285         <p>
286           Module packages must install manual pages into the standard
287           directories (see <ref id="docs">) using the extensions
288           <tt>.1p</tt> and <tt>.3pm</tt> to ensure that no conflict
289           arises where a packaged module duplicates a <var>core</var>
290           module.
291         </p>
292         <p>
293           <file>.packlist</file> files should not be installed.
294         </p>
295       </sect>
296
297       <sect id="package_names">
298         <heading>Module Package Names</heading>
299         <p>
300           Perl module packages should be named for the primary module
301           provided.  The naming convention is to lowercase the Perl module
302           name, prepend, <tt>lib</tt>, change all occurrences
303           of <tt>::</tt> to <tt>-</tt>, and append <tt>-perl</tt>.  For
304           example:
305           <example>
306 Foo::Bar        libfoo-bar-perl
307 Foo::Bar::Baz   libfoo-bar-baz-perl
308 Foo::BarBaz     libfoo-barbaz-perl
309           </example>
310           Packages which include multiple modules may additionally include
311           provides for the additional modules using the same convention.
312         </p>
313       </sect>
314
315       <sect id="vendor_install">
316         <heading>Vendor Installation</heading>
317         <p>
318           A module should use the following lines in the
319           <file>debian/rules</file> <tt>build</tt>
320           target<footnote>The environment variable <tt>PERL_MM_OPT</tt>
321           may be used to pass the <tt>INSTALLDIRS=vendor</tt> option in
322           cases where <file>Makefile.PL</file> is not invoked directly
323           from <file>debian/rules</file></footnote>:
324           <example>
325 perl Makefile.PL INSTALLDIRS=vendor
326 $(MAKE) OPTIMIZE="-O2 -g -Wall"
327           </example>
328           and this one to install the results into the temporary tree:
329           <example>
330 $(MAKE) install DESTDIR=$(CURDIR)/debian/&lt;tmp&gt;
331           </example><footnote>
332             <p>Replace &lt;tmp&gt; with the appropriate directory
333             (nominally just tmp)</p>
334           </footnote>
335         </p>
336       </sect>
337
338       <sect id="module_deps">
339         <heading>Module Dependencies</heading>
340         <sect1 id="indep_modules">
341           <heading>Architecture-Independent Modules</heading>
342           <p>
343             Architecture-independent modules which require
344             <var>core</var> modules from the <package>perl</package>
345             package must specify a dependency on that package.
346           </p>
347           <p>
348             Modules which contain explicit <tt>require
349             <var>version</var></tt> or <tt>use <var>version</var></tt>
350             statements must specify a dependency on
351             <package>perl</package> or <package>perl-base</package> with
352             the minimum required version, or more simply the current
353             version.
354           </p>
355         </sect1>
356
357         <sect1 id="binary_modules">
358           <heading>Binary Modules</heading>
359           <p>
360             Binary modules must specify a dependency on either
361             <package>perl</package> or <package>perl-base</package> with
362             a minimum version of the <package>perl</package> package
363             used to build the module, and must additionally depend on
364             the expansion of
365             <package>perlapi-$Config{debian_abi}</package> using
366             the <tt>Config</tt> module. If <tt>$Config{debian_abi}</tt>
367             is empty or not set, <tt>$Config{version}</tt> must be used.
368           </p>
369         </sect1>
370
371         <sect1 id="dh_perl">
372           <heading>Automating Perl Dependencies</heading>
373           <p>
374             Rather than hard-coding the dependencies into the control
375             file, using a substitution such as <tt>${perl:Depends}</tt>
376             is suggested.  This allows the dependencies to be determined
377             at build time and written to the <file>substvars</file> file
378             in the form
379             <tt>perl:Depends=<var>deps</var></tt>.<footnote>
380               <p>Please note that dependencies caused by versioned
381               uses and on separately packaged modules are not included
382               in this variable and must be explicitly included.</p>
383             </footnote>
384           </p>
385           <p>
386             Packages built with <prgn>debhelper</prgn> may use
387
388             <manref name="dh_perl" section="1"> to generate this
389             substitution automatically.  This additionally requires a
390             versioned <tt>Build-Depends</tt> (or
391             <tt>Build-Depends-Indep</tt>) on <tt>debhelper (>=
392             3.0.18)</tt>.
393           </p>
394         </sect1>
395       </sect>
396     </chapt>
397
398     <chapt id="programs">
399       <heading>Perl Programs</heading>
400       <sect id="hash_bang">
401         <heading>Script Magic</heading>
402         <p>
403           All packaged perl programs must start with
404           <tt>#!/usr/bin/perl</tt> and may append such flags as are
405           required.
406         </p>
407       </sect>
408
409       <sect id="program_deps">
410         <heading>Program Dependencies</heading>
411         <p>
412           Programs which require <var>core</var> modules from the
413           <package>perl</package> package must specify a dependency on
414           that package.
415         </p>
416         <p>
417           Programs which contain explicit <tt>require
418           <var>version</var></tt> or <tt>use <var>version</var></tt>
419           statements must specify a dependency on
420           <package>perl</package> or <package>perl-base</package> with
421           the minimum required version, or more simply the current
422           version.
423         </p>
424         <p>
425           As with modules, packages using <prgn>debhelper</prgn> may use
426           <manref name="dh_perl" section="1"> to automatically generate
427           dependences (see <ref id="dh_perl">).
428         </p>
429       </sect>
430     </chapt>
431
432     <chapt id="embed">
433       <heading>Programs Embedding Perl</heading>
434       <sect id="build_embedded">
435         <heading>Building Embedded Programs</heading>
436         <p>
437           Programs which embed a perl interpreter must declare a
438           <tt>Build-Depends</tt> on <package>libperl-dev</package>.
439         </p>
440         <p>
441           The default linker options produced by
442           <example>
443 perl -MExtUtils::Embed -e ldopts
444           </example>
445           will link against the dynamic <tt>libperl</tt>.  If programs
446           wish to link to the static library, then <tt>-lperl</tt>
447           should be changed to <file>/usr/lib/libperl.a</file> in those
448           options.
449         </p>
450       </sect>
451
452       <sect id="embedded_deps">
453         <heading>Embedded Perl Dependencies</heading>
454         <p>
455           Dependencies for programs linking against the shared Perl
456           library will be automatically created by
457           <prgn>dpkg-shlibdeps</prgn>.  Note however that the shared
458           perl library package only suggests
459           <package>perl-base</package> and packages requiring any
460           <var>core</var> modules from the <package>perl</package>
461           package must depend upon it explicitly.
462         </p>
463       </sect>
464     </chapt>
465
466     <appendix id="perl6">
467       <heading>Perl 6</heading>
468       <p>
469         The current stable upstream version at the time of this writing
470         is 5.6.0.  There is currently work in progress on the next major
471         revision, although the specifications have yet to be finalised.
472       </p>
473       <p>
474         It is anticipated that when Perl 6 is released it will initially
475         be packaged as <package>perl6</package>, install the binary as
476         <file>/usr/bin/perl6</file> and use different directories for
477         packaged modules to <package>perl</package>:
478         <example>
479 /usr/lib/perl6
480 /usr/share/perl6
481         </example>
482         This will allow Perl 5 and 6 packages and modules (which should
483         be packaged as <package>libfoo-bar-perl6</package>), to co-exist
484         for as long as required.
485       </p>
486       <p>
487         At some stage in the future when Perl 6 is sufficiently mature,
488         the package naming may be reversed such that the
489         <package>perl</package> package contains Perl 6 and the current
490         package becomes <package>perl5</package>.
491       </p>
492     </appendix>
493   </book>
494 </debiandoc>
495 <!-- Local variables: -->
496 <!-- indent-tabs-mode: t -->
497 <!-- End: -->