diff options
author | Joshua Lock <joshua.g.lock@intel.com> | 2016-11-08 14:49:54 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-11-15 15:19:54 +0000 |
commit | 545f5f96d9b7447583d865de7b35e444a9785426 (patch) | |
tree | 728ecf30c79ff9b577536a4ee49f3a2f960d6995 /meta/lib/oe | |
parent | b4070cf6c9e3a1fb03e9a03b74bb025176f503e5 (diff) | |
download | poky-545f5f96d9b7447583d865de7b35e444a9785426.tar.gz |
lib/oe/lsb: make the release dict keys consistent regardless of source
Rather than have the distro_identifier method look for different keys in
the dict depending on the source ensure that each function for retrieving
release data uses the same key names in the returned dict.
(From OE-Core rev: 2ddd6ddaf0c5ba14ae83347eba877ac9ef179c76)
Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r-- | meta/lib/oe/lsb.py | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/meta/lib/oe/lsb.py b/meta/lib/oe/lsb.py index e0bdfba255..0bb76864a0 100644 --- a/meta/lib/oe/lsb.py +++ b/meta/lib/oe/lsb.py | |||
@@ -1,5 +1,5 @@ | |||
1 | def release_dict(): | 1 | def release_dict_lsb(): |
2 | """Return the output of lsb_release -ir as a dictionary""" | 2 | """ Return the output of lsb_release -ir as a dictionary """ |
3 | from subprocess import PIPE | 3 | from subprocess import PIPE |
4 | 4 | ||
5 | try: | 5 | try: |
@@ -7,19 +7,28 @@ def release_dict(): | |||
7 | except bb.process.CmdError as exc: | 7 | except bb.process.CmdError as exc: |
8 | return None | 8 | return None |
9 | 9 | ||
10 | lsb_map = { 'Distributor ID': 'DISTRIB_ID', | ||
11 | 'Release': 'DISTRIB_RELEASE'} | ||
12 | lsb_keys = lsb_map.keys() | ||
13 | |||
10 | data = {} | 14 | data = {} |
11 | for line in output.splitlines(): | 15 | for line in output.splitlines(): |
12 | if line.startswith("-e"): line = line[3:] | 16 | if line.startswith("-e"): |
17 | line = line[3:] | ||
13 | try: | 18 | try: |
14 | key, value = line.split(":\t", 1) | 19 | key, value = line.split(":\t", 1) |
15 | except ValueError: | 20 | except ValueError: |
16 | continue | 21 | continue |
17 | else: | 22 | if key in lsb_keys: |
18 | data[key] = value | 23 | data[lsb_map[key]] = value |
24 | |||
25 | if len(data.keys()) != 2: | ||
26 | return None | ||
27 | |||
19 | return data | 28 | return data |
20 | 29 | ||
21 | def release_dict_file(): | 30 | def release_dict_file(): |
22 | """ Try to gather LSB release information manually when lsb_release tool is unavailable """ | 31 | """ Try to gather release information manually when other methods fail """ |
23 | data = None | 32 | data = None |
24 | try: | 33 | try: |
25 | if os.path.exists('/etc/lsb-release'): | 34 | if os.path.exists('/etc/lsb-release'): |
@@ -64,15 +73,12 @@ def distro_identifier(adjust_hook=None): | |||
64 | 73 | ||
65 | import re | 74 | import re |
66 | 75 | ||
67 | lsb_data = release_dict() | 76 | distro_data = release_dict_lsb() |
68 | if lsb_data: | 77 | if not distro_data: |
69 | distro_id, release = lsb_data['Distributor ID'], lsb_data['Release'] | 78 | distro_data = release_dict_file() |
70 | else: | 79 | |
71 | lsb_data_file = release_dict_file() | 80 | distro_id = distro_data['DISTRIB_ID'] |
72 | if lsb_data_file: | 81 | release = distro_data['DISTRIB_RELEASE'] |
73 | distro_id, release = lsb_data_file['DISTRIB_ID'], lsb_data_file.get('DISTRIB_RELEASE', None) | ||
74 | else: | ||
75 | distro_id, release = None, None | ||
76 | 82 | ||
77 | if adjust_hook: | 83 | if adjust_hook: |
78 | distro_id, release = adjust_hook(distro_id, release) | 84 | distro_id, release = adjust_hook(distro_id, release) |