summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2013-03-12 03:39:56 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-03-14 16:37:09 +0000
commit062a5f6c69f9be2057920f9cbf5ab8cc1511589b (patch)
treea9e82956018b2dfb1ae324dc6c817ae8eaf9bff6 /meta/lib/oe
parent4da406cd50cf02a63ed76810a670aba1eb561c79 (diff)
downloadpoky-062a5f6c69f9be2057920f9cbf5ab8cc1511589b.tar.gz
lib/oe/lsb: enable getting distro ID when lsb_release is not installed
If lsb_release is not installed (as it may not be on headless/minimal installations on distros whose LSB package has a long list of dependencies) we need to gather the information directly from files in /etc. Fixes [YOCTO #4012]. (From OE-Core rev: 106a7bcdb5ad9956f1d78f508408bfbcf7ff5120) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r--meta/lib/oe/lsb.py39
1 files changed, 37 insertions, 2 deletions
diff --git a/meta/lib/oe/lsb.py b/meta/lib/oe/lsb.py
index 9133356afb..f4a5ba1c17 100644
--- a/meta/lib/oe/lsb.py
+++ b/meta/lib/oe/lsb.py
@@ -17,6 +17,37 @@ def release_dict():
17 data[key] = value 17 data[key] = value
18 return data 18 return data
19 19
20def release_dict_file():
21 """ Try to gather LSB release information manually when lsb_release tool is unavailable """
22 data = None
23 try:
24 if os.path.exists('/etc/lsb-release'):
25 data = {}
26 with open('/etc/lsb-release') as f:
27 for line in f:
28 key, value = line.split("=", 1)
29 data[key] = value
30 elif os.path.exists('/etc/redhat-release'):
31 data = {}
32 with open('/etc/redhat-release') as f:
33 distro = f.readline().strip()
34 import re
35 match = re.match(r'(.*) release (.*) \((.*)\)', distro)
36 if match:
37 data['DISTRIB_ID'] = match.group(1)
38 data['DISTRIB_RELEASE'] = match.group(2)
39 elif os.path.exists('/etc/SuSE-release'):
40 data = {}
41 data['DISTRIB_ID'] = 'SUSE LINUX'
42 with open('/etc/SuSE-release') as f:
43 for line in f:
44 if line.startswith('VERSION = '):
45 data['DISTRIB_RELEASE'] = line[10:].rstrip()
46 break
47 except IOError:
48 return None
49 return data
50
20def distro_identifier(adjust_hook=None): 51def distro_identifier(adjust_hook=None):
21 """Return a distro identifier string based upon lsb_release -ri, 52 """Return a distro identifier string based upon lsb_release -ri,
22 with optional adjustment via a hook""" 53 with optional adjustment via a hook"""
@@ -25,8 +56,12 @@ def distro_identifier(adjust_hook=None):
25 if lsb_data: 56 if lsb_data:
26 distro_id, release = lsb_data['Distributor ID'], lsb_data['Release'] 57 distro_id, release = lsb_data['Distributor ID'], lsb_data['Release']
27 else: 58 else:
28 distro_id, release = None, None 59 lsb_data_file = release_dict_file()
29 60 if lsb_data_file:
61 distro_id, release = lsb_data_file['DISTRIB_ID'], lsb_data_file['DISTRIB_RELEASE']
62 else:
63 distro_id, release = None, None
64
30 if adjust_hook: 65 if adjust_hook:
31 distro_id, release = adjust_hook(distro_id, release) 66 distro_id, release = adjust_hook(distro_id, release)
32 if not distro_id: 67 if not distro_id: