Perl policy / dh_perlcheck
Hi,
I've slightly updated the perl policy in order to enable some good things
like automatic detection of the good perl dependency and like beeing able
to recompile for another perl with a line like this one :
PERL=perl-5.004 debian/rules binary
I've also added the INSTALLARCHLIB path in the Makefile.PL options since
otherwise it's derived from INSTALLPRIVLIB (by adding the archname) and
that will generate a bad path /usr/lib/perl5/$archname/ ...
In order to simplify the detection of the perl dependency I've written
a dh_perlcheck perl script that will be included in debhelper.
Any comments are welcomed,
--
Hertzog Raphaël >> 0C4CABF1 >> http://prope.insa-lyon.fr/~rhertzog/
<!doctype debiandoc system>
<book>
<title>Debian Perl policy
<author><name/Raphaël Hertzog/ <email/hertzog@debian.org/
<version>1.0
<abstract>
This document explains how perl stuff is packaged within Debian.
<copyright>Copyright 1999 by the Debian Project
<p>
This manual is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
A copy of the GNU General Public License is available as /usr/doc/copyright/GPL in the Debian GNU/Linux distribution.
<toc>
<chapt>General view of perl stuff on a Debian system
<p>Debian has decided to enable developers to have more than one perl on
their system. You can have perl-5.004 and perl-5.005. However only one version
of perl will be officially blessed at a time. This official version should
be used to build all perl modules. The current policy is to bless the more
recent perl available in Debian. The official perl will always be available
under /usr/bin/perl. Older perls will be available as /usr/bin/perl-$version.
<p>This choice has many consequences on how modules and perl itself are
packaged. You'll find all the details in the following chapters.
<chapt>How perl itself is packaged
<p>Each perl-$version source package will build at least
perl-$version-base, perl-$version, perl-$version-doc,
perl-$version-suid and perl-$version-debug.
<p>You can also have things like perl-$version-thread or
perl-$version-libperl (or libperl-$version) depending
on the perl version and on the motivation of the perl
maintainer. :-)
<p>As perl-5.004 and perl-5.005 may be installed at the same time,
the files must be installed in versionned directories so that one package
does not overwrite the other's files. But they should cooperate so that
the man page refers to the good version of perl (/usr/bin/perl) and so that
/usr/bin/perl will always be the latest perl.
<p>Perl should always look for modules in /usr/lib/perl5 as it's the
standard directory used for installing non-binary perl modules.
<sect>perl-$version-base
<p>A Debian system must always have a working /usr/bin/perl as it's used
by postinsts and by numerous scripts called from postints like
adduser, update-alternatives and so on.
<p>To achieve this goal, a perl-$version-base package must
always be installed. That's the reason why the fake package perl-base
is essential and depends on perl5-base that is provided by all
perl-$version-base packages.
<sect>perl-$version
<p>This is the standard perl package containing all the modules
shipped with the perl sources. It should provide perl5 so that
perl scripts do not need to worry about which perl-$version is the
current one. It does depend on perl-$version-base as it does not
provide the perl binary.
<chapt>Packaging perl modules
<sect>Recommendations for all modules
<p>First, if you package a module Foo::Bar you should call your
package libfoo-bar-perl.
<p>In order to configure your perl module you can use something like this :
<p>At the top of debian/rules :
<example>
ifndef PERL
PERL = /usr/bin/perl
endif
TMP =`pwd`/debian/tmp
archlib =`$(PERL) -MConfig -e 'print $$Config{installarchlib}'`
config =INSTALLDIRS=perl INSTALLMAN1DIR=$(TMP)/usr/man/man1 INSTALLMAN3DIR=$(TMP)/usr/man/man3 INSTALLPRIVLIB=$(TMP)/usr/lib/perl5 INSTALLARCHLIB=$(TMP)$(archlib)
</example>
And in the build target :
<example>
$(PERL) Makefile.PL $(config)
make CFLAGS="-O2 -g -Wall"
</example>
<p>And for installing the module in the tree :
<p><example>
make pure_install
</example>
<p>Be sure to remove .packlist file installed automatically. You can
add those lines for example :
<p><example>
find `pwd`/debian/tmp -type f -name .packlist | xargs -r rm -f
find `pwd`/debian/tmp -type d -empty | xargs -r rmdir -p --no-fail-on-non-empty
</example>
<sect1>Managing perl dependencies automatically
<p>As you may have noticed, we do not have hardcored any specific
perl version in the build process but the package may have to
depend on a specific perl version (generally the version that has been
used to build it). In order to never hardcore any perl version, we'll
try to use a substitution. Instead to write "perl-5.005" or "perl5"
in the control file we'll use "${perl:Depends}" and the build process
will add a line "perl:Depends=what_is_needeed" to the substvars file.
<p>In order to generate this substitution you can use dh_perlcheck
that is provided with debhelper. Or you can manage that yourself
by adding the good lines in your rules file.
<p>If you want to know the version of perl that you're currently
using for the build you can use something like that :
<p><example>
version = `$(PERL) -e 'printf "%.3f", $$]'`
</example>
<sect>Non-binary perl modules
<p>They must be installed in /usr/lib/perl5 and must depend on perl5.
<sect>Binary perl modules
<p>They must be installed in /usr/lib/perl/$version/$arch-linux and
must depend on perl-$version.
<p>You may want to provide a threaded version of the module which will
be installed in /usr/lib/perl5/$version/$arch-linux-thread. You
can provide the threaded module in the same package or in another
package called libfoo-bar-perl-thread.
<p>The binary modules must always be built with the latest perl
available in Debian. You can build the module for an older version of perl
but in that case you must call the module package accordingly by
specifying the perl version at the end of the package name
(ie libfoo-bar-perl-5.004).
<chapt>Packaging perl scripts
<p>This is very simple, perl scripts should always use /usr/bin/perl
and should depend on perl5. At the present time you cannot setup
a versionned dependency on perl5 as dpkg doesn't support this.
However you can be sure that perl5 is >= 5.004.05. If you really
need to make sure that you have perl5.005 then you should depend
on perl-5.005 (and here you can use a versionned dependency). But
you'll have to update your dependency when perl-5.006 comes out
and so on, so it's not very convenient.
<p>Take care to include any dependency on a perl module as they are
not automatically detected by the standard tools like the libraries
are. Lintian may warn you about such problems.
<p>If the script does have very special needs such as a specific version
of perl then you'll need to use #!/usr/bin/perl-5.004 (I take 5.004 as
an example but you should replace 5.004 by whatever old version of perl
you are needing) and you'll need to add a dependency to perl-5.004. If
it does furthermore request some binary modules then you'll need to
package thoses modules especially for perl-5.004 instead of
the latest perl (beeing perl-5.005 or whatever else). Those
modules packaged for old perls will have to add the perl version
in their package name. For a module Foo::Bar, instead of calling
the package libfoo-bar-perl you'll have to call it
libfoo-bar-perl-5.004.
</book>
Debian Perl policy
------------------
Raphaël Hertzog <hertzog@debian.org>
1.0
-------------------------------------------------------------------------------
Résumé
------
This document explains how perl stuff is packaged within Debian.
Copyright
---------
Copyright 1999 by the Debian Project
This manual is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version. This is distributed in the hope that it
will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details. A copy of the GNU
General Public License is available as /usr/doc/copyright/GPL in the
Debian GNU/Linux distribution.
-------------------------------------------------------------------------------
Table des matières
------------------
1. General view of perl stuff on a Debian system
2. How perl itself is packaged
2.1. perl-$version-base
2.2. perl-$version
3. Packaging perl modules
3.1. Recommendations for all modules
3.2. Non-binary perl modules
3.3. Binary perl modules
4. Packaging perl scripts
-------------------------------------------------------------------------------
1. General view of perl stuff on a Debian system
------------------------------------------------
Debian has decided to enable developers to have more than one perl on
their system. You can have perl-5.004 and perl-5.005. However only one
version of perl will be officially blessed at a time. This official
version should be used to build all perl modules. The current policy
is to bless the more recent perl available in Debian. The official
perl will always be available under /usr/bin/perl. Older perls will be
available as /usr/bin/perl-$version.
This choice has many consequences on how modules and perl itself are
packaged. You'll find all the details in the following chapters.
-------------------------------------------------------------------------------
2. How perl itself is packaged
------------------------------
Each perl-$version source package will build at least
perl-$version-base, perl-$version, perl-$version-doc,
perl-$version-suid and perl-$version-debug.
You can also have things like perl-$version-thread or
perl-$version-libperl (or libperl-$version) depending on the perl
version and on the motivation of the perl maintainer. :-)
As perl-5.004 and perl-5.005 may be installed at the same time, the
files must be installed in versionned directories so that one package
does not overwrite the other's files. But they should cooperate so
that the man page refers to the good version of perl (/usr/bin/perl)
and so that /usr/bin/perl will always be the latest perl.
Perl should always look for modules in /usr/lib/perl5 as it's the
standard directory used for installing non-binary perl modules.
2.1. perl-$version-base
-----------------------
A Debian system must always have a working /usr/bin/perl as it's used
by postinsts and by numerous scripts called from postints like
adduser, update-alternatives and so on.
To achieve this goal, a perl-$version-base package must always be
installed. That's the reason why the fake package perl-base is
essential and depends on perl5-base that is provided by all
perl-$version-base packages.
2.2. perl-$version
------------------
This is the standard perl package containing all the modules shipped
with the perl sources. It should provide perl5 so that perl scripts do
not need to worry about which perl-$version is the current one. It
does depend on perl-$version-base as it does not provide the perl
binary.
-------------------------------------------------------------------------------
3. Packaging perl modules
-------------------------
3.1. Recommendations for all modules
------------------------------------
First, if you package a module Foo::Bar you should call your package
libfoo-bar-perl.
In order to configure your perl module you can use something like this
:
At the top of debian/rules :
ifndef PERL
PERL = /usr/bin/perl
endif
TMP =`pwd`/debian/tmp
archlib =`$(PERL) -MConfig -e 'print $$Config{installarchlib}'`
config =INSTALLDIRS=perl INSTALLMAN1DIR=$(TMP)/usr/man/man1 INSTALLMAN3DIR=$(TMP)/usr/man/man3 INSTALLPRIVLIB=$(TMP)/usr/lib/perl5 INSTALLARCHLIB=$(TMP)$(archlib)
And in the build target :
$(PERL) Makefile.PL $(config)
make CFLAGS="-O2 -g -Wall"
And for installing the module in the tree :
make pure_install
Be sure to remove .packlist file installed automatically. You can add
those lines for example :
find `pwd`/debian/tmp -type f -name .packlist | xargs -r rm -f
find `pwd`/debian/tmp -type d -empty | xargs -r rmdir -p --no-fail-on-non-empty
3.1.1. Managing perl dependencies automatically
-----------------------------------------------
As you may have noticed, we do not have hardcored any specific perl
version in the build process but the package may have to depend on a
specific perl version (generally the version that has been used to
build it). In order to never hardcore any perl version, we'll try to
use a substitution. Instead to write "perl-5.005" or "perl5" in the
control file we'll use "${perl:Depends}" and the build process will
add a line "perl:Depends=what_is_needeed" to the substvars file.
In order to generate this substitution you can use dh_perlcheck that
is provided with debhelper. Or you can manage that yourself by adding
the good lines in your rules file.
If you want to know the version of perl that you're currently using
for the build you can use something like that :
version = `$(PERL) -e 'printf "%.3f", $$]'`
3.2. Non-binary perl modules
----------------------------
They must be installed in /usr/lib/perl5 and must depend on perl5.
3.3. Binary perl modules
------------------------
They must be installed in /usr/lib/perl/$version/$arch-linux and must
depend on perl-$version.
You may want to provide a threaded version of the module which will be
installed in /usr/lib/perl5/$version/$arch-linux-thread. You can
provide the threaded module in the same package or in another package
called libfoo-bar-perl-thread.
The binary modules must always be built with the latest perl available
in Debian. You can build the module for an older version of perl but
in that case you must call the module package accordingly by
specifying the perl version at the end of the package name (ie
libfoo-bar-perl-5.004).
-------------------------------------------------------------------------------
4. Packaging perl scripts
-------------------------
This is very simple, perl scripts should always use /usr/bin/perl and
should depend on perl5. At the present time you cannot setup a
versionned dependency on perl5 as dpkg doesn't support this. However
you can be sure that perl5 is >= 5.004.05. If you really need to make
sure that you have perl5.005 then you should depend on perl-5.005 (and
here you can use a versionned dependency). But you'll have to update
your dependency when perl-5.006 comes out and so on, so it's not very
convenient.
Take care to include any dependency on a perl module as they are not
automatically detected by the standard tools like the libraries are.
Lintian may warn you about such problems.
If the script does have very special needs such as a specific version
of perl then you'll need to use #!/usr/bin/perl-5.004 (I take 5.004 as
an example but you should replace 5.004 by whatever old version of
perl you are needing) and you'll need to add a dependency to
perl-5.004. If it does furthermore request some binary modules then
you'll need to package thoses modules especially for perl-5.004
instead of the latest perl (beeing perl-5.005 or whatever else). Those
modules packaged for old perls will have to add the perl version in
their package name. For a module Foo::Bar, instead of calling the
package libfoo-bar-perl you'll have to call it libfoo-bar-perl-5.004.
-------------------------------------------------------------------------------
Debian Perl policy
Raphaël Hertzog <hertzog@debian.org>
1.0
#!/usr/bin/perl -w
#
# Find dependencies on perl stuff
# Possible extensions :
# - check for require 5.00X to know if we need to depend on a specific perl
# - check for #!/usr/bin/perl-5.00X
BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
use Dh_Lib;
init();
my $perl = $ENV{'PERL'} || '/usr/bin/perl';
my $version = `$perl -e 'printf "%.3f", \$]'`;
verbose_print("Package compiled with perl-$version ($perl) !");
foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
$TMP=tmpdir($PACKAGE);
$EXT=pkgext($PACKAGE);
my ($file, $v, $arch);
my $dep_arch = '';
my $dep = '';
my $found = 0;
foreach $file (split(/\n/,`find $TMP -type f -name "*.pm"`)) {
if ($file =~ m<^$TMP/usr/lib/perl5/(\d\.\d{3})/([^/]+)/>) {
$found++;
$v = $1;
$arch = $2;
print STDERR "WARNING: a module has been found " .
"in perl-$v arch directory. \n But " .
"perl-$version is the perl currently used ...\n"
unless ($v eq $version);
$v .= '-thread' if ($arch =~ /-thread/);
if (not $dep_arch) {
$dep_arch = "perl-$v";
} else {
$dep_arch .= ", perl-$v"
unless ($dep_arch =~ /perl-$v/);
}
} elsif ($file =~ m<^$TMP/usr/lib/perl5/>) {
$found++;
}
}
if ($found and not $dep_arch) {
$dep = "perl5";
} elsif ($dep_arch) {
$dep = $dep_arch;
}
next if not $dep;
if (-e "debian/$EXT\subtsvars") {
system('perl -i -ne "print $_ unless /^perl:Depends=/;"'
.' debian/' . $EXT . 'substvars');
open (S, ">>debian/$EXT\substvars") || die "$!";
} else {
open (S, ">debian/$EXT\substvars") || die "$!";
}
print S "perl:Depends=$dep\n";
close S;
}
Reply to: