5 dh_makeshlibs - automatically create shlibs file and call dpkg-gensymbols
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>] [S<B<--> I<params>>]
18 B<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 F<postinst> and F<postrm> scripts (in
22 v3 mode and above only) to any packages in which it finds shared libraries.
28 =item debian/I<package>.symbols
30 =item debian/I<package>.symbols.I<arch>
32 These symbols files, if present, are passed to L<dpkg-gensymbols(1)> to
33 be processed and installed. Use the I<arch> specific names if you need
34 to provide different symbols files for different architectures.
42 =item B<-m>I<major>, B<--major=>I<major>
44 Instead of trying to guess the major number of the library with /postobjdump,
45 use the major number specified after the -m parameter. This is much less
46 useful than it used to be, back in the bad old days when this program
47 looked at library filenames rather than using objdump.
49 =item B<-V>, B<-V>I<dependencies>
51 =item B<--version-info>, B<--version-info=>I<dependencies>
53 By default, the shlibs file generated by this program does not make packages
54 depend on any particular version of the package containing the shared
55 library. It may be necessary for you to add some version dependancy
56 information to the shlibs file. If B<-V> is specified with no dependency
57 information, the current upstream version of the package is plugged into a
58 dependency that looks like "I<packagename> B<(=E<gt>> I<packageversion>B<)>". Note that in
59 debhelper compatibility levels before v4, the Debian part of the package
60 version number is also included. If B<-V> is specified with parameters, the
61 parameters can be used to specify the exact dependency information needed
62 (be sure to include the package name).
64 Beware of using B<-V> without any parameters; this is a conservative setting
65 that always ensures that other packages' shared library dependencies are at
66 least as tight as they need to be (unless your library is prone to changing
67 ABI without updating the upstream version number), so that if the
68 maintainer screws up then they won't break. The flip side is that packages
69 might end up with dependencies that are too tight and so find it harder to
72 =item B<-n>, B<--noscripts>
74 Do not modify F<postinst>/F<postrm> scripts.
76 =item B<-X>I<item>, B<--exclude=>I<item>
78 Exclude files that contain I<item> anywhere in their filename or directory
79 from being treated as shared libraries.
81 =item B<--add-udeb=>I<udeb>
83 Create an additional line for udebs in the shlibs file and use I<udeb> as the
84 package name for udebs to depend on instead of the regular library package.
88 Pass I<params> to L<dpkg-gensymbols(1)>.
96 =item B<dh_makeshlibs>
98 Assuming this is a package named F<libfoobar1>, generates a shlibs file that
100 libfoobar 1 libfoobar1
102 =item B<dh_makeshlibs -V>
104 Assuming the current version of the package is 1.1-3, generates a shlibs
105 file that looks something like:
106 libfoobar 1 libfoobar1 (>= 1.1)
108 =item B<dh_makeshlibs -V 'libfoobar1 (E<gt>= 1.0)'>
110 Generates a shlibs file that looks something like:
111 libfoobar 1 libfoobar1 (>= 1.0)
118 "m=s", => \$dh{M_PARAMS},
119 "major=s" => \$dh{M_PARAMS},
120 "version-info:s" => \$dh{V_FLAG},
121 "add-udeb=s" => \$dh{SHLIBS_UDEB},
124 my $objdump=cross_command("objdump");
126 foreach my $package (@{$dh{DOPACKAGES}}) {
127 next if is_udeb($package);
129 my $tmp=tmpdir($package);
132 my $need_ldconfig = 0;
134 doit("rm", "-f", "$tmp/DEBIAN/shlibs");
136 # So, we look for files or links to existing files with names that
137 # match "*.so.*". And we only look at real files not
138 # symlinks, so we don't accidentually add shlibs data to -dev
139 # packages. This may have a few false positives, which is ok,
140 # because only if we can get a library name and a major number from
141 # objdump is anything actually added.
143 my (@udeb_lines, @lib_files);
144 if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
145 $exclude="! \\( $dh{EXCLUDE_FIND} \\) ";
147 open (FIND, "find $tmp -type f \\( -name '*.so' -or -name '*.so.*' \\) $exclude |");
149 my ($library, $major);
151 my $ret=`$objdump -p $_`;
152 if ($ret=~m/\s+SONAME\s+(.+)\.so\.(.+)/) {
153 # proper soname format
157 elsif ($ret=~m/\s+SONAME\s+(.+)-(.+)\.so/) {
158 # idiotic crap soname format
163 if (defined($dh{M_PARAMS}) && $dh{M_PARAMS} ne '') {
164 $major=$dh{M_PARAMS};
167 if (! -d "$tmp/DEBIAN") {
168 doit("install","-d","$tmp/DEBIAN");
171 if ($dh{V_FLAG_SET}) {
172 if ($dh{V_FLAG} ne '') {
176 # Call isnative becuase it sets $dh{VERSION}
179 my $version = $dh{VERSION};
180 # Old compatibility levels include the
181 # debian revision, while new do not.
183 # Remove debian version, if any.
184 $version =~ s/-[^-]+$//;
186 $deps="$package (>= $version)";
189 if (defined($library) && defined($major) && defined($deps) &&
190 $library ne '' && $major ne '' && $deps ne '') {
192 # Prevent duplicate lines from entering the file.
193 my $line="$library $major $deps";
194 if (! $seen{$line}) {
196 complex_doit("echo '$line' >>$tmp/DEBIAN/shlibs");
197 if (defined($dh{SHLIBS_UDEB}) && $dh{SHLIBS_UDEB} ne '') {
198 my $udeb_deps = $deps;
199 $udeb_deps =~ s/\Q$package\E/$dh{SHLIBS_UDEB}/e;
200 $line="udeb: "."$library $major $udeb_deps";
201 push @udeb_lines, $line;
208 # Write udeb: lines last.
209 foreach (@udeb_lines) {
210 complex_doit("echo '$_' >>$tmp/DEBIAN/shlibs");
214 if (! compat(2) && ! $dh{NOSCRIPTS} && $need_ldconfig) {
215 autoscript($package,"postinst","postinst-makeshlibs");
216 autoscript($package,"postrm","postrm-makeshlibs");
219 if (-e "$tmp/DEBIAN/shlibs") {
220 doit("chmod",644,"$tmp/DEBIAN/shlibs");
221 doit("chown","0:0","$tmp/DEBIAN/shlibs");
224 # dpkg-gensymbols files
225 my $symbols=pkgfile($package, "symbols");
229 @liblist=map { "-e$_" } @lib_files;
231 # -I is used rather than using dpkg-gensymbols
232 # own search for symbols files, since that search
233 # is not 100% compatible with debhelper. (For example,
234 # this supports --ignore being used.)
235 doit("dpkg-gensymbols", "-p$package", "-I$symbols",
239 if (-s "$tmp/DEBIAN/symbols" == 0) {
240 doit("rm", "-f", "$tmp/DEBIAN/symbols");
249 This program is a part of debhelper.
253 Joey Hess <joeyh@debian.org>