perl-policy.sgml 19 KB

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