5 dh_makeshlibs - automatically create shlibs file
10 use Debian::Debhelper::Dh_Lib;
14 B<dh_makeshlibs> [S<I<debhelper options>>] [B<-m>I<major>] [B<-V>I<[dependancies]>] [B<-n>] [B<-X>I<item>]
18 dh_makeshlibs is a debhelper program that automatically scans for shared
19 libraries, and generates a shlibs file for the libraries it finds.
21 It also adds a call to ldconfig in the postinst and postrm scripts (in
22 V3 mode and above only) to any packages which it finds shared libraries in.
28 =item B<-m>I<major>, B<--major=>I<major>
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.
35 =item B<-V>, B<-V>I<dependancies>
37 =item B<--version-info>, B<--version-info=>I<dependancies>
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
45 specified with parameters, the parameters can be used to specify the exact
46 dependancy information needed (be sure to include the package name).
48 Beware of using -V without any parameters; this is a conservative setting
49 that always ensures that other packages' shared library dependencies are at
50 least as tight as they need to be, so that if the maintainer screws up then
51 they won't break. The flip side is that packages might end up with
52 dependencies that are too tight and so find it harder to be upgraded.
54 =item B<-n>, B<--noscripts>
56 Do not modify postinst/postrm scripts.
58 =item B<-X>I<item>, B<--exclude=>I<item>
60 Exclude files that contain "item" anywhere in their filename from
61 being treated as shared libraries.
69 Assuming this is a package named libfoobar1, generates a shlibs file that
71 libfoobar 1 libfoobar1
75 Assuming the current version of the package is 1.0-3, generates a shlibs
76 file that looks something like:
77 libfoobar 1 libfoobar1 (>= 1.0-3)
79 dh_makeshlibs -V 'libfoobar1 (>= 1.0)'
81 Generates a shlibs file that looks something like:
82 libfoobar 1 libfoobar1 (>= 1.0)
88 foreach my $package (@{$dh{DOPACKAGES}}) {
89 my $tmp=tmpdir($package);
92 my $need_ldconfig = 0;
94 doit("rm", "-f", "$tmp/DEBIAN/shlibs");
96 # So, we look for files or links to existing files with names that
97 # match "*.so*". Matching *.so.* is not good enough because of
98 # broken crap like db3. And we only look at real files not
99 # symlinks, so we don't accidentually add shlibs data to -dev
100 # packages. This may have a few false positives, which is ok,
101 # because only if we can get a library name and a major number from
102 # objdump is anything actually added.
104 if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
105 $exclude="! \\( $dh{EXCLUDE_FIND} \\) ";
107 open (FIND, "find $tmp -type f -name '*.so*' $exclude |");
109 my ($library, $major);
110 my $objdump=`objdump -p $_`;
111 if ($objdump=~m/\s+SONAME\s+(.+)\.so\.(.+)/) {
112 # proper soname format
116 elsif ($objdump=~m/\s+SONAME\s+(.+)-(.+)\.so/) {
117 # idiotic crap soname format
122 if (defined($dh{M_PARAMS}) && $dh{M_PARAMS} ne '') {
123 $major=$dh{M_PARAMS};
126 if (! -d "$tmp/DEBIAN") {
127 doit("install","-d","$tmp/DEBIAN");
130 if ($dh{V_FLAG_SET}) {
131 if ($dh{V_FLAG} ne '') {
135 # Call isnative becuase it sets $dh{VERSION}
138 my $version = $dh{VERSION};
139 # Old compatability levels include the
140 # debian revision, while new do not.
142 # Remove debian version, if any.
143 $version =~ s/-[^-]+$//;
145 $deps="$package (>= $version)";
148 if (defined($library) && defined($major) && defined($deps) &&
149 $library ne '' && $major ne '' && $deps ne '') {
151 # Prevent duplicate lines from entering the file.
152 my $line="$library $major $deps";
153 if (! $seen{$line}) {
155 complex_doit("echo '$line' >>$tmp/DEBIAN/shlibs");
162 if (! compat(2) && ! $dh{NOSCRIPTS} && $need_ldconfig) {
163 autoscript($package,"postinst","postinst-makeshlibs");
164 autoscript($package,"postrm","postrm-makeshlibs");
167 if (-e "$tmp/DEBIAN/shlibs") {
168 doit("chmod",644,"$tmp/DEBIAN/shlibs");
169 doit("chown","0.0","$tmp/DEBIAN/shlibs");
177 This program is a part of debhelper.
181 Joey Hess <joeyh@debian.org>