]> git.donarmstrong.com Git - debhelper.git/blob - dh_makeshlibs
r441: * Added dh_installman, a new program that replaces dh_installmanpages.
[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 from the
31 filename of the library, use the major number specified after the -m parameter.
32
33 =item B<-V>, B<-V>I<dependancies>
34
35 =item B<--version-info>, B<--version-info=>I<dependancies>
36
37 By default, the shlibs file generated by this program does not make packages
38 depend on any particular version of the package containing the shared
39 library. It may be necessary for you to add some version dependancy
40 information to the shlibs file. If -V is specified with no dependancy
41 information, the current version of the package is plugged into a
42 dependancy that looks like "packagename (>= packageversion)". If -V is specified with
43 parameters, the parameters can be used to specify the exact dependancy
44 information needed (be sure to include the package name).
45
46 =item B<-n>, B<--noscripts>
47
48 Do not modify postinst/postrm scripts.
49
50 =back
51
52 =head1 EXAMPLES
53
54  dh_makeshlibs
55
56 Assuming this is a package named libfoobar1, generates a shlibs file that
57 looks something like:
58  libfoobar 1 libfoobar1
59
60  dh_makeshlibs -V
61
62 Assuming the current version of the package is 1.0-3, generates a shlibs
63 file that looks something like:
64  libfoobar 1 libfoobar1 (>= 1.0-3)
65
66  dh_makeshlibs -V 'libfoobar1 (>= 1.0)'
67
68 Generates a shlibs file that looks something like:
69   libfoobar 1 libfoobar1 (>= 1.0)
70
71 =head1 NOTES
72
73 There is no guarantee that the program will get the shlibs file right. For
74 example, it may not correctly guess the major number of your package. In
75 cases like these (and perhaps in general, just to be safe), it is better to
76 create a debian/shlibs file by hand, or force it to use the correct major
77 number by specifying the -m parameter.
78
79 =cut
80
81 init();
82
83 foreach my $package (@{$dh{DOPACKAGES}}) {
84         my $tmp=tmpdir($package);
85
86         my %seen;
87         my $need_ldconfig = 0;
88
89         doit("rm", "-f", "$tmp/DEBIAN/shlibs");
90
91         open (FIND, "find $tmp -xtype f -name '*.so*' |");
92         while (<FIND>) {
93                 my $library;
94                 my $major;
95         
96                 chomp;
97                 $need_ldconfig=1;
98                 # The second evil regexp is for db3, whose author should
99                 # be shot.
100                 if (m#.*/([^/]*)\.so\.(\d*)\.?# || m#.*/([^/]*)-([^\s/]+)\.so$#) {
101                         $library = $1;
102                         $major = $2;
103                 }
104                 if (defined($dh{M_PARAMS}) && $dh{M_PARAMS} ne '') {
105                         $major=$dh{M_PARAMS};
106                 }
107                 if (! -d "$tmp/DEBIAN") {
108                         doit("install","-d","$tmp/DEBIAN");
109                 }
110                 my $deps=$package;
111                 if ($dh{V_FLAG_SET}) {
112                         if ($dh{V_FLAG} ne '') {
113                                 $deps=$dh{V_FLAG};
114                         }       
115                         else {
116                                 # Call isnative becuase it sets $dh{VERSION}
117                                 # as a side effect.
118                                 isnative($package);
119                                 $deps="$package (>= $dh{VERSION})";
120                         }
121                 }
122                 if (defined($library) && defined($major) && defined($deps) &&
123                     $library ne '' && $major ne '' && $deps ne '') {
124                         # Prevent duplicate lines from entering the file.
125                         my $line="$library $major $deps";
126                         if (! $seen{$line}) {
127                                 $seen{$line}=1;
128                                 complex_doit("echo '$line' >>$tmp/DEBIAN/shlibs");
129                         }
130                 }
131         }
132         close FIND;
133
134         # New as of dh_v3.
135         if (! compat(2) && ! $dh{NOSCRIPTS} && $need_ldconfig) {
136                 autoscript($package,"postinst","postinst-makeshlibs");
137                 autoscript($package,"postrm","postrm-makeshlibs");
138         }
139
140         if (-e "$tmp/DEBIAN/shlibs") {
141                 doit("chmod",644,"$tmp/DEBIAN/shlibs");
142                 doit("chown","0.0","$tmp/DEBIAN/shlibs");
143         }
144 }
145
146 =head1 SEE ALSO
147
148 L<debhelper(1)>
149
150 This program is a part of debhelper.
151
152 =head1 AUTHOR
153
154 Joey Hess <joeyh@debian.org>
155
156 =cut