5 dh_makeshlibs - automatically create shlibs file
10 use Debian::Debhelper::Dh_Lib;
14 dh_makeshlibs [debhelper options] [-mmajor] [-V[dependancies]] [-n]
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 DH_COMPAT=3 mode and above only).
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 specified with
45 parameters, the parameters can be used to specify the exact dependancy
46 information needed (be sure to include the package name).
48 =item B<-n>, B<--noscripts>
50 Do not modify postinst/postrm scripts.
58 Assuming this is a package named libfoobar1, generates a shlibs file that
60 libfoobar 1 libfoobar1
64 Assuming the current version of the package is 1.0-3, generates a shlibs
65 file that looks something like:
66 libfoobar 1 libfoobar1 (>= 1.0-3)
68 dh_makeshlibs -V 'libfoobar1 (>= 1.0)'
70 Generates a shlibs file that looks something like:
71 libfoobar 1 libfoobar1 (>= 1.0)
77 foreach my $package (@{$dh{DOPACKAGES}}) {
78 my $tmp=tmpdir($package);
81 my $need_ldconfig = 0;
83 doit("rm", "-f", "$tmp/DEBIAN/shlibs");
85 # So, we look for files or links to existing files with names that
86 # match "*.so*". Matching *.so.* is not good enough because of
87 # broken crap like db3. And we only look at real files not
88 # symlinks, so we don't accidentually add shlibs data to -dev
89 # packages. This may have a few false positives, which is ok,
90 # because only if we can get a library name and a major number from
91 # objdump is anything actually added.
92 open (FIND, "find $tmp -type f -name '*.so*' |");
94 my ($library, $major) =
95 `objdump -p $_` =~ m/\s+SONAME\s+(.+)\.so\.(.+)/;
97 if (defined($dh{M_PARAMS}) && $dh{M_PARAMS} ne '') {
101 if (! -d "$tmp/DEBIAN") {
102 doit("install","-d","$tmp/DEBIAN");
105 if ($dh{V_FLAG_SET}) {
106 if ($dh{V_FLAG} ne '') {
110 # Call isnative becuase it sets $dh{VERSION}
113 $deps="$package (>= $dh{VERSION})";
116 if (defined($library) && defined($major) && defined($deps) &&
117 $library ne '' && $major ne '' && $deps ne '') {
119 # Prevent duplicate lines from entering the file.
120 my $line="$library $major $deps";
121 if (! $seen{$line}) {
123 complex_doit("echo '$line' >>$tmp/DEBIAN/shlibs");
130 if (! compat(2) && ! $dh{NOSCRIPTS} && $need_ldconfig) {
131 autoscript($package,"postinst","postinst-makeshlibs");
132 autoscript($package,"postrm","postrm-makeshlibs");
135 if (-e "$tmp/DEBIAN/shlibs") {
136 doit("chmod",644,"$tmp/DEBIAN/shlibs");
137 doit("chown","0.0","$tmp/DEBIAN/shlibs");
145 This program is a part of debhelper.
149 Joey Hess <joeyh@debian.org>