base.bbclass: add a METADATA_BRANCH variable
authorJeremy Laine <jeremy.laine@m4x.org>
Wed, 21 May 2008 13:18:46 +0000 (13:18 +0000)
committerJeremy Laine <jeremy.laine@m4x.org>
Wed, 21 May 2008 13:18:46 +0000 (13:18 +0000)
classes/base.bbclass

index 7ffb472..3c6f5a1 100644 (file)
@@ -706,6 +706,17 @@ def base_get_scmbasepath(d):
        path_to_bbfiles = bb.data.getVar( 'BBFILES', d, 1 ).split()
        return path_to_bbfiles[0][:path_to_bbfiles[0].rindex( "packages" )]
 
+def base_get_metadata_monotone_branch(d):
+       monotone_branch = "<unknown>"
+       try:
+               monotone_branch = file( "%s/_MTN/options" % base_get_scmbasepath(d) ).read().strip()
+               if monotone_branch.startswith( "database" ):
+                       monotone_branch_words = monotone_branch.split()
+                       monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1]
+       except:
+               pass
+       return monotone_branch
+
 def base_get_metadata_monotone_revision(d):
        monotone_revision = "<unknown>"
        try:
@@ -725,6 +736,7 @@ def base_get_metadata_svn_revision(d):
                pass
        return revision
 
+METADATA_BRANCH ?= "${@base_get_metadata_monotone_branch(d)}"
 METADATA_REVISION ?= "${@base_get_metadata_monotone_revision(d)}"
 
 addhandler base_eventhandler
@@ -757,7 +769,7 @@ python base_eventhandler() {
 
        if name.startswith("BuildStarted"):
                bb.data.setVar( 'BB_VERSION', bb.__version__, e.data )
-               statusvars = ['BB_VERSION', 'METADATA_REVISION', 'TARGET_ARCH', 'TARGET_OS', 'MACHINE', 'DISTRO', 'DISTRO_VERSION','TARGET_FPU']
+               statusvars = ['BB_VERSION', 'METADATA_BRANCH', 'METADATA_REVISION', 'TARGET_ARCH', 'TARGET_OS', 'MACHINE', 'DISTRO', 'DISTRO_VERSION','TARGET_FPU']
                statuslines = ["%-17s = \"%s\"" % (i, bb.data.getVar(i, e.data, 1) or '') for i in statusvars]
                statusmsg = "\nOE Build Configuration:\n%s\n" % '\n'.join(statuslines)
                print statusmsg