How to correctly deal with lib-symlinks in modern Ubuntu versions?

Solution 1:

With muru's recommendation we should use realpath command. This happens because of usrmerge.

But with small note that running realpath on the earliest stage will not work as expected.

So we need to add one extra step to process the output file:

dpkg -S $(realpath $(grep -E "/lib.*" --only-matching /tmp/not-from-apt)) 2> /tmp/not-from-apt-final

And the complete method for 20.04 LTS will look as follows:

export EXE=/usr/bin/mc;

dpkg -S $(ldd $EXE | grep -v "=>" | awk '{print $1}') 2> /tmp/not-from-apt
dpkg -S $(ldd $EXE | grep "=>" | awk '{print $3}') 2>> /tmp/not-from-apt

dpkg -S $(realpath $(grep -E "/lib.*" --only-matching /tmp/not-from-apt)) 2> /tmp/not-from-apt-final

it will produce empty /tmp/not-from-apt-final file when there are no errors.
Also one can always check the contents of /tmp/not-from-apt for extra info.


Below is the case when one has output of ldd from some other system saved as /tmp/ldd-output, so packages are not installed locally. Here one needs to use apt-file search instead of dpkg -S as implemented in the GitHub Gist

sudo apt-get update
sudo apt-get install apt-file
sudo apt-file update

cd /tmp
wget -c https://gist.githubusercontent.com/N0rbert/423d9b5c8718c45a699e9d3bd406ffc6/raw/2ce8e747795b74d67a00b96d840626bd95409ad3/apt-file_ldd_parse.sh
chmod +x apt-file_ldd_parse.sh
./apt-file_ldd_parse.sh /tmp/ldd-output | grep Warning

to get something like shown below for this question about 21.10:

Warning: configured repositories does not contain 'linux-vdso.so.1' library.
Warning: configured repositories does not contain '/usr/lib/dcaenabler/libcurl.so.4' library.
Warning: configured repositories does not contain '/usr/lib/dcaenabler/libssl.so.1.1' library.
Warning: configured repositories does not contain '/usr/lib/dcaenabler/libcrypto.so.1.1' library.
Warning: configured repositories does not contain 'libldap_r-2.4.so.2' library.
Warning: configured repositories does not contain 'liblber-2.4.so.2' library.

Note: linux-vdso.so.1 is not a problem, it is virtual.