[OE-core] [PATCH v2 3/3] base-files: create typical merged /usr symlinks if the "merged-usr" distro feature is set

Matthias Schiffer mschiffer at universe-factory.net
Sat Jan 2 23:53:01 UTC 2016


The typical symlinks are:

* /bin -> usr/bin
* /sbin -> usr/sbin
* /lib -> usr/lib
* /usr/sbin -> bin

It is checked that only sane symlinks are created, so a half-merged /usr
(e.g, merging bin and sbin, but not lib) is feasible as well.

The following options in a distro configuration create a full Fedora-style
merged /usr:

  DISTRO_FEATURES_DEFAULT += "merged-usr"
  base_bindir = "${exec_prefix}/bin"
  base_sbindir = "${exec_prefix}/bin"
  sbindir = "${exec_prefix}/bin"
  base_libdir = "${exec_prefix}/${baselib}"
  nonarch_base_libdir = "${exec_prefix}/lib"

[YOCTO #7040]

Signed-off-by: Matthias Schiffer <mschiffer at universe-factory.net>
---
v2:
* add the merged-usr symlinks in a separate task, so do_install can be
  overridden independently of the merged-usr feature.
* add PACKAGECONFIG for merged-usr, so the package is rebuilt when the
  distro feature is changed.


 meta/recipes-core/base-files/base-files_3.0.14.bb | 36 +++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/meta/recipes-core/base-files/base-files_3.0.14.bb b/meta/recipes-core/base-files/base-files_3.0.14.bb
index 2af7ecd..21a740f 100644
--- a/meta/recipes-core/base-files/base-files_3.0.14.bb
+++ b/meta/recipes-core/base-files/base-files_3.0.14.bb
@@ -30,6 +30,13 @@ S = "${WORKDIR}"
 
 INHIBIT_DEFAULT_DEPS = "1"
 
+PACKAGECONFIG ??= " \
+                   ${@bb.utils.contains('DISTRO_FEATURES', 'merged-usr','merged-usr', '', d)} \
+"
+
+PACKAGECONFIG[merged-usr] = ",,"
+
+
 docdir_append = "/${P}"
 dirs1777 = "/tmp ${localstatedir}/volatile/tmp"
 dirs2775 = ""
@@ -136,6 +143,35 @@ do_install () {
 	ln -sf /proc/mounts ${D}${sysconfdir}/mtab
 }
 
+do_install_merged_usr () {
+	if ${@bb.utils.contains('PACKAGECONFIG','merged-usr','false','true',d)}; then
+		return
+	fi
+
+	if [ "${base_bindir}" != "/bin" ]; then
+		ln -snf "${@d.getVar('base_bindir', True)[1:]}" ${D}/bin
+	fi
+
+	if [ "${base_sbindir}" != "/sbin"  ]; then
+		ln -snf "${@d.getVar('base_sbindir', True)[1:]}" ${D}/sbin
+	fi
+
+	if [ "${nonarch_base_libdir}" != "/lib" ]; then
+		ln -snf "${@d.getVar('nonarch_base_libdir', True)[1:]}" ${D}/lib
+	fi
+
+	if [ "${base_libdir}" != "/${baselib}" ]; then
+		ln -snf "${@d.getVar('base_libdir', True)[1:]}" ${D}/${baselib}
+	fi
+
+	if [ "${bindir}" = "${exec_prefix}/bin" -a "${sbindir}" = "${exec_prefix}/bin" ]; then
+		ln -snf bin ${D}${exec_prefix}/sbin
+	fi
+}
+
+addtask install_merged_usr after do_install before do_package do_populate_sysroot
+
+
 DISTRO_VERSION[vardepsexclude] += "DATE"
 do_install_basefilesissue () {
 	if [ "${hostname}" ]; then
-- 
2.6.4




More information about the Openembedded-core mailing list