]> git.donarmstrong.com Git - debhelper.git/blob - dh_makeshlibs
r450: * Modified to use dpkg-architecture instead of dpkg --print-architecture.
[debhelper.git] / dh_makeshlibs
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_makeshlibs - automatically create shlibs file
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14   dh_makeshlibs [debhelper options] [-mmajor] [-V[dependancies]] [-n]
15
16 =head1 DESCRIPTION
17
18 dh_makeshlibs is a debhelper program that automatically scans for shared
19 libraries, and generates a shlibs file for the libraries it finds.
20
21 It also adds a call to ldconfig in the postinst and postrm scripts (in
22 DH_COMPAT=3 mode and above only).
23
24 =head1 OPTIONS
25
26 =over 4
27
28 =item B<-m>I<major>, B<--major=>I<major>
29
30 Instead of trying to guess the major number of the library with objdump,
31 use the major number specified after the -m parameter. This is much less
32 useful than it used to be, back in the bad old days when this program
33 looked at library filenames rather than using objdump.
34
35 =item B<-V>, B<-V>I<dependancies>
36
37 =item B<--version-info>, B<--version-info=>I<dependancies>
38
39 By default, the shlibs file generated by this program does not make packages
40 depend on any particular version of the package containing the shared
41 library. It may be necessary for you to add some version dependancy
42 information to the shlibs file. If -V is specified with no dependancy
43 information, the current version of the package is plugged into a
44 dependancy that looks like "packagename (>= packageversion)". If -V is specified with
45 parameters, the parameters can be used to specify the exact dependancy
46 information needed (be sure to include the package name).
47
48 =item B<-n>, B<--noscripts>
49
50 Do not modify postinst/postrm scripts.
51
52 =back
53
54 =head1 EXAMPLES
55
56  dh_makeshlibs
57
58 Assuming this is a package named libfoobar1, generates a shlibs file that
59 looks something like:
60  libfoobar 1 libfoobar1
61
62  dh_makeshlibs -V
63
64 Assuming the current version of the package is 1.0-3, generates a shlibs
65 file that looks something like:
66  libfoobar 1 libfoobar1 (>= 1.0-3)
67
68  dh_makeshlibs -V 'libfoobar1 (>= 1.0)'
69
70 Generates a shlibs file that looks something like:
71   libfoobar 1 libfoobar1 (>= 1.0)
72
73 =cut
74
75 init();
76
77 foreach my $package (@{$dh{DOPACKAGES}}) {
78         my $tmp=tmpdir($package);
79
80         my %seen;
81         my $need_ldconfig = 0;
82
83         doit("rm", "-f", "$tmp/DEBIAN/shlibs");
84
85         open (FIND, "find $tmp -xtype f -name '*.so*' |");
86         while (<FIND>) {
87                 my ($library, $major) = 
88                         `objdump -p $_` =~ m/\s+SONAME\s+(.+)\.so\.(.+)/;
89
90                 if (defined($dh{M_PARAMS}) && $dh{M_PARAMS} ne '') {
91                         $major=$dh{M_PARAMS};
92                 }
93                 
94                 if (! -d "$tmp/DEBIAN") {
95                         doit("install","-d","$tmp/DEBIAN");
96                 }
97                 my $deps=$package;
98                 if ($dh{V_FLAG_SET}) {
99                         if ($dh{V_FLAG} ne '') {
100                                 $deps=$dh{V_FLAG};
101                         }       
102                         else {
103                                 # Call isnative becuase it sets $dh{VERSION}
104                                 # as a side effect.
105                                 isnative($package);
106                                 $deps="$package (>= $dh{VERSION})";
107                         }
108                 }
109                 if (defined($library) && defined($major) && defined($deps) &&
110                     $library ne '' && $major ne '' && $deps ne '') {
111                         $need_ldconfig=1;
112                         # Prevent duplicate lines from entering the file.
113                         my $line="$library $major $deps";
114                         if (! $seen{$line}) {
115                                 $seen{$line}=1;
116                                 complex_doit("echo '$line' >>$tmp/DEBIAN/shlibs");
117                         }
118                 }
119         }
120         close FIND;
121
122         # New as of dh_v3.
123         if (! compat(2) && ! $dh{NOSCRIPTS} && $need_ldconfig) {
124                 autoscript($package,"postinst","postinst-makeshlibs");
125                 autoscript($package,"postrm","postrm-makeshlibs");
126         }
127
128         if (-e "$tmp/DEBIAN/shlibs") {
129                 doit("chmod",644,"$tmp/DEBIAN/shlibs");
130                 doit("chown","0.0","$tmp/DEBIAN/shlibs");
131         }
132 }
133
134 =head1 SEE ALSO
135
136 L<debhelper(1)>
137
138 This program is a part of debhelper.
139
140 =head1 AUTHOR
141
142 Joey Hess <joeyh@debian.org>
143
144 =cut