mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 00:59:48 +00:00
oe.lsb: add get_os_release()
Move get_os_release() from oeqa.utils.metadata to oe.lsb, merging the code with release_dict_osr() from oe.lsb. This removes some code duplication and makes get_os_release() more robust. (From OE-Core rev: 56b883f7765f6bd72e83dec26a5db8c7108c835d) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
a11e87f179
commit
ef8c15852c
@@ -10,19 +10,9 @@ from collections.abc import MutableMapping
|
||||
from xml.dom.minidom import parseString
|
||||
from xml.etree.ElementTree import Element, tostring
|
||||
|
||||
from oe.lsb import get_os_release
|
||||
from oeqa.utils.commands import runCmd, get_bb_vars
|
||||
|
||||
def get_os_release():
|
||||
"""Get info from /etc/os-release as a dict"""
|
||||
data = OrderedDict()
|
||||
os_release_file = '/etc/os-release'
|
||||
if not os.path.exists(os_release_file):
|
||||
return None
|
||||
with open(os_release_file) as fobj:
|
||||
for line in fobj:
|
||||
key, value = line.split('=', 1)
|
||||
data[key.strip().lower()] = value.strip().strip('"')
|
||||
return data
|
||||
|
||||
def metadata_from_bb():
|
||||
""" Returns test's metadata as OrderedDict.
|
||||
@@ -45,9 +35,9 @@ def metadata_from_bb():
|
||||
os_release = get_os_release()
|
||||
if os_release:
|
||||
info_dict['host_distro'] = OrderedDict()
|
||||
for key in ('id', 'version_id', 'pretty_name'):
|
||||
for key in ('ID', 'VERSION_ID', 'PRETTY_NAME'):
|
||||
if key in os_release:
|
||||
info_dict['host_distro'][key] = os_release[key]
|
||||
info_dict['host_distro'][key.lower()] = os_release[key]
|
||||
|
||||
info_dict['layers'] = get_layers(data_dict['BBLAYERS'])
|
||||
info_dict['bitbake'] = git_rev_info(os.path.dirname(bb.__file__))
|
||||
|
||||
Reference in New Issue
Block a user