1 # Take a list of directories in COLLECTIONS, in priority order (highest to
2 # lowest), and use those to populate BBFILES, BBFILE_COLLECTIONS,
3 # BBFILE_PATTERN_*, and BBFILE_PRIORITY_*. By default, COLLECTIONS is
4 # prepopulated with the locations the user specified in their BBPATH.
6 COLLECTIONS = "${@' '.join(d.getVar('BBPATH', 1).split(':'))}"
8 def collections_setup(d):
9 """ Populate collection and bbfiles metadata from the COLLECTIONS var. """
12 from itertools import izip, chain
16 if d.getVar(k, 0) is None:
19 collections = d.getVar("COLLECTIONS", 1)
22 globbed = (glob(path) for path in collections.split())
23 collections = list(chain(*globbed))
27 for collection in collections:
28 basename = os.path.basename(collection).split(os.path.extsep)[0]
29 if namemap.get(basename):
30 basename = "%s-%s" % (basename, hash(collection))
31 namemap[basename] = collection
32 collectionmap[collection] = basename
34 for (collection, priority) in izip(collections, xrange(len(collections), 0, -1)):
35 if not os.path.exists(collection):
36 bb.fatal("Collection %s does not exist" % collection)
38 name = collectionmap[collection]
40 bb.fatal("Unable to determine collection name for %s" % collection)
42 setifunset("BBFILE_PATTERN_%s" % name, "^%s/" % collection)
43 setifunset("BBFILE_PRIORITY_%s" % name, str(priority))
45 setifunset("BBFILE_COLLECTIONS", " ".join(collectionmap.values()))
46 setifunset("BBFILES", " ".join(collectionmap.keys()))
48 addhandler collections_eh
49 python collections_eh () {
50 from bb.event import getName
52 if getName(e) == "ConfigParsed":
53 collections_setup(e.data)