[oe] [PATCH] Fix the package_arch=machine_arch logic to use FILESPATH*

Chris Larson clarson at kergoth.com
Thu Aug 19 18:23:59 UTC 2010


From: Chris Larson <chris_larson at mentor.com>

- Use FILESPATHPKG and FILESPATHBASE to locate the machine specific dirs
- Use the fetch urldata rather than poking at urls ourselves
- Move the logic into utils.bbclass as def'd python functions
- Simplify

Signed-off-by: Chris Larson <chris_larson at mentor.com>
---
 classes/base.bbclass  |   21 ++++-----------------
 classes/utils.bbclass |   18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/classes/base.bbclass b/classes/base.bbclass
index 02c7875..89f983f 100644
--- a/classes/base.bbclass
+++ b/classes/base.bbclass
@@ -442,23 +442,10 @@ python () {
     # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0
     #
     override = bb.data.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH', d, 1)
-    if override != '0':
-        paths = []
-        for p in [ "${PF}", "${P}", "${PN}", "files", "" ]:
-            path = bb.data.expand(os.path.join("${FILE_DIRNAME}", p, "${MACHINE}"), d)
-            if os.path.isdir(path):
-                paths.append(path)
-        if len(paths) != 0:
-            for s in srcuri.split():
-                if not s.startswith("file://"):
-                    continue
-                local = bb.data.expand(bb.fetch.localpath(s, d), d)
-                for mp in paths:
-                    if local.startswith(mp):
-                        #bb.note("overriding PACKAGE_ARCH from %s to %s" % (pkg_arch, mach_arch))
-                        bb.data.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}", d)
-                        bb.data.setVar('MULTIMACH_ARCH', mach_arch, d)
-                        return
+    if override != '0' and is_machine_specific(d):
+        bb.data.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}", d)
+        bb.data.setVar('MULTIMACH_ARCH', mach_arch, d)
+        return
 
     multiarch = pkg_arch
 
diff --git a/classes/utils.bbclass b/classes/utils.bbclass
index 7740ea3..4840c4f 100644
--- a/classes/utils.bbclass
+++ b/classes/utils.bbclass
@@ -38,6 +38,24 @@ def oe_filter(f, str, d):
 def oe_filter_out(f, str, d):
     return oe.utils.str_filter_out(f, str, d)
 
+def machine_paths(d):
+    """List any existing machine specific filespath directories"""
+    machine = d.getVar("MACHINE", True)
+    filespathpkg = d.getVar("FILESPATHPKG", True).split(":")
+    for basepath in d.getVar("FILESPATHBASE", True).split(":"):
+        for pkgpath in filespathpkg:
+            machinepath = os.path.join(basepath, pkgpath, machine)
+            if os.path.isdir(machinepath):
+                yield machinepath
+
+def is_machine_specific(d):
+    """Determine whether the current recipe is machine specific"""
+    machinepaths = set(machine_paths(d))
+    urldatadict = bb.fetch.init(d.getVar("SRC_URI", True).split(), d, True)
+    for urldata in (urldata for urldata in urldatadict.itervalues()
+                    if urldata.type == "file"):
+        if any(urldata.path.startswith(mp + "/") for mp in machinepaths):
+            return True
 
 def subprocess_setup():
    import signal
-- 
1.7.2.1.66.g0d0ba





More information about the Openembedded-devel mailing list