5 dh_perl - calculates perl scripts & modules dependencies
12 use Debian::Debhelper::Dh_Lib;
16 dh_perl [debhelper options] [-d] [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.
25 The dependancy will be substituted into your package's control file
26 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.15
64 my $vendorlib = substr $Config{vendorlib}, 1;
65 my $vendorarch = substr $Config{vendorarch}, 1;
67 # Cleaning the paths given on the command line
74 # If -d is given, then the dependency is on perl-base rather than perl.
75 $perl .= '-base' if $dh{D_FLAG};
79 use constant PROGRAM => 1;
80 use constant PM_MODULE => 2;
81 use constant XS_MODULE => 4;
83 foreach my $package (@{$dh{DOPACKAGES}}) {
84 my $tmp = tmpdir($package);
85 my $ext = pkgext($package);
87 # Check also for alternate locations given on the command line
88 my @dirs = grep -d, map "$tmp/$_", $vendorlib, $vendorarch, @ARGV;
90 # Look for perl modules and check where they are installed
94 $deps |= PM_MODULE if /\.pm$/;
95 $deps |= XS_MODULE if /\.so$/;
100 return unless -f and (-x or /\.pl$/);
102 return unless open F, $_;
103 if (read F, local $_, 32 and m%^#!\s*/usr/bin/perl\s%)
113 my $perl_depends = $perl;
114 if ($deps & XS_MODULE or $dh{V_FLAG_SET})
116 ($version) = `dpkg -s $perl` =~ /^Version:\s*(\S+)/m
119 $perl_depends .= " (>= $version)";
122 # add perlapi-<ver> for XS modules
123 $perl_depends .= ", perlapi-$Config{version}"
124 if $deps & XS_MODULE;
126 # don't need to depend on an un-versioned perl-base, it's
128 next if $perl_depends eq 'perl-base';
130 if (-e "debian/${ext}substvars") {
131 open (IN, "<debian/${ext}substvars");
132 my @lines=grep { ! /^perl:Depends=/ } <IN>;
134 open (OUT, ">debian/${ext}substvars");
137 open (OUT, ">debian/${ext}substvars");
139 print OUT "perl:Depends=$perl_depends\n";
147 This program is a part of debhelper.
151 Brendan O'Dea <bod@debian.org>