5 dh_perl - calculates perl dependencies
12 use Debian::Debhelper::Dh_Lib;
16 B<dh_perl> [S<I<debhelper options>>] [B<-d>] [S<I<library dirs ...>>]
20 dh_perl is a debhelper program that is responsible for generating
21 the ${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 perl or
25 perlapi. The dependency will be substituted into your package's control
26 file wherever you place the token "${perl:Depends}".
34 In some specific cases you may want to depend on perl-base rather than the
35 full perl package. If so, you can pass the -d option to make dh_perl generate
36 a dependency on the correct base package. This is only necessary for some
37 packages that are included in the base system.
41 By default, scripts and architecture independent modules don't depend
42 on any specific version of perl. The -V option causes the current
43 version of the perl (or perl-base with -d) package to be specified.
47 If your package installs perl modules in non-standard
48 directories, you can make dh_perl check those directories by passing their
49 names on the command line. It will only check the vendorlib and vendorarch
50 directories by default.
56 Debian policy, version 3.0.1
58 Perl policy, version 1.18
64 my $vendorlib = substr $Config{vendorlib}, 1;
65 my $vendorarch = substr $Config{vendorarch}, 1;
67 # the installation dir for arch-indep modules changed to
68 # /usr/share/perl5 in this version:
69 my $min_version = '5.6.0-16';
71 # Cleaning the paths given on the command line
78 # If -d is given, then the dependency is on perl-base rather than perl.
79 $perl .= '-base' if $dh{D_FLAG};
83 use constant PROGRAM => 1;
84 use constant PM_MODULE => 2;
85 use constant XS_MODULE => 4;
87 foreach my $package (@{$dh{DOPACKAGES}}) {
88 my $tmp = tmpdir($package);
89 my $ext = pkgext($package);
91 delsubstvar($package, "perl:Depends"); # for idempotency
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$/);
108 return unless open F, $_;
109 if (read F, local $_, 32 and m%^#!\s*(/usr/bin/perl|/usr/bin/env\s+perl)\s%) {
117 if ($deps & XS_MODULE or $dh{V_FLAG_SET}) {
118 ($version) = `dpkg -s $perl` =~ /^Version:\s*(\S+)/m
120 $version = ">= $version";
122 elsif ($deps & PM_MODULE) {
123 $version = ">= $min_version";
126 # no need to depend on an un-versioned perl-base -- it's
128 addsubstvar($package, "perl:Depends", $perl, $version)
129 unless $perl eq 'perl-base' && ! length($version);
131 # add perlapi-<ver> for XS modules
132 addsubstvar($package, "perl:Depends", "perlapi-$Config{version}")
133 if $deps & XS_MODULE;
141 This program is a part of debhelper.
145 Brendan O'Dea <bod@debian.org>