Firstly, your package should install the shared libraries under their
normal names. For example, the libgdbm1 package should install
libgdbm.so.1.7.3
as /usr/lib/libgdbm.so.1.7.3
. The
files should not be renamed or relinked by any prerm or postrm
scripts; dpkg will take care of renaming things safely without
affecting running programs, and attempts to interfere with this are
likely to lead to problems.
Secondly, your package should include the symlink that ldconfig
would create for the shared libraries. For example, the
libgdbm1 package should include a symlink from
/usr/lib/libgdbm.so.1
to libgdbm.so.1.7.3
. This is
needed so that ld.so can find the library in between the time
dpkg installs it and ldconfig is run in the
postinst script. Futhermore, and this is very important,
the library must be placed before the symlink pointing to it in the
.deb
file. This is so that by the time dpkg comes to
install the symlink (overwriting the previous symlink pointing at an
older version of the library) the new shared library is already in
place. Currently the way to ensure the ordering is done properly is
to install the library in the appropriate debian/tmp/.../lib
directory before creating the symlink, by putting the commands in the
debian/rules
in the appropriate order.
If you do the above your package does not need to call ldconfig in its maintainer scripts. It is especially important not to call ldconfig in the postrm or preinst scripts in the case where the package is being upgraded (see the programmer's manual), as ldconfig will see the temporary names that dpkg uses for the files while it is installing them and will make the shared library links point to them, just before dpkg continues the installation and removes the links!