diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-06-09 11:23:30 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-06-11 10:30:56 +0100 |
commit | ba85bb605502a86fa83bd7a0f3d8ed644dc16a8c (patch) | |
tree | e30bf6f81aa714fad3b9f94c0814339410b0973f /meta/classes/metadata_scm.bbclass | |
parent | 5ed5a3cc8a4d819a0af8ee59f0c960bc4de07b61 (diff) | |
download | poky-ba85bb605502a86fa83bd7a0f3d8ed644dc16a8c.tar.gz |
classes/buildcfg: Move git/layer revision code into new OE module buildcfg
There is a load of duplicated git/layer/revision code which makes
most sesne as a python library, not bbclass code. Start to refactor as such.
(From OE-Core rev: 439cdf8a1e52fd2c4dc81dc40ce7e6af282ce7ac)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/metadata_scm.bbclass')
-rw-r--r-- | meta/classes/metadata_scm.bbclass | 43 |
1 files changed, 2 insertions, 41 deletions
diff --git a/meta/classes/metadata_scm.bbclass b/meta/classes/metadata_scm.bbclass index 47cb969b8d..f646b3159a 100644 --- a/meta/classes/metadata_scm.bbclass +++ b/meta/classes/metadata_scm.bbclass | |||
@@ -1,44 +1,5 @@ | |||
1 | def base_detect_revision(d): | ||
2 | path = base_get_scmbasepath(d) | ||
3 | return base_get_metadata_git_revision(path, d) | ||
4 | 1 | ||
5 | def base_detect_branch(d): | 2 | METADATA_BRANCH := "${@oe.buildcfg.detect_branch(d)}" |
6 | path = base_get_scmbasepath(d) | ||
7 | return base_get_metadata_git_branch(path, d) | ||
8 | |||
9 | def base_get_scmbasepath(d): | ||
10 | return os.path.join(d.getVar('COREBASE'), 'meta') | ||
11 | |||
12 | def base_get_metadata_svn_revision(path, d): | ||
13 | # This only works with older subversion. For newer versions | ||
14 | # this function will need to be fixed by someone interested | ||
15 | revision = "<unknown>" | ||
16 | try: | ||
17 | with open("%s/.svn/entries" % path) as f: | ||
18 | revision = f.readlines()[3].strip() | ||
19 | except (IOError, IndexError): | ||
20 | pass | ||
21 | return revision | ||
22 | |||
23 | def base_get_metadata_git_branch(path, d): | ||
24 | import bb.process | ||
25 | |||
26 | try: | ||
27 | rev, _ = bb.process.run('git rev-parse --abbrev-ref HEAD', cwd=path) | ||
28 | except bb.process.ExecutionError: | ||
29 | rev = '<unknown>' | ||
30 | return rev.strip() | ||
31 | |||
32 | def base_get_metadata_git_revision(path, d): | ||
33 | import bb.process | ||
34 | |||
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 | |||
41 | METADATA_BRANCH := "${@base_detect_branch(d)}" | ||
42 | METADATA_BRANCH[vardepvalue] = "${METADATA_BRANCH}" | 3 | METADATA_BRANCH[vardepvalue] = "${METADATA_BRANCH}" |
43 | METADATA_REVISION := "${@base_detect_revision(d)}" | 4 | METADATA_REVISION := "${@oe.buildcfg.detect_revision(d)}" |
44 | METADATA_REVISION[vardepvalue] = "${METADATA_REVISION}" | 5 | METADATA_REVISION[vardepvalue] = "${METADATA_REVISION}" |