]> git.donarmstrong.com Git - debhelper.git/blob - dh_shlibdeps
r462: * dh_shlibdeps: document that -l accepts multiple dirs, and
[debhelper.git] / dh_shlibdeps
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_shlibdeps - calculate shared library dependancies
6
7 =cut
8
9 use strict;
10 use Cwd;
11 use Debian::Debhelper::Dh_Lib;
12
13 =head1 SYNOPSIS
14
15   dh_shlibdeps [debhelper options] [-ldirectory] [-Xitem] [-- params]
16
17 =head1 DESCRIPTION
18
19 dh_shlibdeps is a debhelper program that is responsible for calculating
20 shared library dependancies for packages.
21
22 This program is merely a wrapper around L<dpkg-shlibdeps(1)> that calls it
23 once for each package listed in the control file, passing it
24 a list of ELF executables and shared libraries it has found.
25
26 =head1 OPTIONS
27
28 =over 4
29
30 =item B<-u>I<params>, B<--dpkg-shlibdeps-params=>I<params>
31
32 =item B<--> I<params>
33
34 Pass "params" to L<dpkg-shlibdeps(1)>.
35
36 =item B<-X>I<item>, B<--exclude=>I<item>
37
38 Exclude files that contain "item" anywhere in their filename from being
39 passed to dpkg-shlibdeps. This will make their dependancies be ignored.
40 This may be useful in some situations, but use it with caution. This option
41 may be used more than once to exclude more than one thing.
42
43 =item B<-l>I<directory>[:directory:directory:..]
44
45 Before dpkg-shlibdeps is run, LD_LIBRARY_PATH will be set to the 
46 specified directory (or directories -- separate with colons). This is
47 useful for multi-binary packages where a library is built in one
48 package and another package contains binaries linked against said
49 library. Relative paths will be made absolute for the benefit of
50 dpkg-shlibdeps.
51
52 =back
53
54 =cut
55
56 init();
57
58 foreach my $package (@{$dh{DOPACKAGES}}) {
59         my $tmp=tmpdir($package);
60         my $ext=pkgext($package);
61
62         my @filelist;
63         my $ff;
64
65         # Generate a list of ELF binaries in the package, ignoring any
66         # we were told to exclude.
67         my $find_options='';
68         if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
69                 $find_options="! \\( $dh{EXCLUDE_FIND} \\)";
70         }
71         foreach my $file (split(/\n/,`find $tmp -type f \\( -perm +111 -or -name "*.so*" \\) $find_options`)) {
72                 # TODO: this is slow, optimize. Ie, file can run once on multiple files..
73                 $ff=`file "$file"`;
74                 if ($ff=~m/ELF/ && $ff!~/statically linked/) {
75                         push @filelist,$file;
76                 }
77         }
78
79         if (@filelist) {
80                 if ($dh{L_PARAMS}) {
81                         my @paths=();
82                         foreach (split(/:/, $dh{L_PARAMS})) {
83                                 # Force the path absolute.
84                                 if (m:^/:) {
85                                         push @paths, $_;
86                                 }
87                                 else {
88                                         push @paths, getcwd()."/$_";
89                                 }
90                         }
91                         $dh{L_PARAMS}=join(':', @paths);
92                         $ENV{'LD_LIBRARY_PATH'}=$dh{L_PARAMS};
93                         verbose_print("LD_LIBRARY_PATH=$dh{L_PARAMS} \\");
94                 }
95                 doit("dpkg-shlibdeps","-Tdebian/${ext}substvars",@{$dh{U_PARAMS}},'-dDepends',@filelist);
96         }
97 }
98
99 =head1 SEE ALSO
100
101 L<debhelper(1)>
102
103 This program is a part of debhelper.
104
105 =head1 AUTHOR
106
107 Joey Hess <joeyh@debian.org>
108
109 =cut