newcollection: clean up, and work for those not using collections.inc
authorChris Larson <chris_larson@mentor.com>
Fri, 12 Nov 2010 23:12:26 +0000 (16:12 -0700)
committerChris Larson <chris_larson@mentor.com>
Fri, 12 Nov 2010 23:13:11 +0000 (16:13 -0700)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
classes/newcollection.bbclass

index 7d4d478..9570597 100644 (file)
@@ -106,16 +106,25 @@ python do_newcollection() {
     from bb.build import FuncFailed
     from urlparse import urlparse, urlunparse
 
-    files = [__newcollection_get_recipe(d)]
-    files += __newcollection_get_recipedeps(d)
-    files += __newcollection_get_fileuris(d)
+    files = set([__newcollection_get_recipe(d)])
+    files |= set(__newcollection_get_recipedeps(d))
+    files |= set(__newcollection_get_fileuris(d))
+
+    # filter out files that aren't in any overlays
     collectionsinfo = d.getVar("COLLECTIONSINFO",1) or ""
-    collections = list(chain(*(glob(normpath(collection['path'])) for collection in collectionsinfo.itervalues())))
+    if collectionsinfo:
+        collections = list(chain(*(glob(normpath(collection['path']))
+                                for collection in collectionsinfo.itervalues())))
+    else:
+        topdir = d.getVar("TOPDIR", True)
+        collections = d.getVar("BBPATH", True).split(":")
+        if topdir in collections:
+            collections.remove(topdir)
+
     if not collections:
         return
 
-    # filter out files that aren't in collections
-    files = filter(lambda f: len(filter(lambda c: f.startswith(c), collections)) != 0, files)
+    files = filter(lambda f: any(f.startswith(c) for c in collections), files)
     if not files:
         return
 
@@ -132,21 +141,16 @@ python do_newcollection() {
         else:
                 existing += glob(normpath(path))
 
-    recipe = filter(lambda f: f.endswith(".bb"), files)
-    if not recipe:
-        debug(1, "Recipe already populated, skipping.")
-        return
-
-    for file in files:
+    for file in set(files):
         for col in collections:
             if file.startswith(col + sep):
                 basefile = file[len(col)+1:]
+
         if not basefile:
             continue
 
-        for e in existing:
-            if exists(join(e, basefile)):
-                break
+        if any(exists(join(e, basefile)) for e in existing):
+            debug(1, "%s already in existing collections, skipping." % basefile)
         else:
             __newcollection_populate_file(file, join(destcol, basefile), d)
 }