简体   繁体   中英

Executable can't find shared library during apt install phase

This is the command I am running to install Debian packages from the virtual repo I have created. This repo has library A that contains a shared library and library B that starts the executable that uses this shared library in postinst section of Debian. Library B depends on Library A ( via control file of Debian ). Both A and B libraries were packaged by me.

apt-get -o Dir::Etc::SourceList="${VIRTUAL_REPO_PATH}/upgrade.list" -o Debug::pkgProblemResolver=yes -o Dir::Etc::SourceParts="/dev/null" -o Dir::State::Lists="${VIRTUAL_REPO_PATH}/lists" -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install ${VIRTUAL_REPO_PATH}/${COMPONENT_DEB}*.deb -y --allow-unauthenticated

I have added triggers file to Debian of library A with " activate-noawait ldconfig " row as mentioned here .

The Debian of library A has 3 files ( extracted with dpkg-deb --control.. ): control, postinst, triggers.

postinst

#! /bin/sh

set -e

if [ "$1" = "configure" ]; then
        ldconfig
fi

triggers

activate-noawait ldconfig

In dpkg.log I can see that library A was installed and configured before library B.

2021-04-16 08:54:16 configure libsigar:amd64 1.7.0-fs1 <none>
2021-04-16 08:54:16 status unpacked libsigar:amd64 1.7.0-fs1
2021-04-16 08:54:16 status half-configured libsigar:amd64 1.7.0-fs1
2021-04-16 08:54:16 status installed libsigar:amd64 1.7.0-fs1

In postinst of the library B I am starting the executable and at that given moment of time it fails with error while loading shared libraries: A: cannot open shared object file: No such file or directory . If I start the executable immediately after the installation everything works just fine. I tried to comment out the postinst script starting from the moment executable is started and execute that part manually - no issue whatsoever.

Also I have added ldconfig call to postinst just before the executable is started with no luck.

Does anyone know what is the reason?

I found the root cause. It appears I have to create a symlink (libsigar.so.0 -> libsigar.so) in the package before postinst is called. Otherwise even ldconfig isn't sufficient enough.

The run-time library package should include the symbolic link for the SONAME that ldconfig would create for the shared libraries. For example, the libgdbm3 package should include a symbolic link from /usr/lib/libgdbm.so.3 to libgdbm.so.3.0.0. This is needed so that the dynamic linker (for example ld.so or ld-linux.so.*) can find the library between the time that dpkg installs it and the time that ldconfig is run in the postinst script.[59]

http://www.chiark.greenend.org.uk/doc/debian-policy/policy.html/ch-sharedlibs.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM