diff options
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oe/lsb.py | 33 | ||||
-rw-r--r-- | meta/lib/oeqa/utils/metadata.py | 16 |
2 files changed, 23 insertions, 26 deletions
diff --git a/meta/lib/oe/lsb.py b/meta/lib/oe/lsb.py index 3a945e0fce..71c0992c5d 100644 --- a/meta/lib/oe/lsb.py +++ b/meta/lib/oe/lsb.py | |||
@@ -1,19 +1,26 @@ | |||
1 | def get_os_release(): | ||
2 | """Get all key-value pairs from /etc/os-release as a dict""" | ||
3 | from collections import OrderedDict | ||
4 | |||
5 | data = OrderedDict() | ||
6 | if os.path.exists('/etc/os-release'): | ||
7 | with open('/etc/os-release') as f: | ||
8 | for line in f: | ||
9 | try: | ||
10 | key, val = line.rstrip().split('=', 1) | ||
11 | except ValueError: | ||
12 | continue | ||
13 | data[key.strip()] = val.strip('"') | ||
14 | return data | ||
15 | |||
1 | def release_dict_osr(): | 16 | def release_dict_osr(): |
2 | """ Populate a dict with pertinent values from /etc/os-release """ | 17 | """ Populate a dict with pertinent values from /etc/os-release """ |
3 | if not os.path.exists('/etc/os-release'): | ||
4 | return None | ||
5 | |||
6 | data = {} | 18 | data = {} |
7 | with open('/etc/os-release') as f: | 19 | os_release = get_os_release() |
8 | for line in f: | 20 | if 'ID' in os_release: |
9 | try: | 21 | data['DISTRIB_ID'] = os_release['ID'] |
10 | key, val = line.rstrip().split('=', 1) | 22 | if 'VERSION_ID' in os_release: |
11 | except ValueError: | 23 | data['DISTRIB_RELEASE'] = os_release['VERSION_ID'] |
12 | continue | ||
13 | if key == 'ID': | ||
14 | data['DISTRIB_ID'] = val.strip('"') | ||
15 | if key == 'VERSION_ID': | ||
16 | data['DISTRIB_RELEASE'] = val.strip('"') | ||
17 | 24 | ||
18 | return data | 25 | return data |
19 | 26 | ||
diff --git a/meta/lib/oeqa/utils/metadata.py b/meta/lib/oeqa/utils/metadata.py index cb81155e54..65bbdc61f4 100644 --- a/meta/lib/oeqa/utils/metadata.py +++ b/meta/lib/oeqa/utils/metadata.py | |||
@@ -10,19 +10,9 @@ from collections.abc import MutableMapping | |||
10 | from xml.dom.minidom import parseString | 10 | from xml.dom.minidom import parseString |
11 | from xml.etree.ElementTree import Element, tostring | 11 | from xml.etree.ElementTree import Element, tostring |
12 | 12 | ||
13 | from oe.lsb import get_os_release | ||
13 | from oeqa.utils.commands import runCmd, get_bb_vars | 14 | from oeqa.utils.commands import runCmd, get_bb_vars |
14 | 15 | ||
15 | def get_os_release(): | ||
16 | """Get info from /etc/os-release as a dict""" | ||
17 | data = OrderedDict() | ||
18 | os_release_file = '/etc/os-release' | ||
19 | if not os.path.exists(os_release_file): | ||
20 | return None | ||
21 | with open(os_release_file) as fobj: | ||
22 | for line in fobj: | ||
23 | key, value = line.split('=', 1) | ||
24 | data[key.strip().lower()] = value.strip().strip('"') | ||
25 | return data | ||
26 | 16 | ||
27 | def metadata_from_bb(): | 17 | def metadata_from_bb(): |
28 | """ Returns test's metadata as OrderedDict. | 18 | """ Returns test's metadata as OrderedDict. |
@@ -45,9 +35,9 @@ def metadata_from_bb(): | |||
45 | os_release = get_os_release() | 35 | os_release = get_os_release() |
46 | if os_release: | 36 | if os_release: |
47 | info_dict['host_distro'] = OrderedDict() | 37 | info_dict['host_distro'] = OrderedDict() |
48 | for key in ('id', 'version_id', 'pretty_name'): | 38 | for key in ('ID', 'VERSION_ID', 'PRETTY_NAME'): |
49 | if key in os_release: | 39 | if key in os_release: |
50 | info_dict['host_distro'][key] = os_release[key] | 40 | info_dict['host_distro'][key.lower()] = os_release[key] |
51 | 41 | ||
52 | info_dict['layers'] = get_layers(data_dict['BBLAYERS']) | 42 | info_dict['layers'] = get_layers(data_dict['BBLAYERS']) |
53 | info_dict['bitbake'] = git_rev_info(os.path.dirname(bb.__file__)) | 43 | info_dict['bitbake'] = git_rev_info(os.path.dirname(bb.__file__)) |