Skip to contentSkip to conversation

base.bbclass: Update the preferred_ml_updates

PATCH New Mark Hatle 1 participant 2 messages Mar 19, 2013

lore
Share & tools
lore

Mark Hatle

author
#0 lore raw

cover base.bbclass: Update the preferred_ml_updates

While working on a problem related to variable key expansion, I noticed that the multilib PREFERRED_* expansion wasn't working exactly the way it should have. This patch addresses that issue. Below is a diff of PREFERRED_* entries before and after this patch.

@@ -58,11 +58,6 @@
PREFERRED_PROVIDER_virtual/lib32-libiconv="lib32-eglibc" PREFERRED_PROVIDER_virtual/lib32-libintl="lib32-eglibc" PREFERRED_PROVIDER_virtual/lib32-libx11="lib32-libx11"
-PREFERRED_PROVIDER_virtual/lib32-nativesdk-libc="lib32-nativesdk-eglibc" -PREFERRED_PROVIDER_virtual/lib32-nativesdk-libiconv="lib32-nativesdk-eglibc" -PREFERRED_PROVIDER_virtual/lib32-nativesdk-libintl="lib32-nativesdk-eglibc" -PREFERRED_PROVIDER_virtual/lib32-nativesdk-x86_64-oesdk-linux-libc-for-gcc="lib32-nativesdk-eglibc" -PREFERRED_PROVIDER_virtual/lib32-nativesdk-x86_64-oesdk-linux-libc-initial="lib32-nativesdk-eglibc-initial"
PREFERRED_PROVIDER_virtual/lib32-update-alternatives="lib32-opkg" PREFERRED_PROVIDER_virtual/lib32-xserver="lib32-xserver-xorg" PREFERRED_PROVIDER_virtual/lib32-xserver-xf86="lib32-xserver-xorg"
@@ -77,9 +72,7 @@
PREFERRED_PROVIDER_virtual/nativesdk-libc="nativesdk-eglibc" PREFERRED_PROVIDER_virtual/nativesdk-libiconv="nativesdk-eglibc" PREFERRED_PROVIDER_virtual/nativesdk-libintl="nativesdk-eglibc"
-PREFERRED_PROVIDER_virtual/nativesdk-x86_64-oesdk-linux-libc-for-gcc="lib32-nativesdk-eglibc"
PREFERRED_PROVIDER_virtual/nativesdk-x86_64-oesdk-linux-libc-for-gcc="nativesdk-eglibc"
-PREFERRED_PROVIDER_virtual/nativesdk-x86_64-oesdk-linux-libc-initial="lib32-nativesdk-eglibc-initial"
PREFERRED_PROVIDER_virtual/nativesdk-x86_64-oesdk-linux-libc-initial="nativesdk-eglibc-initial" PREFERRED_PROVIDER_virtual/update-alternatives-native="opkg-native" PREFERRED_PROVIDER_virtual/update-alternatives="opkg"

author
#1 lore raw

PATCH 1/1 base.bbclass: Update the preferred_ml_updates

When processing the blacklists, we should avoid cross-canadian packages, as they will not have any multilib prefixes to expand.

Similarly look for "virtual/nativesdk-" in addition to the existing "nativesdk-". These items should also be ignored.

Finally, in order to avoid undeterministic variable key expansion, such as:

MYVAR = "foo"

PREFERRED_PROVIDER_${MYVAR} = "bar"
PREFERRED_PROVIDER_foo = "foobar"

during the multilib processing of PREFERRED_VERSION and PREFERRED_PROVIDER, the code was changed to rename the variable key, to the final key. This along with the existing code avoids the problems.

---
 meta/classes/base.bbclass | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
meta/classes/base.bbclass +18 -6
index 5fe9a84..181bcfe 100644
@@ -162,7 +162,7 @@ def preferred_ml_updates(d):
             providers.append(v)
 
     for pkg, reason in blacklists.items():
-        if pkg.endswith(("-native", "-crosssdk")) or pkg.startswith("nativesdk-") or 'cross-canadian' in pkg:
+        if pkg.endswith(("-native", "-crosssdk")) or pkg.startswith(("nativesdk-", "virtual/nativesdk-")) or 'cross-canadian' in pkg:
             continue
         for p in prefixes:
             newpkg = p + "-" + pkg
@@ -172,7 +172,7 @@ def preferred_ml_updates(d):
     for v in versions:
         val = d.getVar(v, False)
         pkg = v.replace("PREFERRED_VERSION_", "")
-        if pkg.endswith(("-native", "-crosssdk")) or pkg.startswith("nativesdk-"):
+        if pkg.endswith(("-native", "-crosssdk")) or pkg.startswith(("nativesdk-", "virtual/nativesdk-")):
             continue
         if 'cross-canadian' in pkg:
             for p in prefixes:
@@ -182,8 +182,12 @@ def preferred_ml_updates(d):
                 bb.data.update_data(localdata)
                 newname = localdata.expand(v)
                 if newname != v:
-                    newval = localdata.getVar(v, True)
+                    newval = localdata.expand(val)
                     d.setVar(newname, newval)
+            # Avoid future variable key expansion
+            vexp = d.expand(v)
+            if v != vexp and d.getVar(v, False):
+                d.renameVar(v, vexp)
             continue
         for p in prefixes:
             newname = "PREFERRED_VERSION_" + p + "-" + pkg
@@ -193,7 +197,7 @@ def preferred_ml_updates(d):
     for prov in providers:
         val = d.getVar(prov, False)
         pkg = prov.replace("PREFERRED_PROVIDER_", "")
-        if pkg.endswith(("-native", "-crosssdk")) or pkg.startswith("nativesdk-"):
+        if pkg.endswith(("-native", "-crosssdk")) or pkg.startswith(("nativesdk-", "virtual/nativesdk-")):
             continue
         if 'cross-canadian' in pkg:
             for p in prefixes:
@@ -205,6 +209,10 @@ def preferred_ml_updates(d):
                 if newname != prov:
                     newval = localdata.expand(val)
                     d.setVar(newname, newval)
+            # Avoid future variable key expansion
+            provexp = d.expand(prov)
+            if prov != provexp and d.getVar(prov, False):
+                d.renameVar(prov, provexp)
             continue
         virt = ""
         if pkg.startswith("virtual/"):
@@ -220,19 +228,23 @@ def preferred_ml_updates(d):
             localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override)
             bb.data.update_data(localdata)
             newname = localdata.expand(prov)
-            if newname != prov:
+            if newname != prov and not d.getVar(newname, False):
                 d.setVar(newname, localdata.expand(val))
 
             # implement alternative multilib name
             newname = localdata.expand("PREFERRED_PROVIDER_" + virt + p + "-" + pkg)
             if not d.getVar(newname, False):
                 d.setVar(newname, val)
+        # Avoid future variable key expansion
+        provexp = d.expand(prov)
+        if prov != provexp and d.getVar(prov, False):
+            d.renameVar(prov, provexp)
 
 
     mp = (d.getVar("MULTI_PROVIDER_WHITELIST", True) or "").split()
     extramp = []
     for p in mp:
-        if p.endswith(("-native", "-crosssdk")) or p.startswith("nativesdk-") or 'cross-canadian' in p:
+        if p.endswith(("-native", "-crosssdk")) or p.startswith(("nativesdk-", "virtual/nativesdk-")) or 'cross-canadian' in p:
             continue
         virt = ""
         if p.startswith("virtual/"):
Signature · 1 line
1.8.1.2.545.g2f19ada