mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
bug 1311580 - Fix mozinfo os_version / linux_distro on Linux. r=jmaher
MozReview-Commit-ID: FD9fzKg6Ei4 --HG-- extra : rebase_source : f2e0dcc74cc997e14a07546f215cd3e9a123855b
This commit is contained in:
parent
b072bd5c1e
commit
d0f81be1fb
@ -92,25 +92,16 @@ elif system.startswith('MINGW'):
|
||||
info['os'] = 'win'
|
||||
os_version = version = unknown
|
||||
elif system == "Linux":
|
||||
if hasattr(platform, "linux_distribution"):
|
||||
(distro, os_version, codename) = platform.linux_distribution()
|
||||
else:
|
||||
(distro, os_version, codename) = platform.dist()
|
||||
if not processor:
|
||||
processor = machine
|
||||
version = "%s %s" % (distro, os_version)
|
||||
|
||||
# Bug in Python 2's `platform` library:
|
||||
# It will return a triple of empty strings if the distribution is not supported.
|
||||
# It works on Python 3. If we don't have an OS version,
|
||||
# the unit tests fail to run.
|
||||
if not distro and not os_version and not codename:
|
||||
distro = 'lfs'
|
||||
version = release
|
||||
os_version = release
|
||||
# Try to get a useful distro name/version out of os-release.
|
||||
try:
|
||||
os_info = dict(map(lambda x: x.strip('"'), l.split('=')) for l in open('/etc/os-release', 'rb').read().splitlines())
|
||||
except IOError:
|
||||
os_info = {}
|
||||
|
||||
info['os'] = 'linux'
|
||||
info['linux_distro'] = distro
|
||||
version = os_version = os_info.get('VERSION_ID', release)
|
||||
info['linux_distro'] = os_info.get('NAME', 'lfs')
|
||||
|
||||
elif system in ['DragonFly', 'FreeBSD', 'NetBSD', 'OpenBSD']:
|
||||
info['os'] = 'bsd'
|
||||
version = os_version = sys.platform
|
||||
|
Loading…
Reference in New Issue
Block a user