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 symlink must be placed before the library it
points to in the .deb
file. Currently the way to ensure the
ordering is done properly is to create the symlink in the appropriate
debian/tmp/.../lib
directory before installing the library
when you build the package.
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!