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):
66 branch = os.popen('cd %s; PATH=%s git symbolic-ref HEAD 2>/dev/null' % (path, d.getVar("PATH", 1))).read().rstrip()
69 return branch.replace("refs/heads/", "")
72 def base_get_metadata_git_revision(path, d):
73 rev = os.popen("cd %s; PATH=%s git show-ref HEAD 2>/dev/null" % (path, d.getVar("PATH", 1))).read().split(" ")[0].rstrip()