Skip to content

Commit c37d374

Browse files
committed
Merge pull request #41 from brson/ldconfig
On Linux, configure the dynamic linker to find /usr/local/lib.
2 parents 0012a74 + 6349a95 commit c37d374

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

install-template.sh

+38-3
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,8 @@ uninstall_components() {
566566
verbose_msg "removing manifest directory $_md"
567567
run rm -r "$_md"
568568
want_ok "failed to remove $_md"
569+
570+
maybe_unconfigure_ld
569571
fi
570572
fi
571573

@@ -696,12 +698,32 @@ install_components() {
696698
done
697699
}
698700

699-
maybe_run_ldconfig() {
701+
maybe_configure_ld() {
702+
local _abs_libdir="$1"
703+
700704
get_host_triple
701705
local _ostype="$RETVAL"
702706
assert_nz "$_ostype" "ostype"
703707

704708
if [ "$_ostype" = "unknown-linux-gnu" -a ! -n "${CFG_DISABLE_LDCONFIG-}" ]; then
709+
710+
# Fedora-based systems do not configure the dynamic linker to look
711+
# /usr/local/lib, which is our default installation directory. To
712+
# make things just work, try to put that directory in
713+
# /etc/ld.so.conf.d/rust-installer-v1 so ldconfig picks it up.
714+
# Issue #30.
715+
#
716+
# This will get rm'd when the last component is uninstalled in
717+
# maybe_unconfigure_ld.
718+
if [ "$_abs_libdir" = "/usr/local/lib" -a -d "/etc/ld.so.conf.d" ]; then
719+
echo "$_abs_libdir" > "/etc/ld.so.conf.d/rust-installer-v1-$TEMPLATE_REL_MANIFEST_DIR.conf"
720+
if [ $? -ne 0 ]; then
721+
# This shouldn't happen if we've gotten this far
722+
# installing to /usr/local
723+
warn "failed to update /etc/ld.so.conf.d. this is unexpected"
724+
fi
725+
fi
726+
705727
verbose_msg "running ldconfig"
706728
if [ -n "${CFG_VERBOSE-}" ]; then
707729
ldconfig
@@ -715,6 +737,19 @@ maybe_run_ldconfig() {
715737
fi
716738
}
717739

740+
maybe_unconfigure_ld() {
741+
get_host_triple
742+
local _ostype="$RETVAL"
743+
assert_nz "$_ostype" "ostype"
744+
745+
if [ "$_ostype" != "unknown-linux-gnu" ]; then
746+
return 0
747+
fi
748+
749+
rm "/etc/ld.so.conf.d/rust-installer-v1-$TEMPLATE_REL_MANIFEST_DIR.conf" 2> /dev/null
750+
# Above may fail since that file may not have been created on install
751+
}
752+
718753
# Doing our own 'install'-like backup that is consistent across platforms
719754
maybe_backup_path() {
720755
local _file_install_path="$1"
@@ -967,8 +1002,8 @@ install_uninstaller "$src_dir" "$src_basename" "$abs_libdir"
9671002
# Install each component
9681003
install_components "$src_dir" "$abs_libdir" "$dest_prefix" "$components"
9691004

970-
# Run ldconfig to make dynamic libraries available to the linker
971-
maybe_run_ldconfig
1005+
# Make dynamic libraries available to the linker
1006+
maybe_configure_ld "$abs_libdir"
9721007

9731008
echo
9741009
echo " $TEMPLATE_SUCCESS_MESSAGE"

0 commit comments

Comments
 (0)