Bug 945869 - Provide more granular OS version information in mozinfo. r=ted.mielczarek

This commit is contained in:
Marco Castelluccio 2014-05-01 06:09:00 +02:00
parent 41b2074a93
commit 44958302c8
2 changed files with 30 additions and 15 deletions

View File

@ -16,6 +16,8 @@ from mach.mixin.logging import LoggingMixin
import mozpack.path as mozpath
import manifestparser
import mozinfo
from .data import (
ConfigFileSubstitution,
Defines,
@ -69,12 +71,16 @@ class TreeMetadataEmitter(LoggingMixin):
self.config = config
# TODO add mozinfo into config or somewhere else.
mozinfo_path = mozpath.join(config.topobjdir, 'mozinfo.json')
if os.path.exists(mozinfo_path):
self.mozinfo = json.load(open(mozinfo_path, 'rt'))
else:
self.mozinfo = {}
mozinfo.find_and_update_from_json(config.topobjdir)
# Python 2.6 doesn't allow unicode keys to be used for keyword
# arguments. This gross hack works around the problem until we
# rid ourselves of 2.6.
self.info = {}
for k, v in mozinfo.info.items():
if isinstance(k, unicode):
k = k.encode('ascii')
self.info[k] = v
self._libs = {}
self._final_libs = []
@ -476,7 +482,7 @@ class TreeMetadataEmitter(LoggingMixin):
# We return tests that don't exist because we want manifests
# defining tests that don't exist to result in error.
filtered = m.active_tests(exists=False, disabled=False,
**self.mozinfo)
**self.info)
missing = [t['name'] for t in filtered if not os.path.exists(t['path'])]
if missing:

View File

@ -31,6 +31,7 @@ unknown = unknown() # singleton
info = {'os': unknown,
'processor': unknown,
'version': unknown,
'os_version': unknown,
'bits': unknown }
(system, node, release, version, machine, processor) = platform.uname()
(bits, linkage) = platform.architecture()
@ -45,28 +46,34 @@ if system in ["Microsoft", "Windows"]:
else:
processor = os.environ.get('PROCESSOR_ARCHITECTURE', processor)
system = os.environ.get("OS", system).replace('_', ' ')
service_pack = os.sys.getwindowsversion()[4]
(major, minor, _, _, service_pack) = os.sys.getwindowsversion()
info['service_pack'] = service_pack
os_version = "%d.%d" % (major, minor)
elif system == "Linux":
if hasattr(platform, "linux_distribution"):
(distro, version, codename) = platform.linux_distribution()
(distro, os_version, codename) = platform.linux_distribution()
else:
(distro, version, codename) = platform.dist()
version = "%s %s" % (distro, version)
(distro, os_version, codename) = platform.dist()
if not processor:
processor = machine
version = "%s %s" % (distro, os_version)
info['os'] = 'linux'
info['linux_distro'] = distro
elif system in ['DragonFly', 'FreeBSD', 'NetBSD', 'OpenBSD']:
info['os'] = 'bsd'
version = sys.platform
version = os_version = sys.platform
elif system == "Darwin":
(release, versioninfo, machine) = platform.mac_ver()
version = "OS X %s" % release
versionNums = release.split('.')[:2]
os_version = "%s.%s" % (versionNums[0], versionNums[1])
info['os'] = 'mac'
elif sys.platform in ('solaris', 'sunos5'):
info['os'] = 'unix'
version = sys.platform
info['version'] = version # os version
os_version = version = sys.platform
info['version'] = version
info['os_version'] = os_version
# processor type and bits
if processor in ["i386", "i686"]:
@ -140,7 +147,7 @@ def find_and_update_from_json(*dirs):
"""
# First, see if we're in an objdir
try:
from mozbuild.base import MozbuildObject
from mozbuild.base import MozbuildObject, BuildEnvironmentNotFoundException
build = MozbuildObject.from_environment()
json_path = _os.path.join(build.topobjdir, "mozinfo.json")
if _os.path.isfile(json_path):
@ -148,6 +155,8 @@ def find_and_update_from_json(*dirs):
return json_path
except ImportError:
pass
except BuildEnvironmentNotFoundException:
pass
for d in dirs:
d = _os.path.abspath(d)