summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/lsb.py36
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 @@
1def release_dict(): 1def 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
21def release_dict_file(): 30def 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)