Reimplement 78b0b66d59693d5bc.

We need to set the correct install_name on shared libraries before
staging them into the destroot, because linking with binaries occurs
during the general build process. If the libraries don't have the
correct install_name set by that time, launching the binary will fail.
Fix incorrect usage of g_return_if_fail() in a function which must return a boolean value.