5 dh_perl - calculates Perl dependencies and cleans up after MakeMaker
12 use Debian::Debhelper::Dh_Lib;
16 B<dh_perl> [S<I<debhelper options>>] [B<-d>] [S<I<library dirs> ...>]
20 B<dh_perl> is a debhelper program that is responsible for generating
21 the B<${perl:Depends}> substitutions and adding them to substvars files.
23 The program will look at Perl scripts and modules in your package,
24 and will use this information to generate a dependency on B<perl> or
25 B<perlapi>. The dependency will be substituted into your package's F<control>
26 file wherever you place the token B<${perl:Depends}>.
28 B<dh_perl> also cleans up empty directories that MakeMaker can generate when
29 installing Perl modules.
37 In some specific cases you may want to depend on B<perl-base> rather than the
38 full B<perl> package. If so, you can pass the -d option to make B<dh_perl> generate
39 a dependency on the correct base package. This is only necessary for some
40 packages that are included in the base system.
42 Note that this flag may cause no dependency on B<perl-base> to be generated at
43 all. B<perl-base> is Essential, so its dependency can be left out, unless a
44 versioned dependency is needed.
48 By default, scripts and architecture independent modules don't depend
49 on any specific version of B<perl>. The B<-V> option causes the current
50 version of the B<perl> (or B<perl-base> with B<-d>) package to be specified.
54 If your package installs Perl modules in non-standard
55 directories, you can make B<dh_perl> check those directories by passing their
56 names on the command line. It will only check the F<vendorlib> and F<vendorarch>
57 directories by default.
63 Debian policy, version 3.8.3
65 Perl policy, version 1.20
71 my $vendorlib = substr $Config{vendorlib}, 1;
72 my $vendorarch = substr $Config{vendorarch}, 1;
74 # Cleaning the paths given on the command line
81 # If -d is given, then the dependency is on perl-base rather than perl.
82 $perl .= '-base' if $dh{D_FLAG};
86 use constant PROGRAM => 1;
87 use constant PM_MODULE => 2;
88 use constant XS_MODULE => 4;
90 foreach my $package (@{$dh{DOPACKAGES}}) {
91 my $tmp=tmpdir($package);
93 # Check also for alternate locations given on the command line
94 my @dirs = grep -d, map "$tmp/$_", $vendorlib, $vendorarch, @ARGV;
96 # Look for perl modules and check where they are installed
100 $deps |= PM_MODULE if /\.pm$/;
101 $deps |= XS_MODULE if /\.so$/;
106 return unless -f and (-x or /\.pl$/);
107 return if $File::Find::dir=~/\/usr\/share\/doc\//;
110 return unless open F, $_;
111 if (read F, local $_, 32 and m%^#!\s*(/usr/bin/perl|/usr/bin/env\s+perl)\s%) {
119 if ($deps & XS_MODULE or $dh{V_FLAG_SET}) {
120 ($version) = `dpkg -s $perl` =~ /^Version:\s*(\S+)/m
122 $version = ">= $version";
125 # no need to depend on an un-versioned perl-base -- it's
127 addsubstvar($package, "perl:Depends", $perl, $version)
128 unless $perl eq 'perl-base' && ! length($version);
130 # add perlapi-<ver> for XS modules
131 addsubstvar($package, "perl:Depends",
132 "perlapi-" . ($Config{debian_abi} || $Config{version}))
133 if $deps & XS_MODULE;
136 # MakeMaker always makes lib and share dirs, but typically
137 # only one directory is installed into.
138 foreach my $dir ("$tmp/usr/share/perl5", "$tmp/usr/lib/perl5") {
140 doit("rmdir", "--ignore-fail-on-non-empty", "--parents",
150 This program is a part of debhelper.
154 Brendan O'Dea <bod@debian.org>