Bug 820285 - Use distutils.version.StrictVersion in OSX version tests; r=gps
authorJorge Luis Mendez <jlmendezbonini@gmail.com>
Wed, 12 Dec 2012 19:56:48 -0500
changeset 115877 6445a79d979566e4920272abf517005b25c7c01c
parent 115876 1630310cc83dc721de2fb1b5b5b14484f5b91c5a
child 115878 531eb76b7ab6c842e61faa7425c8d9c29732b280
push id24028
push useremorley@mozilla.com
push dateThu, 13 Dec 2012 15:56:02 +0000
treeherderautoland@9db79b97abbb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs820285
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 820285 - Use distutils.version.StrictVersion in OSX version tests; r=gps DONTBUILD (NPOTB)
python/mozboot/mozboot/bootstrap.py
python/mozboot/mozboot/osx.py
--- a/python/mozboot/mozboot/bootstrap.py
+++ b/python/mozboot/mozboot/bootstrap.py
@@ -53,22 +53,20 @@ class Bootstrapper(object):
                 raise NotImplementedError('Bootstrap support for this Linux '
                                           'distro not yet available.')
 
             args['version'] = version
             args['dist_id'] = dist_id
 
         elif sys.platform.startswith('darwin'):
             # TODO Support Darwin platforms that aren't OS X.
-            major, minor, point = map(int, platform.mac_ver()[0].split('.'))
+            osx_version = platform.mac_ver()[0]
 
             cls = OSXBootstrapper
-            args['major'] = major
-            args['minor'] = minor
-            args['point'] = point
+            args['version'] = osx_version
 
         elif sys.platform.startswith('openbsd'):
             cls = OpenBSDBootstrapper
             args['version'] = platform.uname()[2]
 
         if cls is None:
             raise NotImplementedError('Bootstrap support is not yet available '
                                       'for your OS.')
--- a/python/mozboot/mozboot/osx.py
+++ b/python/mozboot/mozboot/osx.py
@@ -72,60 +72,60 @@ output as packages are built.
 HOMEBREW_OLD_CLANG = '''
 We require a newer compiler than what is provided by your version of Xcode.
 
 We will install a modern version of Clang through Homebrew.
 '''
 
 
 class OSXBootstrapper(BaseBootstrapper):
-    def __init__(self, major, minor, point):
+    def __init__(self, version):
         BaseBootstrapper.__init__(self)
 
-        if major == 10 and minor < 6:
+        self.os_version = StrictVersion(version)
+
+        if self.os_version < StrictVersion('10.6'):
             raise Exception('OS X 10.6 or above is required.')
 
-        self.os_version = minor
-
     def install_system_packages(self):
         self.ensure_xcode()
         self.ensure_homebrew()
         self.ensure_homebrew_packages()
 
     def ensure_xcode(self):
-        if self.os_version < 7:
+        if self.os_version < StrictVersion('10.7'):
             if not os.path.exists('/Developer/Applications/Xcode.app'):
                 print(XCODE_REQUIRED_LEGACY)
 
                 subprocess.check_call(['open', XCODE_LEGACY])
                 sys.exit(1)
 
-        elif self.os_version >= 7:
+        elif self.os_version >= StrictVersion('10.7'):
             if not os.path.exists('/Applications/Xcode.app'):
                 print(XCODE_REQUIRED)
 
                 subprocess.check_call(['open', XCODE_APP_STORE])
 
                 print('Once the install has finished, please relaunch this script.')
                 sys.exit(1)
 
         # Once Xcode is installed, you need to agree to the license before you can
         # use it.
         try:
             output = self.check_output(['/usr/bin/xcrun', 'clang'],
                 stderr=subprocess.STDOUT)
         except subprocess.CalledProcessError as e:
-             if 'license' in e.output:
-                 xcodebuild = self.which('xcodebuild')
-                 subprocess.check_call([xcodebuild, '-license'])
+            if 'license' in e.output:
+                xcodebuild = self.which('xcodebuild')
+                subprocess.check_call([xcodebuild, '-license'])
 
         # Even then we're not done! We need to install the Xcode command line tools.
         # As of Mountain Lion, apparently the only way to do this is to go through a
         # menu dialog inside Xcode itself. We're not making this up.
-        if self.os_version >= 7:
+        if self.os_version >= StrictVersion('10.7'):
             if not os.path.exists('/usr/bin/clang'):
                 print(XCODE_COMMAND_LINE_TOOLS_MISSING)
                 print(INSTALL_XCODE_COMMAND_LINE_TOOLS_STEPS)
                 sys.exit(1)
 
             output = self.check_output(['/usr/bin/clang', '--version'])
             match = RE_CLANG_VERSION.search(output)
             if match is None:
@@ -174,14 +174,13 @@ class OSXBootstrapper(BaseBootstrapper):
                 continue
 
             if not printed:
                 print(HOMEBREW_PACKAGES)
                 printed = True
 
             subprocess.check_call([brew, '-v', 'install', package])
 
-        if self.os_version < 7 and 'llvm' not in installed:
+        if self.os_version < StrictVersion('10.7') and 'llvm' not in installed:
             print(HOMEBREW_OLD_CLANG)
 
             subprocess.check_call([brew, '-v', 'install', 'llvm',
                 '--with-clang', '--all-targets'])
-