yaobin.wen

Yaobin's Blog

View on GitHub
7 April 2022

What is the detailed process of resolving `${shlibs:Depends}` when creating a Debian package?

by yaobin.wen

In 2018-10-22, I asked this question on Ask Ubuntu.

At that time, my work involves a lot of Debian packaging, and I was using the Debian New Maintainers’ Guide as my main reference.

What I didn’t fully understood was how the ${shlibs:Depends} was resolved into specific packages and versions. By “how” I meant the detailed steps from the variable ${shlibs:Depends} to the final list of packages in the Depends field.

Chapter 4 of Debian New Maintainers’ Guide says:

dh_shlibdeps(1) calculates shared library dependencies for binary packages. It generates a list of ELF executables and shared libraries it has found for each binary package. This list is used for substituting ${shlibs:Depends}.

I was really interested in the detailed steps of “generates a list of ELF executables and shared libraries it has found for each binary package”, such as what were the information sources used.

I also looked at the section “8.6.4. The shlibs system” in the Debian Policy Manual. It does give some information sources but still doesn’t seem to talk about the detailed steps either.

The user user.dz posted what he/she had learned and I appreciated the help (by accepting the answer).

But today I realized that it looks like ${shlibs:Depends} is resolved by dpkg-shlibdeps (or dh_shlibdeps) using the file debian/shlibs.local. The section “8.6.4.1. The shlibs files present on the system” of the Debian Policy Manual says:

This lists overrides for this package. This file should normally not be used, but may be needed temporarily in unusual situations to work around bugs in other packages, or in unusual cases where the normally declared dependency information in the installed shlibs file for a library cannot be used. This file overrides information obtained from any other source.

shlibs file format is defined by deb-shlibs(5). In other words, if a Debian package doesn’t have the file debian/shlibs.local, the variable ${shlibs:Depends} may be resolved to an empty list.

I haven’t got a chance to verify if this is correct, so I only posted my findings as a comment below my original question. But I think this is a good clue if one day I need to dig in deeper.

Tags: Tech - Linux - Debian