Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Linux, configure the dynamic linker to find /usr/local/lib. #41

Merged
merged 1 commit into from
Jul 10, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions install-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ uninstall_components() {
verbose_msg "removing manifest directory $_md"
run rm -r "$_md"
want_ok "failed to remove $_md"

maybe_unconfigure_ld
fi
fi

Expand Down Expand Up @@ -696,12 +698,32 @@ install_components() {
done
}

maybe_run_ldconfig() {
maybe_configure_ld() {
local _abs_libdir="$1"

get_host_triple
local _ostype="$RETVAL"
assert_nz "$_ostype" "ostype"

if [ "$_ostype" = "unknown-linux-gnu" -a ! -n "${CFG_DISABLE_LDCONFIG-}" ]; then

# Fedora-based systems do not configure the dynamic linker to look
# /usr/local/lib, which is our default installation directory. To
# make things just work, try to put that directory in
# /etc/ld.so.conf.d/rust-installer-v1 so ldconfig picks it up.
# Issue #30.
#
# This will get rm'd when the last component is uninstalled in
# maybe_unconfigure_ld.
if [ "$_abs_libdir" = "/usr/local/lib" -a -d "/etc/ld.so.conf.d" ]; then
echo "$_abs_libdir" > "/etc/ld.so.conf.d/rust-installer-v1-$TEMPLATE_REL_MANIFEST_DIR.conf"
if [ $? -ne 0 ]; then
# This shouldn't happen if we've gotten this far
# installing to /usr/local
warn "failed to update /etc/ld.so.conf.d. this is unexpected"
fi
fi

verbose_msg "running ldconfig"
if [ -n "${CFG_VERBOSE-}" ]; then
ldconfig
Expand All @@ -715,6 +737,19 @@ maybe_run_ldconfig() {
fi
}

maybe_unconfigure_ld() {
get_host_triple
local _ostype="$RETVAL"
assert_nz "$_ostype" "ostype"

if [ "$_ostype" != "unknown-linux-gnu" ]; then
return 0
fi

rm "/etc/ld.so.conf.d/rust-installer-v1-$TEMPLATE_REL_MANIFEST_DIR.conf" 2> /dev/null
# Above may fail since that file may not have been created on install
}

# Doing our own 'install'-like backup that is consistent across platforms
maybe_backup_path() {
local _file_install_path="$1"
Expand Down Expand Up @@ -967,8 +1002,8 @@ install_uninstaller "$src_dir" "$src_basename" "$abs_libdir"
# Install each component
install_components "$src_dir" "$abs_libdir" "$dest_prefix" "$components"

# Run ldconfig to make dynamic libraries available to the linker
maybe_run_ldconfig
# Make dynamic libraries available to the linker
maybe_configure_ld "$abs_libdir"

echo
echo " $TEMPLATE_SUCCESS_MESSAGE"
Expand Down