chiark / gitweb /
awful debugging hacking
[dpkg] / man / dpkg-shlibdeps.man
1 .\" dpkg manual page - dpkg-deb(1)
2 .\"
3 .\" Copyright © 1995-1996 Ian Jackson <ijackson@chiark.greenend.org.uk>
4 .\" Copyright © 2000 Wichert Akkerman <wakkerma@debian.org>
5 .\" Copyright © 2006 Frank Lichtenheld <djpig@debian.org>
6 .\" Copyright © 2007-2011 Raphaël Hertzog <hertzog@debian.org>
7 .\" Copyright © 2011-2013, 2015 Guillem Jover <guillem@debian.org>
8 .\"
9 .\" This is free software; you can redistribute it and/or modify
10 .\" it under the terms of the GNU General Public License as published by
11 .\" the Free Software Foundation; either version 2 of the License, or
12 .\" (at your option) any later version.
13 .\"
14 .\" This is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 .\" GNU General Public License for more details.
18 .\"
19 .\" You should have received a copy of the GNU General Public License
20 .\" along with this program.  If not, see <https://www.gnu.org/licenses/>.
21 .
22 .TH dpkg\-shlibdeps 1 "%RELEASE_DATE%" "%VERSION%" "dpkg suite"
23 .nh
24 .SH NAME
25 dpkg\-shlibdeps \- generate shared library substvar dependencies
26 .
27 .SH SYNOPSIS
28 .B dpkg\-shlibdeps
29 .RI [ option "...] [" \fB\-e\fP ] executable " [" option ...]
30 .
31 .SH DESCRIPTION
32 .B dpkg\-shlibdeps
33 calculates shared library dependencies for executables named in its
34 arguments. The dependencies are added to the substitution
35 variables file
36 .B debian/substvars
37 as variable names
38 .BI shlibs: dependency-field
39 where
40 .I dependency-field
41 is a dependency field name. Any other variables starting with
42 .B shlibs:
43 are removed from the file.
44 .P
45 .B dpkg\-shlibdeps
46 has two possible sources of information to generate dependency
47 information. Either
48 .I symbols
49 files or
50 .I shlibs
51 files. For each binary that
52 .B dpkg\-shlibdeps
53 analyzes, it finds out the list of libraries that it's linked with.
54 Then, for each library, it looks up either the
55 .I symbols
56 file, or the
57 .I shlibs
58 file (if the former doesn't exist or if debian/shlibs.local contains
59 the relevant dependency). Both files are supposed to be provided
60 by the library package and should thus be available as
61 %ADMINDIR%/info/\fIpackage\fR.\fIsymbols\fR
62 or %ADMINDIR%/info/\fIpackage\fR.\fIshlibs\fR. The package name is
63 identified in two steps: find the library file on the system (looking in
64 the same directories that \fBld.so\fR would use), then use
65 .BI "dpkg \-S " library-file
66 to lookup the package providing the library.
67 .SS Symbols files
68 Symbols files contain finer-grained dependency information by providing
69 the minimum dependency for each symbol that the library exports. The
70 script tries to find a symbols file associated to a library package
71 in the following places (first match is used):
72 .IP debian/*/DEBIAN/symbols
73 Shared library information generated by the current build process that also invoked
74 .BR dpkg\-shlibdeps .
75 They are generated by
76 .BR dpkg\-gensymbols (1).
77 They are only used if the library is found in a package's build tree. The
78 symbols file in that build tree takes precedence over symbols files from
79 other binary packages.
80 .IP %PKGCONFDIR%/symbols/\fIpackage\fR.symbols.\fIarch\fR
81 .IP %PKGCONFDIR%/symbols/\fIpackage\fR.symbols
82 Per-system overriding shared library dependency information.
83 \fIarch\fR is the architecture of the current system (obtained by
84 .BR "dpkg\-architecture \-qDEB_HOST_ARCH" ).
85 .IP "Output from “\fBdpkg\-query \-\-control\-path\fR \fIpackage\fR symbols”"
86 Package-provided shared library dependency information.
87 Unless overridden by \fB\-\-admindir\fP, those files are located in
88 %ADMINDIR%.
89 .P
90 While scanning the symbols used by all binaries,
91 .B dpkg\-shlibdeps
92 remembers the (biggest) minimal version needed for each library. At the end
93 of the process, it is able to write out the minimal dependency for every
94 library used (provided that the information of the \fIsymbols\fR files are
95 accurate).
96 .P
97 As a safe-guard measure, a symbols file can provide a
98 \fBBuild\-Depends\-Package\fP meta-information field and
99 .B dpkg\-shlibdeps
100 will extract the minimal version required by the corresponding package in
101 the \fBBuild\-Depends\fP field and use this version if it's higher than the
102 minimal version computed by scanning symbols.
103 .SS Shlibs files
104 Shlibs files associate directly a library to a dependency (without looking
105 at the symbols). It's thus often stronger than really needed but very safe
106 and easy to handle.
107 .P
108 The dependencies for a library are looked up in several places. The first
109 file providing information for the library of interest is used:
110 .IP debian/shlibs.local
111 Package-local overriding shared library dependency information.
112 .IP %PKGCONFDIR%/shlibs.override
113 Per-system overriding shared library dependency information.
114 .IP debian/*/DEBIAN/shlibs
115 Shared library information generated by the current build process that also invoked
116 .BR dpkg\-shlibdeps .
117 They are only used if the library is found in a package's build tree. The
118 shlibs file in that build tree takes precedence over shlibs files from
119 other binary packages.
120 .IP "Output from “\fBdpkg\-query \-\-control\-path\fP \fIpackage\fR shlibs”"
121 Package-provided shared library dependency information.
122 Unless overridden by \fB\-\-admindir\fP, those files are located in
123 %ADMINDIR%.
124 .IP %PKGCONFDIR%/shlibs.default
125 Per-system default shared library dependency information.
126 .P
127 The extracted dependencies are then directly used (except if they are
128 filtered out because they have been identified as duplicate, or as weaker
129 than another dependency).
130 .SH OPTIONS
131 .B dpkg\-shlibdeps
132 interprets non-option arguments as executable names, just as if they'd
133 been supplied as
134 .BI \-e executable\fR.
135 .TP
136 .BI \-e executable
137 Include dependencies appropriate for the shared libraries required by
138 .IR executable .
139 This option can be used multiple times.
140 .TP
141 .BI \-l directory
142 Prepend
143 .I directory
144 to the list of directories to search for private shared libraries
145 (since dpkg 1.17.0). This option can be used multiple times.
146
147 Note: Use this option instead of setting \fBLD_LIBRARY_PATH\fP,
148 as that environment variable is used to control the run-time linker
149 and abusing it to set the shared library paths at build-time can be
150 problematic when cross-compiling for example.
151 .TP
152 .BI \-d dependency-field
153 Add dependencies to be added to the control file dependency field
154 .IR dependency-field .
155 (The dependencies for this field are placed in the variable
156 .BI shlibs: dependency-field\fR.)
157
158 The
159 .BI \-d dependency-field
160 option takes effect for all executables after the option, until the
161 next
162 .BI \-d dependency-field\fR.
163 The default
164 .I dependency-field
165 is
166 .BR Depends .
167
168 If the same dependency entry (or set of alternatives) appears in more
169 than one of the recognized dependency field names
170 .BR Pre\-Depends ", " Depends ", " Recommends ", " Enhances " or " Suggests
171 then
172 .B dpkg\-shlibdeps
173 will automatically remove the dependency from all fields except the
174 one representing the most important dependencies.
175 .TP
176 .BI \-p varname-prefix
177 Start substitution variables with
178 .IB varname-prefix :
179 instead of
180 .BR shlibs: .
181 Likewise, any existing substitution variables starting with
182 .IB varname-prefix :
183 (rather than
184 .BR shlibs: )
185 are removed from the substitution variables file.
186 .TP
187 .BR \-O [\fIfilename\fP]
188 Print substitution variable settings to standard output (or \fIfilename\fP
189 if specified, since dpkg 1.17.2), rather than being added to the
190 substitution variables file
191 .RB ( debian/substvars
192 by default).
193 .TP
194 .BI \-t type
195 Prefer shared library dependency information tagged for the given
196 package type. If no tagged information is available, falls back to untagged
197 information. The default package type is \fBdeb\fP. Shared library dependency
198 information is tagged for a given type by prefixing it with the name of the
199 type, a colon, and whitespace.
200 .TP
201 .BI \-L local-shlibs-file
202 Read overriding shared library dependency information from
203 .I local-shlibs-file
204 instead of
205 .BR debian/shlibs.local .
206 .TP
207 .BI \-T substvars-file
208 Write substitution variables in
209 .IR substvars-file ;
210 the default is
211 .BR debian/substvars .
212 .TP
213 .BI \-v
214 Enable verbose mode (since dpkg 1.14.8).
215 Numerous messages are displayed to explain what
216 .B dpkg\-shlibdeps
217 does.
218 .TP
219 .BI \-x package
220 Exclude the package from the generated dependencies (since dpkg 1.14.8).
221 This is useful to
222 avoid self-dependencies for packages which provide ELF binaries
223 (executables or library plugins) using a library contained in the same
224 package. This option can be used multiple times to exclude several
225 packages.
226 .TP
227 .BI \-S package-build-dir
228 Look into \fIpackage-build-dir\fP first when trying to find a library
229 (since dpkg 1.14.15).
230 This is
231 useful when the source package builds multiple flavors of the same library
232 and you want to ensure that you get the dependency from a given binary
233 package. You can use this option multiple times: directories will be
234 tried in the same order before directories of other binary packages.
235 .TP
236 .BI \-I package-build-dir
237 Ignore \fIpackage-build-dir\fP when looking for shlibs, symbols, and shared
238 library files (since dpkg 1.18.5).
239 You can use this option multiple times.
240 .TP
241 .BI \-\-ignore\-missing\-info
242 Do not fail if dependency information can't be found for a shared library
243 (since dpkg 1.14.8).
244 Usage of this option is discouraged, all libraries should provide
245 dependency information (either with shlibs files, or with symbols files)
246 even if they are not yet used by other packages.
247 .TP
248 .BI \-\-warnings= value
249 \fIvalue\fP is a bit field defining the set of warnings that
250 can be emitted by \fBdpkg\-shlibdeps\fP (since dpkg 1.14.17).
251 Bit 0 (value=1) enables the warning “symbol \fIsym\fP used by \fIbinary\fP
252 found in none of the libraries”, bit 1 (value=2) enables the warning
253 “package could avoid a useless dependency” and bit 2 (value=4) enables
254 the warning “\fIbinary\fP should not be linked against \fIlibrary\fP”.
255 The default \fIvalue\fP is 3: the first two warnings are active by
256 default, the last one is not. Set \fIvalue\fP to 7 if you want all
257 warnings to be active.
258 .TP
259 .BI \-\-admindir= dir
260 Change the location of the \fBdpkg\fR database (since dpkg 1.14.0).
261 The default location is \fI%ADMINDIR%\fP.
262 .TP
263 .BR \-? ", " \-\-help
264 Show the usage message and exit.
265 .TP
266 .BR \-\-version
267 Show the version and exit.
268 .
269 .SH DIAGNOSTICS
270 .SS Warnings
271 Since
272 .B dpkg\-shlibdeps
273 analyzes the set of symbols used by each binary of the generated package,
274 it is able to emit warnings in several cases. They inform you of things
275 that can be improved in the package. In most cases, those improvements
276 concern the upstream sources directly. By order of decreasing importance,
277 here are the various warnings that you can encounter:
278 .TP
279 .BI symbol " sym" " used by " binary " found in none of the libraries."
280 The indicated symbol has not been found in the libraries linked with the
281 binary. The \fIbinary\fR is most likely a library and it needs to be linked
282 with an additional library during the build process (option
283 \fB\-l\fR\fIlibrary\fR of the linker).
284 .TP
285 .IB binary " contains an unresolvable reference to symbol " sym ": it's probably a plugin
286 The indicated symbol has not been found in the libraries linked with the
287 binary. The \fIbinary\fR is most likely a plugin and the symbol is
288 probably provided by the program that loads this plugin. In theory a
289 plugin doesn't have any SONAME but this binary does have one and as such
290 it could not be clearly identified as such. However the fact that the
291 binary is stored in a non-public directory is a strong indication
292 that's it's not a normal shared library. If the binary is really a
293 plugin, then disregard this warning. But there's always the possibility
294 that it's a real library and that programs linking to it are using an
295 RPATH so that the dynamic loader finds it. In that case, the library is
296 broken and needs to be fixed.
297 .TP
298 .BI "package could avoid a useless dependency if " binary " was not linked against " library " (it uses none of the library's symbols)"
299 None of the \fIbinaries\fP that are linked with \fPlibrary\fP use any of the
300 symbols provided by the library. By fixing all the binaries, you would avoid
301 the dependency associated to this library (unless the same dependency is
302 also generated by another library that is really used).
303 .TP
304 .BI "package could avoid a useless dependency if " binaries " were not linked against " library " (they use none of the library's symbols)"
305 Exactly the same as the above warning, but for multiple binaries.
306 .TP
307 .IB binary " should not be linked against " library " (it uses none of the library's symbols)"
308 The \fIbinary\fR is linked to a library that it doesn't need. It's not a
309 problem but some small performance improvements in binary load time can be
310 obtained by not linking this library to this binary. This warning checks
311 the same information as the previous one but does it for each binary
312 instead of doing the check globally on all binaries analyzed.
313 .SS Errors
314 .B dpkg\-shlibdeps
315 will fail if it can't find a public library used by a binary or if this
316 library has no associated dependency information (either shlibs file or
317 symbols file). A public library has a SONAME and is versioned
318 (libsomething.so.\fIX\fR). A private library (like a plugin) should not
319 have a SONAME and doesn't need to be versioned.
320 .TP
321 .BI "couldn't find library " library-soname " needed by " binary " (its RPATH is '" rpath "')"
322 The \fIbinary\fR uses a library called \fIlibrary-soname\fR but
323 .B dpkg\-shlibdeps
324 has been unable to find the library.
325 .B dpkg\-shlibdeps
326 creates a list of directories to check as following: directories listed in
327 the RPATH of the binary, directories added by the \fB\-l\fP option, directories
328 listed in the \fBLD_LIBRARY_PATH\fP environment variable, cross multiarch
329 directories (ex. /lib/arm64-linux-gnu, /usr/lib/arm64-linux-gnu), standard
330 public directories (/lib, /usr/lib), directories listed in /etc/ld.so.conf,
331 and obsolete multilib directories (/lib32, /usr/lib32, /lib64, /usr/lib64).
332 Then it checks those directories in the package's build tree
333 of the binary being analyzed, in the packages' build trees indicated with
334 the \fB\-S\fP command-line option, in other packages' build trees that contains
335 a DEBIAN/shlibs or DEBIAN/symbols file and finally in the root directory.
336 If the library is not found in any of those directories, then you get this
337 error.
338
339 If the library not found is in a private directory of the same package,
340 then you want to add the directory with \fB\-l\fP. If it's in another
341 binary package being built, you want to make sure that the shlibs/symbols
342 file of this package is already created and that \fB\-l\fP
343 contains the appropriate directory if it also is in a private directory.
344 .TP
345 .BI "no dependency information found for " library-file " (used by " binary ")."
346 The library needed by \fIbinary\fR has been found by
347 .B dpkg\-shlibdeps
348 in \fIlibrary-file\fR but
349 .B dpkg\-shlibdeps
350 has been unable to find any dependency information for that library. To
351 find out the dependency, it has tried to map the library to a Debian
352 package with the help of
353 .BI "dpkg \-S " library-file\fR.
354 Then it checked the corresponding shlibs and symbols files in
355 %ADMINDIR%/info/, and in the various package's build trees
356 (debian/*/DEBIAN/).
357
358 This failure can be caused by a bad or missing shlibs or symbols file
359 in the package of the library. It might also happen if the library is
360 built within the same source package and if the shlibs files has not yet
361 been created (in which case you must fix debian/rules to create
362 the shlibs before calling \fBdpkg\-shlibdeps\fR). Bad RPATH can also
363 lead to the library being found under a non-canonical name (example:
364 /usr/lib/openoffice.org/../lib/libssl.so.0.9.8 instead of
365 /usr/lib/libssl.so.0.9.8) that's not associated to any package,
366 .B dpkg\-shlibdeps
367 tries to work around this by trying to fallback on a canonical name (using
368 .BR realpath (3))
369 but it might not always work. It's always best to clean up the RPATH
370 of the binary to avoid problems.
371
372 Calling
373 .B dpkg\-shlibdeps
374 in verbose mode (\fB\-v\fP) will provide much more information about where it
375 tried to find the dependency information. This might be useful if you
376 don't understand why it's giving you this error.
377 .SH SEE ALSO
378 .BR deb\-shlibs (5),
379 .BR deb\-symbols (5),
380 .BR dpkg\-gensymbols (1).