0

I want to pack my qt application to deb. During investigation dependencies with ldd i got ~50 libraries. Full list below:

libgstreamer-plugins-base0.10-0,
libgstreamer0.10-0,
libglib2.0-0,
libasound2,
liboss4-salsa-asound2,
libssl1.0.0,
libx11-xcb1,
libxi6,
libxcb-render-util0,
libsm6,
libice6
libxcb1,
libxcb-glx0,
libxcb-render0,
libxcb-image0,
libxcb-icccm4,
libxcb-sync1,
libxcb-xfixes0,
libxcb-shm0,
libxcb-randr0,
libxcb-shape0,
libxcb-keysyms1,
libxcb-xkb1,
libxcb-dri2-0,
libxcb-present0,
libfontconfig1,
libfreetype6,
libxrender1,
libx11-6,
libjpeg-turbo8,
libpng12-0,
zlib1g,
libglib2.0-0,
libgl1-mesa-glx,
libstdc++6,
libgcc1,
libc6,
liborc-0.4-0,
libglib2.0-0,
libxml2,
libffi6,
libxext6,
libuuid1,
libxau6,
libxdmcp6,
libxcb-util0,
libexpat1,
libpcre3,
libglapi-mesa,
libxdamage1,
libxfixes3,
libxshmfence1,
libxxf86vm1,
libdrm2,
liblzma5

I want to minimize this list, based on assumption that there is dependency between some lib and each other in this list.

My questions:

  • Which tool can help me to minimize?
  • Which dependencies from list above are pre-installed for Ubuntu?
6
  • If you can get the name of the library file being used (the .so one), you can use dpkg -S to see which package owns it, then sort and retain unique entries to minimise the list. – muru Aug 3 '14 at 11:42
  • Actually I already did this. This question contains list of packages not just so libraries. No I want to detect dependencies in this list to reduce it. – CAMOBAP Aug 3 '14 at 12:06
  • Oh, so for example, you want to remove libc6 because something else in the list is almost certain to depend on it? – muru Aug 3 '14 at 12:08
  • Yes, exactly. Is there any automation tool/command for this? – CAMOBAP Aug 3 '14 at 12:16
  • I don't know, but I don't think you should to do it. lintian made me include libc6, even though I had a dependency which had it somewhere up in its tree. – muru Aug 3 '14 at 12:24
3

I want to minimize this list, based on assumption that there is dependency between some lib and each other in this list.

You should not do this. The list of dependencies should include each library that your software directly depends on. The reason for this is that your binary requires that library, and exactly that library, to link correctly when run. Suppose that you try to optimise this:

  • Your program depends on libX and libY
  • libY depends on libX
  • So you try to minimise this by specifying a dependency to only libY

Now what happens if the author or package maintainer of libY changes their code to no longer depend on libX? Your package will break. It breaks because you made a false assumption - that libY will always depend on libX. That assumption is not valid - the dependencies of packages can and do change over time. So if your program needs libX, you need to specify that.

The good news is that the list of shared libraries can be generated automatically using dpkg-shlibdeps:

https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-dpkg-shlibdeps

8.6.1 Generating dependencies on shared libraries

When a package that contains any shared libraries or compiled binaries is built, it must run dpkg-shlibdeps on each shared library and compiled binary to determine the libraries used and hence the dependencies needed by the package.[66] To do this, put a call to dpkg-shlibdeps into your debian/rules file in the source package. List all of the compiled binaries, libraries, or loadable modules in your package.[67] dpkg-shlibdeps will use the symbols or shlibs files installed by the shared libraries to generate dependency information. The package must then provide a substitution variable into which the discovered dependency information can be placed.

If you are creating a udeb for use in the Debian Installer, you will need to specify that dpkg-shlibdeps should use the dependency line of type udeb by adding the -tudeb option[68]. If there is no dependency line of type udeb in the shlibs file, dpkg-shlibdeps will fall back to the regular dependency line.

dpkg-shlibdeps puts the dependency information into the debian/substvars file by default, which is then used by dpkg-gencontrol. You will need to place a ${shlibs:Depends} variable in the Depends field in the control file of every binary package built by this source package that contains compiled binaries, libraries, or loadable modules. If you have multiple binary packages, you will need to call dpkg-shlibdeps on each one which contains compiled libraries or binaries. For example, you could use the -T option to the dpkg utilities to specify a different substvars file for each binary package.[69]

For more details on dpkg-shlibdeps, see dpkg-shlibdeps(1).

We say that a binary foo directly uses a library libbar if it is explicitly linked with that library (that is, the library is listed in the ELF NEEDED attribute, caused by adding -lbar to the link line when the binary is created). Other libraries that are needed by libbar are linked indirectly to foo, and the dynamic linker will load them automatically when it loads libbar. A package should depend on the libraries it directly uses, but not the libraries it only uses indirectly. The dependencies for the libraries used directly will automatically pull in the indirectly-used libraries. dpkg-shlibdeps will handle this logic automatically, but package maintainers need to be aware of this distinction between directly and indirectly using a library if they have to override its results for some reason. [70]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.