diff options
Diffstat (limited to 'meta/lib/oe/buildcfg.py')
-rw-r--r-- | meta/lib/oe/buildcfg.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/meta/lib/oe/buildcfg.py b/meta/lib/oe/buildcfg.py new file mode 100644 index 0000000000..a749fc5303 --- /dev/null +++ b/meta/lib/oe/buildcfg.py | |||
@@ -0,0 +1,40 @@ | |||
1 | |||
2 | import subprocess | ||
3 | import bb.process | ||
4 | |||
5 | def detect_revision(d): | ||
6 | path = get_scmbasepath(d) | ||
7 | return get_metadata_git_revision(path, d) | ||
8 | |||
9 | def detect_branch(d): | ||
10 | path = get_scmbasepath(d) | ||
11 | return get_metadata_git_branch(path, d) | ||
12 | |||
13 | def get_scmbasepath(d): | ||
14 | return os.path.join(d.getVar('COREBASE'), 'meta') | ||
15 | |||
16 | def get_metadata_svn_revision(path, d): | ||
17 | # This only works with older subversion. For newer versions | ||
18 | # this function will need to be fixed by someone interested | ||
19 | revision = "<unknown>" | ||
20 | try: | ||
21 | with open("%s/.svn/entries" % path) as f: | ||
22 | revision = f.readlines()[3].strip() | ||
23 | except (IOError, IndexError): | ||
24 | pass | ||
25 | return revision | ||
26 | |||
27 | def get_metadata_git_branch(path, d): | ||
28 | try: | ||
29 | rev, _ = bb.process.run('git rev-parse --abbrev-ref HEAD', cwd=path) | ||
30 | except bb.process.ExecutionError: | ||
31 | rev = '<unknown>' | ||
32 | return rev.strip() | ||
33 | |||
34 | def get_metadata_git_revision(path, d): | ||
35 | try: | ||
36 | rev, _ = bb.process.run('git rev-parse HEAD', cwd=path) | ||
37 | except bb.process.ExecutionError: | ||
38 | rev = '<unknown>' | ||
39 | return rev.strip() | ||
40 | |||