[OE-core] [PATCH 1/2] ldconfig: add method to extend ldconfig search dirs

Armin Kuster akuster808 at gmail.com
Wed Nov 11 17:41:46 UTC 2015


From: Armin Kuster <akuster at mvista.com>

this provides a method to extend the search path ldconfig-native
uses when creating ls.so.cache.

To enable in recipe:

add:
inherit ldconfig

LDSOCONF = "/opt/lib"

this will create a ld.so.conf file in work-shared/ldconfig/${PN}/

to create an image with these new search paths included, add to local.conf:

INHERIT += "image-ldconfig"

this will take all the ${PN}/ld.so.conf files and create a single ld.so.conf
that will be used by ldconfig-native when building an image.

Signed-off-by: Armin Kuster <akuster at mvista.com>
---
 meta/classes/image-ldconfig.bbclass | 26 ++++++++++++++++++++++++++
 meta/classes/ldconfig.bbclass       | 27 +++++++++++++++++++++++++++
 meta/conf/bitbake.conf              |  5 +++++
 3 files changed, 58 insertions(+)
 create mode 100644 meta/classes/image-ldconfig.bbclass
 create mode 100644 meta/classes/ldconfig.bbclass

diff --git a/meta/classes/image-ldconfig.bbclass b/meta/classes/image-ldconfig.bbclass
new file mode 100644
index 0000000..e9946da
--- /dev/null
+++ b/meta/classes/image-ldconfig.bbclass
@@ -0,0 +1,26 @@
+#
+# To enable, use INHERIT in local.conf:
+#
+#       INHERIT += "image-ldconfig"
+
+do_rootfs[depends] += "ldconfig-native:do_populate_sysroot"
+
+IMAGE_PREPROCESS_COMMAND += "ld_so_conf; "
+
+ld_so_conf() {
+
+    rm -f ${STAGING_DIR_NATIVE}${sysconfdir_native}/ld.so.conf
+
+    # save lib dirs as defined in recipes
+    for file in `find ${STAGING_LDSO_CONF_DIR}/*/* -name "ld.so.conf"`;
+    do
+        cat ${file} >> ${STAGING_LDSO_CONF_DIR}/ld.so.conf
+    done
+
+    # remove dups and sort
+    cat ${STAGING_LDSO_CONF_DIR}/ld.so.conf | sort -u > ${IMAGE_ROOTFS}/etc/ld.so.conf
+
+    # this seems to work if at rootfs location.
+    cd ${IMAGE_ROOTFS}
+    ${STAGING_DIR_NATIVE}${bindir_native}/ldconfig -r . -c new -f etc/ld.so.conf 
+}
diff --git a/meta/classes/ldconfig.bbclass b/meta/classes/ldconfig.bbclass
new file mode 100644
index 0000000..558122f
--- /dev/null
+++ b/meta/classes/ldconfig.bbclass
@@ -0,0 +1,27 @@
+# Allows adding libs or alt lib locations to be included
+# during ld.so.cache creation.
+#
+#
+
+do_package[postfuncs] += "save_ld_so_conf "
+do_clean[cleandirs] += "${STAGING_LDSO_CONF_DIR}/${PN} "
+
+python save_ld_so_conf() {
+    import os
+
+    if (d.getVar('USE_LDCONFIG', True) or "1") == "1":
+        ldsodir = d.getVar('STAGING_LDSO_CONF_DIR', True)
+        if not os.path.isdir(ldsodir):
+            os.mkdir(ldsodir)
+    
+        staging_ld = os.path.join(ldsodir, d.expand("${PN}"))
+        if not os.path.isdir(staging_ld):
+            os.mkdir(staging_ld)
+
+        ldsofile = os.path.join(staging_ld, 'ld.so.conf')
+
+        ldconf = d.getVar('LDSOCONF', True).split()
+        with open(ldsofile, 'w') as lsdo:
+            for ldso_entry in ldconf:
+                lsdo.write(ldso_entry+"\n")
+}
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 06971da..f0471f4 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -811,3 +811,8 @@ BB_SIGNATURE_EXCLUDE_FLAGS ?= "doc deps depends \
 
 MLPREFIX ??= ""
 MULTILIB_VARIANTS ??= ""
+
+# 
+# ldconfig stuff
+#
+STAGING_LDSO_CONF_DIR = "${TMPDIR}/work-shared/ldconfig"
-- 
2.3.5




More information about the Openembedded-core mailing list