1 METADATA_SCM = "${@base_get_scm(d)}"
2 METADATA_REVISION = "${@base_get_scm_revision(d)}"
3 METADATA_BRANCH = "${@base_get_scm_branch(d)}"
7 baserepo = os.path.dirname(os.path.dirname(which(d.getVar("BBPATH", 1), "classes/base.bbclass")))
8 for (scm, scmpath) in {"svn": ".svn",
10 "monotone": "_MTN"}.iteritems():
11 if os.path.exists(os.path.join(baserepo, scmpath)):
12 return "%s %s" % (scm, baserepo)
13 return "<unknown> %s" % baserepo
15 def base_get_scm_revision(d):
16 (scm, path) = d.getVar("METADATA_SCM", 1).split()
18 if scm != "<unknown>":
19 return globals()["base_get_metadata_%s_revision" % scm](path, d)
25 def base_get_scm_branch(d):
26 (scm, path) = d.getVar("METADATA_SCM", 1).split()
28 if scm != "<unknown>":
29 return globals()["base_get_metadata_%s_branch" % scm](path, d)
35 def base_get_metadata_monotone_branch(path, d):
36 monotone_branch = "<unknown>"
38 monotone_branch = file( "%s/_MTN/options" % path ).read().strip()
39 if monotone_branch.startswith( "database" ):
40 monotone_branch_words = monotone_branch.split()
41 monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1]
44 return monotone_branch
46 def base_get_metadata_monotone_revision(path, d):
47 monotone_revision = "<unknown>"
49 monotone_revision = file( "%s/_MTN/revision" % path ).read().strip()
50 if monotone_revision.startswith( "format_version" ):
51 monotone_revision_words = monotone_revision.split()
52 monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1]
55 return monotone_revision
57 def base_get_metadata_svn_revision(path, d):
58 revision = "<unknown>"
60 revision = file( "%s/.svn/entries" % path ).readlines()[3].strip()
65 def base_get_metadata_git_branch(path, d):
67 rev = oe_run(d, ["git", "symbolic-ref", "HEAD"], cwd=path).rstrip()
68 except oe.process.CmdError:
71 rev = rev.replace("refs/heads/", "")
74 def base_get_metadata_git_revision(path, d):
76 rev = oe_run(d, ["git", "rev-parse", "--verify", "--short", "HEAD"],
78 except oe.process.CmdError: