Openembedded Devel Discussions
 help / color / mirror / Atom feed
From: Chris Larson <clarson@mvista.com>
To: openembedded-devel@openembedded.org
Subject: [PATCH 1/2] bitbake.conf, collections.inc: Add COLLECTIONS mechanism w/ a sane default.
Date: Wed,  1 Apr 2009 17:27:17 -0700	[thread overview]
Message-ID: <12386320381719-git-send-email-clarson@mvista.com> (raw)

Added code which takes a list of directories in COLLECTIONS, in priority
order (highest to lowest), and uses those to populate BBFILES,
BBFILE_COLLECTIONS, BBFILE_PATTERN_*, and BBFILE_PRIORITY_*.

The default COLLECTIONS is based on BBPATH, so you can now specify a sane
BBPATH, not bother setting up the collections variables or BBFILES, and
still likely be able to do a build.

Signed-off-by: Chris Larson <clarson@mvista.com>
---
 conf/bitbake.conf    |    1 +
 conf/collections.inc |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)
 create mode 100644 conf/collections.inc

diff --git a/conf/bitbake.conf b/conf/bitbake.conf
index 7c159af..134525a 100644
--- a/conf/bitbake.conf
+++ b/conf/bitbake.conf
@@ -620,6 +620,7 @@ OVERRIDES = "local:${MACHINE}:${DISTRO}:${TARGET_OS}:${TARGET_ARCH}:build-${BUIL
 # Include the rest of the config files.
 ##################################################################
 
+require conf/collections.inc
 include conf/site.conf
 include conf/auto.conf
 include conf/local.conf
diff --git a/conf/collections.inc b/conf/collections.inc
new file mode 100644
index 0000000..9355b00
--- /dev/null
+++ b/conf/collections.inc
@@ -0,0 +1,55 @@
+# Take a list of directories in COLLECTIONS, in priority order (highest to
+# lowest), and use those to populate BBFILES, BBFILE_COLLECTIONS,
+# BBFILE_PATTERN_*, and BBFILE_PRIORITY_*.
+
+COLLECTIONS = "${@' '.join(d.getVar('BBPATH', 1).split(':'))}"
+
+def collections_setup(d):
+    """ Populate collection and bbfiles metadata from the COLLECTIONS var. """
+    import bb
+    import os
+    from itertools import izip, chain
+    from glob import glob
+
+    def setifunset(k, v):
+        if d.getVar(k, 0) is None:
+            d.setVar(k, v)
+
+    collections = d.getVar("COLLECTIONS", 1)
+    if not collections:
+        return
+    globbed = (glob(path) for path in collections.split())
+    collections = list(chain(*globbed))
+
+    collectionmap = {}
+    namemap = {}
+    for collection in collections:
+        basename = os.path.basename(collection).split(os.path.extsep)[0]
+        if namemap.get(basename):
+            basename = "%s-%s" % (basename, hash(collection))
+        namemap[basename] = collection
+        collectionmap[collection] = basename
+
+    for (collection, priority) in izip(collections, xrange(len(collections), 0, -1)):
+        if not os.path.exists(collection):
+            bb.fatal("Collection %s does not exist" % collection)
+
+        name = collectionmap[collection]
+        if not name:
+            bb.fatal("Unable to determine collection name for %s" % collection)
+
+        setifunset("BBFILE_PATTERN_%s" % name, "^%s/" % collection)
+        setifunset("BBFILE_PRIORITY_%s" % name, str(priority))
+
+    setifunset("BBFILE_COLLECTIONS", " ".join(collectionmap.values()))
+    setifunset("BBFILES", " ".join(collectionmap.keys()))
+
+addhandler collections_eh
+python collections_eh () {
+    from bb.event import getName
+
+    if getName(e) == "ConfigParsed":
+        collections_setup(e.data)
+
+    return NotHandled
+}
-- 
1.5.2.1




             reply	other threads:[~2009-04-02  0:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-02  0:27 Chris Larson [this message]
2009-04-02  0:27 ` [PATCH 2/2] collections.inc: add support for collection archives Chris Larson
2009-04-02 10:07 ` [PATCH 1/2] bitbake.conf, collections.inc: Add COLLECTIONS mechanism w/ a sane default Graeme Gregory
2009-04-02 19:56   ` Denys Dmytriyenko
2009-04-02 20:28     ` Otavio Salvador
2009-04-03  6:45 ` Holger Schurig
2009-04-03 15:19   ` Chris Larson
2009-04-03  8:54 ` Holger Schurig
2009-04-03 15:17   ` Chris Larson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12386320381719-git-send-email-clarson@mvista.com \
    --to=clarson@mvista.com \
    --cc=openembedded-devel@lists.openembedded.org \
    --cc=openembedded-devel@openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox