]> git.donarmstrong.com Git - debhelper.git/blob - dh_makeshlibs
r433: this is getting *so* boring.
[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 =back
72
73 =head1 NOTES
74
75 There is no guarantee that the program will get the shlibs file right. For
76 example, it may not correctly guess the major number of your package. In
77 cases like these (and perhaps in general, just to be safe), it is better to
78 create a debian/shlibs file by hand, or force it to use the correct major
79 number by specifying the -m parameter.
80
81 =cut
82
83 init();
84
85 foreach my $package (@{$dh{DOPACKAGES}}) {
86         my $tmp=tmpdir($package);
87
88         my %seen;
89         my $need_ldconfig = 0;
90
91         doit("rm", "-f", "$tmp/DEBIAN/shlibs");
92
93         open (FIND, "find $tmp -xtype f -name '*.so*' |");
94         while (<FIND>) {
95                 my $library;
96                 my $major;
97         
98                 chomp;
99                 $need_ldconfig=1;
100                 # The second evil regexp is for db3, whose author should
101                 # be shot.
102                 if (m#.*/([^/]*)\.so\.(\d*)\.?# || m#.*/([^/]*)-([^\s/]+)\.so$#) {
103                         $library = $1;
104                         $major = $2;
105                 }
106                 if (defined($dh{M_PARAMS}) && $dh{M_PARAMS} ne '') {
107                         $major=$dh{M_PARAMS};
108                 }
109                 if (! -d "$tmp/DEBIAN") {
110                         doit("install","-d","$tmp/DEBIAN");
111                 }
112                 my $deps=$package;
113                 if ($dh{V_FLAG_SET}) {
114                         if ($dh{V_FLAG} ne '') {
115                                 $deps=$dh{V_FLAG};
116                         }       
117                         else {
118                                 # Call isnative becuase it sets $dh{VERSION}
119                                 # as a side effect.
120                                 isnative($package);
121                                 $deps="$package (>= $dh{VERSION})";
122                         }
123                 }
124                 if (defined($library) && defined($major) && defined($deps) &&
125                     $library ne '' && $major ne '' && $deps ne '') {
126                         # Prevent duplicate lines from entering the file.
127                         my $line="$library $major $deps";
128                         if (! $seen{$line}) {
129                                 $seen{$line}=1;
130                                 complex_doit("echo '$line' >>$tmp/DEBIAN/shlibs");
131                         }
132                 }
133         }
134         close FIND;
135
136         # New as of dh_v3.
137         if (! compat(2) && ! $dh{NOSCRIPTS} && $need_ldconfig) {
138                 autoscript($package,"postinst","postinst-makeshlibs");
139                 autoscript($package,"postrm","postrm-makeshlibs");
140         }
141
142         if (-e "$tmp/DEBIAN/shlibs") {
143                 doit("chmod",644,"$tmp/DEBIAN/shlibs");
144                 doit("chown","0.0","$tmp/DEBIAN/shlibs");
145         }
146 }
147
148 =head1 SEE ALSO
149
150 L<debhelper(1)>
151
152 This program is a part of debhelper.
153
154 =head1 AUTHOR
155
156 Joey Hess <joeyh@debian.org>
157
158 =cut