Merge m-c to inbound.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 18 Sep 2012 21:34:55 -0400
changeset 107557 b0afece80e93af663d1e34c7f216b7424abba9c8
parent 107556 1b9a3e26763a25c292aea34ea3ea72ebdc133e2f (current diff)
parent 107460 3858e27b3f28527e43f0c274809f9b5ec63826c8 (diff)
child 107558 80542168d0d9a34ad49300a94a4c17b4dc8a0a3c
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
milestone18.0a1
Merge m-c to inbound.
--- a/python/mozboot/bin/bootstrap.py
+++ b/python/mozboot/bin/bootstrap.py
@@ -5,17 +5,19 @@
 
 # This script provides one-line bootstrap support to configure systems to build
 # the tree.
 #
 # The role of this script is to load the Python modules containing actual
 # bootstrap support. It does this through various means, including fetching
 # content from the upstream source repository.
 
-from __future__ import print_function, unicode_literals
+# If we add unicode_literals, optparse breaks on Python 2.6.1 (which is needed
+# to support OS X 10.6).
+from __future__ import print_function
 
 import os
 import shutil
 import sys
 import tempfile
 import urllib2
 
 from optparse import OptionParser
--- a/python/mozboot/mozboot/base.py
+++ b/python/mozboot/mozboot/base.py
@@ -47,8 +47,28 @@ class BaseBootstrapper(object):
 
         self.run_as_root(command)
 
     def apt_install(self, *packages):
         command = ['apt-get', 'install']
         command.extend(packages)
 
         self.run_as_root(command)
+
+    def check_output(self, *args, **kwargs):
+        """Run subprocess.check_output even if Python doesn't provide it."""
+        fn = getattr(subprocess, 'check_output', BaseBootstrapper._check_output)
+
+        return fn(*args, **kwargs)
+
+    @staticmethod
+    def _check_output(*args, **kwargs):
+        """Python 2.6 compatible implementation of subprocess.check_output."""
+        proc = subprocess.Popen(stdout=subprocess.PIPE, *args, **kwargs)
+        output, unused_err = proc.communicate()
+        retcode = proc.poll()
+        if retcode:
+            cmd = kwargs.get('args', args[0])
+            e = subprocess.CalledProcessError(retcode, cmd)
+            e.output = output
+            raise e
+
+        return output
--- a/python/mozboot/mozboot/bootstrap.py
+++ b/python/mozboot/mozboot/bootstrap.py
@@ -1,13 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from __future__ import print_function, unicode_literals
+# If we add unicode_literals, Python 2.6.1 (required for OS X 10.6) breaks.
+from __future__ import print_function
 
 import platform
 import sys
 
 from mozboot.centos import CentOSBootstrapper
 from mozboot.fedora import FedoraBootstrapper
 from mozboot.mint import MintBootstrapper
 from mozboot.osx import OSXBootstrapper
--- a/python/mozboot/mozboot/osx.py
+++ b/python/mozboot/mozboot/osx.py
@@ -25,17 +25,17 @@ RE_CLANG_VERSION = re.compile('Apple cla
 APPLE_CLANG_MINIMUM_VERSION = StrictVersion('4.0')
 
 XCODE_REQUIRED = '''
 Xcode is required to build Firefox. Please complete the install of Xcode
 through the App Store.
 '''
 
 XCODE_REQUIRED_LEGACY = '''
-You will need to download nad install Xcode to build Firefox.
+You will need to download and install Xcode to build Firefox.
 
 Please complete the Xcode download and then relaunch this script.
 '''
 
 XCODE_COMMAND_LINE_TOOLS_MISSING = '''
 The Xcode command line tools are required to build Firefox.
 '''
 
@@ -114,33 +114,33 @@ class OSXBootstrapper(BaseBootstrapper):
                 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 = subprocess.check_output(['/usr/bin/xcrun', 'clang'],
+            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'])
 
         # 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 not os.path.exists('/usr/bin/clang'):
                 print(XCODE_COMMAND_LINE_TOOLS_MISSING)
                 print(INSTALL_XCODE_COMMAND_LINE_TOOLS_STEPS)
                 sys.exit(1)
 
-            output = subprocess.check_output(['/usr/bin/clang', '--version'])
+            output = self.check_output(['/usr/bin/clang', '--version'])
             match = RE_CLANG_VERSION.search(output)
             if match is None:
                 raise Exception('Could not determine Clang version.')
 
             version = StrictVersion(match.group(1))
 
             if version < APPLE_CLANG_MINIMUM_VERSION:
                 print(UPGRADE_XCODE_COMMAND_LINE_TOOLS)
@@ -165,17 +165,17 @@ class OSXBootstrapper(BaseBootstrapper):
 
         print(HOMEBREW_XQUARTZ)
         sys.exit(1)
 
     def ensure_homebrew_packages(self):
         brew = self.which('brew')
         assert brew is not None
 
-        installed = subprocess.check_output([brew, 'list']).split()
+        installed = self.check_output([brew, 'list']).split()
 
         if 'python' not in installed:
             self.ensure_xquartz()
 
         packages = [
             # We need to install Python because Mercurial requires the Python
             # development headers which are missing from OS X (at least on
             # 10.8).
@@ -196,11 +196,11 @@ class OSXBootstrapper(BaseBootstrapper):
                 print(HOMEBREW_PACKAGES)
                 printed = True
 
             subprocess.check_call([brew, '-v', 'install', package])
 
         if self.os_version < 7 and 'llvm' not in installed:
             print(HOMEBREW_OLD_CLANG)
 
-            subprocess.check_call([brew, '-v' 'install', 'llvm',
+            subprocess.check_call([brew, '-v', 'install', 'llvm',
                 '--with-clang', '--all-targets'])