diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2013-11-27 13:53:18 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-12-10 11:16:10 +0000 |
commit | 8ee7b080682e96a42c1cd8dfb299dbd997889a62 (patch) | |
tree | 3b36aee25eb0afb4fe8b856d73b2cc4007d2cdd2 | |
parent | 853f5db48f4cfcb34345938b583874fe5b6fc678 (diff) | |
download | poky-8ee7b080682e96a42c1cd8dfb299dbd997889a62.tar.gz |
toaster.bbclass: read layer information
In the process of removing the local system
accesses from toaster UI (which must be able to
run remotely), the code to read layer information
is moved from Bitbake Toaster UI
to the server-side toaster.bbclass
[YOCTO #5604]
(From OE-Core rev: 158679d244ff5b44354fb474c88122918b93a5b6)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/toaster.bbclass | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/meta/classes/toaster.bbclass b/meta/classes/toaster.bbclass index 8dc1663165..ec9b6c58b7 100644 --- a/meta/classes/toaster.bbclass +++ b/meta/classes/toaster.bbclass | |||
@@ -24,7 +24,73 @@ | |||
24 | # | 24 | # |
25 | # | 25 | # |
26 | 26 | ||
27 | # 1. Dump package file info data | 27 | # Find and dump layer info when we got the layers parsed |
28 | |||
29 | |||
30 | |||
31 | python toaster_layerinfo_dumpdata() { | ||
32 | import subprocess | ||
33 | |||
34 | def _get_git_branch(layer_path): | ||
35 | branch = subprocess.Popen("git symbolic-ref HEAD 2>/dev/null ", cwd=layer_path, shell=True, stdout=subprocess.PIPE).communicate()[0] | ||
36 | branch = branch.replace('refs/heads/', '').rstrip() | ||
37 | return branch | ||
38 | |||
39 | def _get_git_revision(layer_path): | ||
40 | revision = subprocess.Popen("git rev-parse HEAD 2>/dev/null ", cwd=layer_path, shell=True, stdout=subprocess.PIPE).communicate()[0].rstrip() | ||
41 | return revision | ||
42 | |||
43 | def _get_url_map_name(layer_name): | ||
44 | """ Some layers have a different name on openembedded.org site, | ||
45 | this method returns the correct name to use in the URL | ||
46 | """ | ||
47 | |||
48 | url_name = layer_name | ||
49 | url_mapping = {'meta': 'openembedded-core'} | ||
50 | |||
51 | for key in url_mapping.keys(): | ||
52 | if key == layer_name: | ||
53 | url_name = url_mapping[key] | ||
54 | |||
55 | return url_name | ||
56 | |||
57 | def _get_layer_version_information(layer_path): | ||
58 | |||
59 | layer_version_info = {} | ||
60 | layer_version_info['branch'] = _get_git_branch(layer_path) | ||
61 | layer_version_info['commit'] = _get_git_revision(layer_path) | ||
62 | layer_version_info['priority'] = 0 | ||
63 | |||
64 | return layer_version_info | ||
65 | |||
66 | |||
67 | def _get_layer_dict(layer_path): | ||
68 | |||
69 | layer_info = {} | ||
70 | layer_name = layer_path.split('/')[-1] | ||
71 | layer_url = 'http://layers.openembedded.org/layerindex/layer/{layer}/' | ||
72 | layer_url_name = _get_url_map_name(layer_name) | ||
73 | |||
74 | layer_info['name'] = layer_name | ||
75 | layer_info['local_path'] = layer_path | ||
76 | layer_info['layer_index_url'] = layer_url.format(layer=layer_url_name) | ||
77 | layer_info['version'] = _get_layer_version_information(layer_path) | ||
78 | |||
79 | return layer_info | ||
80 | |||
81 | |||
82 | bblayers = e.data.getVar("BBLAYERS", True) | ||
83 | |||
84 | llayerinfo = {} | ||
85 | |||
86 | for layer in { l for l in bblayers.strip().split(" ") if len(l) }: | ||
87 | llayerinfo[layer] = _get_layer_dict(layer) | ||
88 | |||
89 | |||
90 | bb.event.fire(bb.event.MetadataEvent("LayerInfo", llayerinfo), e.data) | ||
91 | } | ||
92 | |||
93 | # Dump package file info data | ||
28 | 94 | ||
29 | python toaster_package_dumpdata() { | 95 | python toaster_package_dumpdata() { |
30 | """ | 96 | """ |