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<[dependencies]>] [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<dependencies>
37 =item B<--version-info>, B<--version-info=>I<dependencies>
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 dependency
43 information, the current upstream version of the package is plugged into a
44 dependency that looks like "packagename (>= packageversion)". Note that in
45 debhelper compatibility levels before v4, the debian part of the package
46 version number is also included. If -V is specified with parameters, the
47 parameters can be used to specify the exact dependency information needed
48 (be sure to include the package name).
50 Beware of using -V without any parameters; this is a conservative setting
51 that always ensures that other packages' shared library dependencies are at
52 least as tight as they need to be (unless your library is prone to changing
53 ABI without updating the upstream version number), so that if the
54 maintainer screws up then they won't break. The flip side is that packages
55 might end up with dependencies that are too tight and so find it harder to
58 =item B<-n>, B<--noscripts>
60 Do not modify postinst/postrm scripts.
62 =item B<-X>I<item>, B<--exclude=>I<item>
64 Exclude files that contain "item" anywhere in their filename or directory
65 from being treated as shared libraries.
67 =item B<--add-udeb=>I<udeb>
69 Create an additional line for udebs in the shlibs file and use "udeb" as the
70 package name for udebs to depend on instead of the regular library package.
80 Assuming this is a package named libfoobar1, generates a shlibs file that
82 libfoobar 1 libfoobar1
84 =item dh_makeshlibs -V
86 Assuming the current version of the package is 1.1-3, generates a shlibs
87 file that looks something like:
88 libfoobar 1 libfoobar1 (>= 1.1)
90 =item dh_makeshlibs -V 'libfoobar1 (>= 1.0)'
92 Generates a shlibs file that looks something like:
93 libfoobar 1 libfoobar1 (>= 1.0)
101 foreach my $package (@{$dh{DOPACKAGES}}) {
102 next if is_udeb($package);
104 my $tmp=tmpdir($package);
107 my $need_ldconfig = 0;
109 doit("rm", "-f", "$tmp/DEBIAN/shlibs");
111 # So, we look for files or links to existing files with names that
112 # match "*.so*". Matching *.so.* is not good enough because of
113 # broken crap like db3. And we only look at real files not
114 # symlinks, so we don't accidentually add shlibs data to -dev
115 # packages. This may have a few false positives, which is ok,
116 # because only if we can get a library name and a major number from
117 # objdump is anything actually added.
120 if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
121 $exclude="! \\( $dh{EXCLUDE_FIND} \\) ";
123 open (FIND, "find $tmp -type f \\( -name '*.so' -or -name '*.so.*' \\) $exclude |");
125 my ($library, $major);
126 my $objdump=`objdump -p $_`;
127 if ($objdump=~m/\s+SONAME\s+(.+)\.so\.(.+)/) {
128 # proper soname format
132 elsif ($objdump=~m/\s+SONAME\s+(.+)-(.+)\.so/) {
133 # idiotic crap soname format
138 if (defined($dh{M_PARAMS}) && $dh{M_PARAMS} ne '') {
139 $major=$dh{M_PARAMS};
142 if (! -d "$tmp/DEBIAN") {
143 doit("install","-d","$tmp/DEBIAN");
146 if ($dh{V_FLAG_SET}) {
147 if ($dh{V_FLAG} ne '') {
151 # Call isnative becuase it sets $dh{VERSION}
154 my $version = $dh{VERSION};
155 # Old compatibility levels include the
156 # debian revision, while new do not.
158 # Remove debian version, if any.
159 $version =~ s/-[^-]+$//;
161 $deps="$package (>= $version)";
164 if (defined($library) && defined($major) && defined($deps) &&
165 $library ne '' && $major ne '' && $deps ne '') {
167 # Prevent duplicate lines from entering the file.
168 my $line="$library $major $deps";
169 if (! $seen{$line}) {
171 complex_doit("echo '$line' >>$tmp/DEBIAN/shlibs");
172 if (defined($dh{SHLIBS_UDEB}) && $dh{SHLIBS_UDEB} ne '') {
173 my $udeb_deps = $deps;
174 $udeb_deps =~ s/\Q$package\E/$dh{SHLIBS_UDEB}/e;
175 $line="udeb: "."$library $major $udeb_deps";
176 push @udeb_lines, $line;
183 # Write udeb: lines last.
184 foreach (@udeb_lines) {
185 complex_doit("echo '$_' >>$tmp/DEBIAN/shlibs");
189 if (! compat(2) && ! $dh{NOSCRIPTS} && $need_ldconfig) {
190 autoscript($package,"postinst","postinst-makeshlibs");
191 autoscript($package,"postrm","postrm-makeshlibs");
194 if (-e "$tmp/DEBIAN/shlibs") {
195 doit("chmod",644,"$tmp/DEBIAN/shlibs");
196 doit("chown","0:0","$tmp/DEBIAN/shlibs");
204 This program is a part of debhelper.
208 Joey Hess <joeyh@debian.org>