Patchwork [1/1] Add support for ld.so.conf.d

login
register
mail settings
Submitter Peter Seebach
Date July 28, 2014, 6:39 p.m.
Message ID <c49369320ca271d42175888f5b9daccf45c297bf.1406572002.git.peter.seebach@windriver.com>
Download mbox | patch
Permalink /patch/76775/
State New
Headers show

Comments

Peter Seebach - July 28, 2014, 6:39 p.m.
The default behavior for USE_LDCONFIG is to use an empty ld.so.conf.
In some cases, it might be desireable to have an ld.so.conf.d directory,
and inherit files from there. This is a common enough use case to
justify support in the recipe, but not common enough to make it the
default. So, eglibc gets a new USE_LDCONFIG_CONF_D value, default 0.
If it's set to 1, we create the directory and add an "include" line
for it to ld.so.conf.

Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
---
 meta/recipes-core/eglibc/eglibc-package.inc |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
Khem Raj - July 28, 2014, 6:47 p.m.
On Mon, Jul 28, 2014 at 11:39 AM, Peter Seebach
<peter.seebach@windriver.com> wrote:
> The default behavior for USE_LDCONFIG is to use an empty ld.so.conf.
> In some cases, it might be desireable to have an ld.so.conf.d directory,
> and inherit files from there. This is a common enough use case to
> justify support in the recipe, but not common enough to make it the
> default. So, eglibc gets a new USE_LDCONFIG_CONF_D value, default 0.
> If it's set to 1, we create the directory and add an "include" line
> for it to ld.so.conf.

the patch is good but introducing another variable is not needed you
can cover it under US_LDCONFIG itself, ldconfig with empty ld.so.conf
will still parse standard lib search paths anyway

Secondly when we use ldconfig it generates ld.so.cache under /etc
so I hope we take care of this when we have ro-rootfs
Mark Hatle - July 28, 2014, 6:59 p.m.
On 7/28/14, 1:47 PM, Khem Raj wrote:
> On Mon, Jul 28, 2014 at 11:39 AM, Peter Seebach
> <peter.seebach@windriver.com> wrote:
>> The default behavior for USE_LDCONFIG is to use an empty ld.so.conf.
>> In some cases, it might be desireable to have an ld.so.conf.d directory,
>> and inherit files from there. This is a common enough use case to
>> justify support in the recipe, but not common enough to make it the
>> default. So, eglibc gets a new USE_LDCONFIG_CONF_D value, default 0.
>> If it's set to 1, we create the directory and add an "include" line
>> for it to ld.so.conf.
>
> the patch is good but introducing another variable is not needed you
> can cover it under US_LDCONFIG itself, ldconfig with empty ld.so.conf
> will still parse standard lib search paths anyway
>
> Secondly when we use ldconfig it generates ld.so.cache under /etc
> so I hope we take care of this when we have ro-rootfs
>

In a read-only root case, the ld.so.cache is generated in the cross environment. 
  I don't know if the cross ldconfig knows about the includes though.  Someone 
will have to check that.

--Mark
Peter Seebach - July 28, 2014, 7:03 p.m.
On Mon, 28 Jul 2014 11:47:30 -0700
Khem Raj <raj.khem@gmail.com> wrote:

> the patch is good but introducing another variable is not needed you
> can cover it under US_LDCONFIG itself, ldconfig with empty ld.so.conf
> will still parse standard lib search paths anyway

The reason I wanted another variable is to control the creation of a
*non-empty* ld.so.conf that would pick up other config files. The idea
is that if you wanted to add a non-standard library search path, you
could create a file in ld.so.conf.d. I didn't want to make the file
have contents unconditionally.
 
> Secondly when we use ldconfig it generates ld.so.cache under /etc
> so I hope we take care of this when we have ro-rootfs

I assume that's already working for the existing empty ld.so.conf you get
with USE_LDCONFIG=1.

It does occur to me that I don't know whether our cross-ldconfig knows
this syntax. I'll double-check that.

-s
Peter Seebach - July 28, 2014, 8:55 p.m.
On Mon, 28 Jul 2014 13:59:20 -0500
Mark Hatle <mark.hatle@windriver.com> wrote:

> In a read-only root case, the ld.so.cache is generated in the cross environment. 
>   I don't know if the cross ldconfig knows about the includes though.  Someone 
> will have to check that.

It appears to be the same source, so it has the functionality at least in the
code.

-s

Patch

diff --git a/meta/recipes-core/eglibc/eglibc-package.inc b/meta/recipes-core/eglibc/eglibc-package.inc
index c357a13..8026199 100644
--- a/meta/recipes-core/eglibc/eglibc-package.inc
+++ b/meta/recipes-core/eglibc/eglibc-package.inc
@@ -16,6 +16,9 @@  python __anonymous () {
 
 # Set this to zero if you don't want ldconfig in the output package
 USE_LDCONFIG ?= "1"
+# Set this to one if you want ld.so.conf to include ld.so.conf.d/*
+# by default.
+USE_LDCONFIG_CONF_D ?= "0"
 
 PACKAGES = "${PN}-dbg catchsegv sln nscd ldd tzcode ${PN}-utils eglibc-thread-db ${PN}-pic libcidn libmemusage libsegfault ${PN}-pcprofile libsotruss ${PN} eglibc-extra-nss ${PN}-dev ${PN}-staticdev ${PN}-doc"
 
@@ -33,7 +36,7 @@  RPROVIDES_${PN}-pcprofile = "glibc-pcprofile"
 RPROVIDES_${PN}-dbg = "glibc-dbg"
 libc_baselibs = "${base_libdir}/libcrypt*.so.* ${base_libdir}/libcrypt-*.so ${base_libdir}/libc.so.* ${base_libdir}/libc-*.so ${base_libdir}/libm*.so.* ${base_libdir}/libm-*.so ${base_libdir}/ld*.so.* ${base_libdir}/ld-*.so ${base_libdir}/libpthread*.so.* ${base_libdir}/libpthread-*.so ${base_libdir}/libresolv*.so.* ${base_libdir}/libresolv-*.so ${base_libdir}/librt*.so.* ${base_libdir}/librt-*.so ${base_libdir}/libutil*.so.* ${base_libdir}/libutil-*.so ${base_libdir}/libnsl*.so.* ${base_libdir}/libnsl-*.so ${base_libdir}/libnss_files*.so.* ${base_libdir}/libnss_files-*.so ${base_libdir}/libnss_compat*.so.* ${base_libdir}/libnss_compat-*.so ${base_libdir}/libnss_dns*.so.* ${base_libdir}/libnss_dns-*.so ${base_libdir}/libdl*.so.* ${base_libdir}/libdl-*.so ${base_libdir}/libanl*.so.* ${base_libdir}/libanl-*.so ${base_libdir}/libBrokenLocale*.so.* ${base_libdir}/libBrokenLocale-*.so"
 
-FILES_${PN} = "${libc_baselibs} ${libexecdir}/* ${@base_conditional('USE_LDCONFIG', '1', '${base_sbindir}/ldconfig ${sysconfdir}/ld.so.conf', '', d)}"
+FILES_${PN} = "${libc_baselibs} ${libexecdir}/* ${@base_conditional('USE_LDCONFIG', '1', '${base_sbindir}/ldconfig ${sysconfdir}/ld.so.conf ${sysconfdir}/ld.so.conf.d', '', d)}"
 FILES_ldd = "${bindir}/ldd"
 FILES_libsegfault = "${base_libdir}/libSegFault*"
 FILES_libcidn = "${base_libdir}/libcidn-*.so ${base_libdir}/libcidn.so.*"
@@ -99,6 +102,11 @@  do_install_append () {
 		if [ -d ${D}${sysconfdir} ]; then
 			rmdir ${D}${sysconfdir}
 		fi
+	else
+		if [ "${USE_LDCONFIG_CONF_D}" = "1" ]; then
+			mkdir -p ${D}${sysconfdir}/ld.so.conf.d
+			echo "include  ld.so.conf.d/*.conf" >> ${D}${sysconfdir}/ld.so.conf
+		fi
 	fi
 }