Skip to contentSkip to conversation

binconfig.bbclass: fix multilib file conflicts

PATCH In review Ming Liu 1 participant 2 messages Nov 25, 2014

lore
Share & tools
lore

Ming Liu

author
#0 lore raw

PATCH 1/1 binconfig.bbclass: fix multilib file conflicts

In a lot of cases binconfig files refer to multilib particular paths like ${base_libdir}, ${libdir}, this would certainly cause files conflict among multilib packages when they are involved in the image, for instance:
with following lines:
......
IMAGE_INSTALL_append = " curl"
IMAGE_INSTALL_append = " lib32-curl"
......

$ bitbake ${DEFAULT_IMAGE} -c populate_sdk

The above task would fail due to the file conflicts between multilib binconfigs.

I know the situation is that most of the binconfig usage were removed from recipes, but there are still some not in the case, and we also need take account of the cases that some recipes may need it for their own purpose.

This patch aims to use update-alternatives link *-config from real path with a PACKAGE_ARCH suffix to avoid the conflicts, which will shore up the binconfig.bbclass without introducing any harmness.

---
 meta/classes/binconfig.bbclass           | 81 ++++++++++++++++++++++++++++++++
 meta/recipes-devtools/tcltk/tcl_8.6.3.bb |  1 +
 2 files changed, 82 insertions(+)
meta/classes/binconfig.bbclass +81 -0
index abeda57..b8cc518 100644
@@ -1,4 +1,5 @@
 BINCONFIG_FILES ?= "${bindir}/*-config"
+BINCONFIG_FILES_class-target ?= "${bindir}/*-config.${PACKAGE_ARCH}"
 FILES_${PN}-dev += "${BINCONFIG_FILES}"
  
 # The namespaces can clash here hence the two step replace
@@ -27,9 +28,21 @@ def get_binconfig_mangle(d):
 
     return s
 
+python __anonymous() {
+    # Update Alternatives are only used on target packages
+    if bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d) or \
+       bb.data.inherits_class('cross', d) or bb.data.inherits_class('crosssdk', d) or \
+       bb.data.inherits_class('cross-canadian', d):
+        return
+
+    if not 'virtual/update-alternatives' in d.getVar('PROVIDES', True):
+        d.appendVar('DEPENDS', ' virtual/${MLPREFIX}update-alternatives')
+}
+
 BINCONFIG_GLOB ?= "*-config"
 
 PACKAGE_PREPROCESS_FUNCS += "binconfig_package_preprocess"
+PACKAGE_PREPROCESS_FUNCS_append_class-target = " binconfig_rename_package_preprocess"
 
 binconfig_package_preprocess () {
 	for config in `find ${PKGD} -name '${BINCONFIG_GLOB}'`; do
@@ -54,6 +67,74 @@ binconfig_package_preprocess () {
 	done	    
 }
 
+binconfig_rename_package_preprocess () {
+	binconfig_files=`echo ${BINCONFIG_FILES} | sed 's:\.${PACKAGE_ARCH}::'`
+	for config in `find ${PKGD} -wholename ${PKGD}$binconfig_files`; do
+		if [ -h $config ]; then
+			real_config=`readlink $config`
+			unlink $config
+			( cd ${PKGD}${bindir} ; ln -sf $real_config.${PACKAGE_ARCH} $config.${PACKAGE_ARCH} )
+		else
+			mv $config $config.${PACKAGE_ARCH}
+		fi
+	done
+}
+
+BINCONFIG_PRIORITY ?= "10"
+
+PACKAGESPLITFUNCS_prepend_class-target = "populate_packages_binconfig "
+
+#
+# Fix binconfig conflicts among multilib packages
+#
+python populate_packages_binconfig () {
+    import os, glob
+
+    pkg = d.getVar('PN', True) + '-dev'
+    dvar = d.getVar('PKGD', True)
+    binconfig_files = d.getVar('BINCONFIG_FILES', True)
+    binconfig_priority = d.getVar('BINCONFIG_PRIORITY', True)
+    binconfig_setup_links = ""
+    binconfig_remove_links = ""
+    for file in glob.glob('%s%s' % (dvar, binconfig_files)):
+        binconfig_target = os.path.basename(file)
+        binconfig_name = binconfig_target[:binconfig_target.find('.')]
+        binconfig_link = file[:file.rfind('.')].replace(dvar, "")
+        binconfig_setup_links += '\tupdate-alternatives --install %s %s %s %s\n' % (binconfig_link, binconfig_name, binconfig_target, binconfig_priority)
+        binconfig_remove_links += '\tupdate-alternatives --remove  %s %s\n' % (binconfig_name, binconfig_target)
+
+        if binconfig_setup_links:
+            provider = d.getVar('VIRTUAL-RUNTIME_update-alternatives', True)
+            if provider:
+                d.appendVar('RDEPENDS_%s' % pkg, ' ' + d.getVar('MLPREFIX') + provider)
+
+            postinst = d.getVar('pkg_postinst_%s' % pkg, True) or '#!/bin/sh\n'
+            postinst += binconfig_setup_links
+            d.setVar('pkg_postinst_%s' % pkg, postinst)
+
+            postrm = d.getVar('pkg_postrm_%s' % pkg, True) or '#!/bin/sh\n'
+            postrm += binconfig_remove_links
+            d.setVar('pkg_postrm_%s' % pkg, postrm)
+}
+
+python package_do_filedeps_append_class-target () {
+    import glob
+
+    pkg = d.getVar('PN', True) + '-dev'
+    pkgdest = d.getVar('PKGDEST', True)
+    binconfig_files = d.getVar('BINCONFIG_FILES', True)
+
+    for file in glob.glob('%s/%s%s' % (pkgdest, pkg, binconfig_files)):
+        binconfig_target = os.path.basename(file)
+        binconfig_link = file[:file.rfind('.')].replace(pkgdest + os.sep + pkg, "")
+
+        # Add file provide
+        trans_target = oe.package.file_translate('%s' % file.replace(pkgdest + os.sep + pkg, ""))
+        d.appendVar('FILERPROVIDES_%s_%s' % (trans_target, pkg), " " + binconfig_link)
+        if not trans_target in (d.getVar('FILERPROVIDESFLIST_%s' % pkg, True) or ""):
+            d.appendVar('FILERPROVIDESFLIST_%s' % pkg, " " + trans_target)
+}
+
 SYSROOT_PREPROCESS_FUNCS += "binconfig_sysroot_preprocess"
 
 binconfig_sysroot_preprocess () {
meta/recipes-devtools/tcltk/tcl_8.6.3.bb +1 -0
index 27197fa..055b9cf 100644
@@ -92,6 +92,7 @@ do_install_ptest() {
 # Fix some paths that might be used by Tcl extensions
 BINCONFIG_GLOB = "*Config.sh"
 BINCONFIG_FILES = "${bindir}/*Config.sh"
+BINCONFIG_FILES_class-target = "${bindir}/*Config.sh.${PACKAGE_ARCH}"
 
 # Fix the path in sstate
 SSTATE_SCAN_FILES += "*Config.sh"
Signature · 1 line
1.8.4.1
author
#1 lore raw

This path is after my previous review request "[OE-core] [PATCH 1/3] binconfig.bbclass: introduce BINCONFIG_FILES variable".

//Ming Liu

Quoted 147 lines · Ming Liu

In a lot of cases binconfig files refer to multilib particular paths like ${base_libdir}, ${libdir}, this would certainly cause files conflict among multilib packages when they are involved in the image, for instance:
with following lines:
......
IMAGE_INSTALL_append = " curl"
IMAGE_INSTALL_append = " lib32-curl"
......

$ bitbake ${DEFAULT_IMAGE} -c populate_sdk

The above task would fail due to the file conflicts between multilib binconfigs.

I know the situation is that most of the binconfig usage were removed from recipes, but there are still some not in the case, and we also need take account of the cases that some recipes may need it for their own purpose.

This patch aims to use update-alternatives link *-config from real path with a PACKAGE_ARCH suffix to avoid the conflicts, which will shore up the binconfig.bbclass without introducing any harmness.

---
  meta/classes/binconfig.bbclass           | 81 ++++++++++++++++++++++++++++++++
  meta/recipes-devtools/tcltk/tcl_8.6.3.bb |  1 +
  2 files changed, 82 insertions(+)
meta/classes/binconfig.bbclass +81 -0
index abeda57..b8cc518 100644
@@ -1,4 +1,5 @@
  BINCONFIG_FILES ?= "${bindir}/*-config"
+BINCONFIG_FILES_class-target ?= "${bindir}/*-config.${PACKAGE_ARCH}"
  FILES_${PN}-dev += "${BINCONFIG_FILES}"
 
  # The namespaces can clash here hence the two step replace
@@ -27,9 +28,21 @@ def get_binconfig_mangle(d):
 
      return s
 
+python __anonymous() {
+    # Update Alternatives are only used on target packages
+    if bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d) or \
+       bb.data.inherits_class('cross', d) or bb.data.inherits_class('crosssdk', d) or \
+       bb.data.inherits_class('cross-canadian', d):
+        return
+
+    if not 'virtual/update-alternatives' in d.getVar('PROVIDES', True):
+        d.appendVar('DEPENDS', ' virtual/${MLPREFIX}update-alternatives')
+}
+
  BINCONFIG_GLOB ?= "*-config"
 
  PACKAGE_PREPROCESS_FUNCS += "binconfig_package_preprocess"
+PACKAGE_PREPROCESS_FUNCS_append_class-target = " binconfig_rename_package_preprocess"
 
  binconfig_package_preprocess () {
  	for config in `find ${PKGD} -name '${BINCONFIG_GLOB}'`; do
@@ -54,6 +67,74 @@ binconfig_package_preprocess () {
  	done	
  }
 
+binconfig_rename_package_preprocess () {
+	binconfig_files=`echo ${BINCONFIG_FILES} | sed 's:\.${PACKAGE_ARCH}::'`
+	for config in `find ${PKGD} -wholename ${PKGD}$binconfig_files`; do
+		if [ -h $config ]; then
+			real_config=`readlink $config`
+			unlink $config
+			( cd ${PKGD}${bindir} ; ln -sf $real_config.${PACKAGE_ARCH} $config.${PACKAGE_ARCH} )
+		else
+			mv $config $config.${PACKAGE_ARCH}
+		fi
+	done
+}
+
+BINCONFIG_PRIORITY ?= "10"
+
+PACKAGESPLITFUNCS_prepend_class-target = "populate_packages_binconfig "
+
+#
+# Fix binconfig conflicts among multilib packages
+#
+python populate_packages_binconfig () {
+    import os, glob
+
+    pkg = d.getVar('PN', True) + '-dev'
+    dvar = d.getVar('PKGD', True)
+    binconfig_files = d.getVar('BINCONFIG_FILES', True)
+    binconfig_priority = d.getVar('BINCONFIG_PRIORITY', True)
+    binconfig_setup_links = ""
+    binconfig_remove_links = ""
+    for file in glob.glob('%s%s' % (dvar, binconfig_files)):
+        binconfig_target = os.path.basename(file)
+        binconfig_name = binconfig_target[:binconfig_target.find('.')]
+        binconfig_link = file[:file.rfind('.')].replace(dvar, "")
+        binconfig_setup_links += '\tupdate-alternatives --install %s %s %s %s\n' % (binconfig_link, binconfig_name, binconfig_target, binconfig_priority)
+        binconfig_remove_links += '\tupdate-alternatives --remove  %s %s\n' % (binconfig_name, binconfig_target)
+
+        if binconfig_setup_links:
+            provider = d.getVar('VIRTUAL-RUNTIME_update-alternatives', True)
+            if provider:
+                d.appendVar('RDEPENDS_%s' % pkg, ' ' + d.getVar('MLPREFIX') + provider)
+
+            postinst = d.getVar('pkg_postinst_%s' % pkg, True) or '#!/bin/sh\n'
+            postinst += binconfig_setup_links
+            d.setVar('pkg_postinst_%s' % pkg, postinst)
+
+            postrm = d.getVar('pkg_postrm_%s' % pkg, True) or '#!/bin/sh\n'
+            postrm += binconfig_remove_links
+            d.setVar('pkg_postrm_%s' % pkg, postrm)
+}
+
+python package_do_filedeps_append_class-target () {
+    import glob
+
+    pkg = d.getVar('PN', True) + '-dev'
+    pkgdest = d.getVar('PKGDEST', True)
+    binconfig_files = d.getVar('BINCONFIG_FILES', True)
+
+    for file in glob.glob('%s/%s%s' % (pkgdest, pkg, binconfig_files)):
+        binconfig_target = os.path.basename(file)
+        binconfig_link = file[:file.rfind('.')].replace(pkgdest + os.sep + pkg, "")
+
+        # Add file provide
+        trans_target = oe.package.file_translate('%s' % file.replace(pkgdest + os.sep + pkg, ""))
+        d.appendVar('FILERPROVIDES_%s_%s' % (trans_target, pkg), " " + binconfig_link)
+        if not trans_target in (d.getVar('FILERPROVIDESFLIST_%s' % pkg, True) or ""):
+            d.appendVar('FILERPROVIDESFLIST_%s' % pkg, " " + trans_target)
+}
+
  SYSROOT_PREPROCESS_FUNCS += "binconfig_sysroot_preprocess"
 
  binconfig_sysroot_preprocess () {
meta/recipes-devtools/tcltk/tcl_8.6.3.bb +1 -0
index 27197fa..055b9cf 100644
@@ -92,6 +92,7 @@ do_install_ptest() {
  # Fix some paths that might be used by Tcl extensions
  BINCONFIG_GLOB = "*Config.sh"
  BINCONFIG_FILES = "${bindir}/*Config.sh"
+BINCONFIG_FILES_class-target = "${bindir}/*Config.sh.${PACKAGE_ARCH}"
 
  # Fix the path in sstate
  SSTATE_SCAN_FILES += "*Config.sh"