[asterisk-commits] build: Execute ldconfig to build cache. (take two) (asterisk[14])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 24 12:10:37 CST 2017


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5081 )

Change subject: build: Execute ldconfig to build cache. (take two)
......................................................................


build: Execute ldconfig to build cache. (take two)

On some platforms a multiarch approach is used for libraries.
The build system does not take this into account and still
places libraries into the lib directory if no --libdir is
specified to configure. On initial startup this results in
libasteriskssl.so not being found, as it is not in the multiarch
lib directory.  To make matters worse, options were being passed
to ldconfig on both Linux and FreeBSD that actually prevented
the rebuild of the cache.

 * Fedora has a /usr/share/config.site that automatically tells
   autoconf to use /usr/lib64 but CentOS does not. This logic was
   copied to configure.ac and modified so systems like Ubuntu,
   which still use /usr/lib for 64-bit systems, aren't affected.

Now that we have them in the correct directory...

In order for the system loader to find libasteriskssl and
libasteriskpj, one of 3 things has to happen...

  - The linker cache must be rebuilt including the directory
    where the libasterisk* libraries were installed.  Only root
    can rebuild the cache.  This was busted.
  - We have to link the asterisk binary with an rpath pointing
    to the directrory where the libasterisk* libraries were
    installed.  This makes things very complicated and will happen
    over the collective dead bodies of everyone who's had to
    package a distribution with an rpath.
  - Finally, you can start asterisk with LD_LIBRARY_PATH set to the
    directrory where the libasterisk* libraries were installed.

There are no other options. So...

 * The invokation of ldconfig has been moved from main/Makefile
   to ASTTOPDIR/Makefile, the options have been removed, and
   DESTDIR/ASTLIBDIR appended.  If you aren't root, you will be
   warned after the "Asterisk Installation Compete" banner that
   you must re-run 'make install' as root, manually run
   'ldconfig DESTDIR/ASTLIBDIR' as root, or run asterisk with
   LD_LIBRARY_PATH.

ASTERISK-26705

Change-Id: I2a64b7c33a7d3e9bde20f47e3d3ab771977af982
---
M Makefile
M configure
M configure.ac
M main/Makefile
4 files changed, 65 insertions(+), 13 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, approved
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/Makefile b/Makefile
index 8e237e1..80845d5 100644
--- a/Makefile
+++ b/Makefile
@@ -182,11 +182,6 @@
 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
 OPTIONS=
 
-ifeq ($(OSARCH),linux-gnu)
-  # flag to tell 'ldconfig' to only process specified directories
-  LDCONFIG_FLAGS=-n
-endif
-
 ifeq ($(findstring -save-temps,$(_ASTCFLAGS) $(ASTCFLAGS)),)
   ifeq ($(findstring -pipe,$(_ASTCFLAGS) $(ASTCFLAGS)),)
     _ASTCFLAGS+=-pipe
@@ -222,8 +217,6 @@
   # -V is understood by BSD Make, not by GNU make.
   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
   _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
-  # flag to tell 'ldconfig' to only process specified directories
-  LDCONFIG_FLAGS=-m
 endif
 
 ifeq ($(OSARCH),NetBSD)
@@ -642,6 +635,23 @@
 		echo " WARNING WARNING WARNING" ;\
 	fi
 
+ld-cache-update:
+ifneq ($(LDCONFIG),)
+	@if [ $${EUID} -eq 0 ] ; then \
+		$(LDCONFIG) "$(DESTDIR)$(ASTLIBDIR)/" ; \
+	else \
+		echo " WARNING WARNING WARNING" ;\
+		echo "" ;\
+		echo " You cannot rebuild the system linker cache unless you are root. " ;\
+		echo " You MUST do one of the follwing..." ;\
+		echo "  * Re-run 'make install' as root. " ;\
+		echo "  * Run 'ldconfig $(DESTDIR)$(ASTLIBDIR)' as root. " ;\
+		echo "  * Run asterisk with 'LD_LIBRARY_PATH=$(DESTDIR)$(ASTLIBDIR) asterisk' " ;\
+		echo "" ;\
+		echo " WARNING WARNING WARNING" ;\
+	fi
+endif
+
 badshell:
 ifneq ($(filter ~%,$(DESTDIR)),)
 	@echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
@@ -680,6 +690,7 @@
 	@echo " + doxygen installed on your local system    +"
 	@echo " +-------------------------------------------+"
 	@$(MAKE) -s oldmodcheck
+	@$(MAKE) -s ld-cache-update
 
 isntall: install
 
@@ -912,6 +923,9 @@
 	rm -f $(DESTDIR)$(DAHDI_UDEV_HOOK_DIR)/40-asterisk
 endif
 	$(MAKE) -C sounds uninstall
+ifneq ($(LDCONFIG),)
+	$(LDCONFIG) || :
+endif
 
 uninstall: _uninstall
 	@echo " +--------- Asterisk Uninstall Complete -----+"
@@ -1042,6 +1056,7 @@
 .PHONY: ari-stubs
 .PHONY: basic-pbx
 .PHONY: check-alembic
+.PHONY: ld-cache-update
 .PHONY: $(SUBDIRS_INSTALL)
 .PHONY: $(SUBDIRS_DIST_CLEAN)
 .PHONY: $(SUBDIRS_CLEAN)
diff --git a/configure b/configure
index 44c7e07..5091f59 100755
--- a/configure
+++ b/configure
@@ -4887,6 +4887,28 @@
      fi
 fi
 
+#
+# The following code for detecting lib64 was taken from Fedora's
+# /usr/share/config.site with a modification to check that the
+# /usr/lib64 directory actually exists.  This prevents libdir from
+# being set to /usr/lib64 on 64-bit systems that still use /usr/lib.
+#
+if test "$prefix" = /usr ||\
+     { test "$prefix" = NONE && test "$ac_default_prefix" = /usr ; }
+then
+     for i in x86_64 ppc64 s390x aarch64; do
+        if test $host_cpu = $i; then
+           if test "$libdir" = '${exec_prefix}/lib' &&\
+              { test -d "${exec_prefix}/lib64" || test -d "${ac_default_prefix}/lib64" ; } ; then
+              libdir='${exec_prefix}/lib64'
+              { $as_echo "$as_me:${as_lineno-$LINENO}:  Setting libdir=${libdir} " >&5
+$as_echo "$as_me:  Setting libdir=${libdir} " >&6;}
+           fi
+           break
+        fi
+     done
+fi
+
 BUILD_PLATFORM=${build}
 BUILD_CPU=${build_cpu}
 BUILD_VENDOR=${build_vendor}
diff --git a/configure.ac b/configure.ac
index 74bc332..9727fb9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,6 +135,27 @@
      fi
 fi
 
+#
+# The following code for detecting lib64 was taken from Fedora's
+# /usr/share/config.site with a modification to check that the
+# /usr/lib64 directory actually exists.  This prevents libdir from
+# being set to /usr/lib64 on 64-bit systems that still use /usr/lib.
+#
+if test "$prefix" = /usr ||\
+     { test "$prefix" = NONE && test "$ac_default_prefix" = /usr ; }
+then
+     for i in x86_64 ppc64 s390x aarch64; do
+        if test $host_cpu = $i; then
+           if test "$libdir" = '${exec_prefix}/lib' &&\
+              { test -d "${exec_prefix}/lib64" || test -d "${ac_default_prefix}/lib64" ; } ; then
+              libdir='${exec_prefix}/lib64'
+              AC_MSG_NOTICE([ Setting libdir=${libdir} ])
+           fi
+           break
+        fi
+     done
+fi
+
 BUILD_PLATFORM=${build}
 BUILD_CPU=${build_cpu}
 BUILD_VENDOR=${build_vendor}
diff --git a/main/Makefile b/main/Makefile
index 4d1b2c4..d3463f7 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -354,9 +354,6 @@
 	$(INSTALL) -m 755 $(ASTPJ_LIB) "$(DESTDIR)$(ASTLIBDIR)/"
 endif
 endif
-ifneq ($(LDCONFIG),)
-	$(LDCONFIG) $(LDCONFIG_FLAGS) "$(DESTDIR)$(ASTLIBDIR)/"
-endif
 	$(LN) -sf asterisk "$(DESTDIR)$(ASTSBINDIR)/rasterisk"
 
 binuninstall:
@@ -371,9 +368,6 @@
 #   ASTSSL_SO_VERSION may not exist on Darwin
 	rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTPJ_LIB).$(ASTPJ_SO_VERSION)" || :
 	rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTPJ_LIB)"
-endif
-ifneq ($(LDCONFIG),)
-	$(LDCONFIG) $(LDCONFIG_FLAGS) "$(DESTDIR)$(ASTLIBDIR)/"
 endif
 
 clean::

-- 
To view, visit https://gerrit.asterisk.org/5081
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2a64b7c33a7d3e9bde20f47e3d3ab771977af982
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list