Specify location of 'repo' tool during 'repo init'

This is to prevent 'repo' from failing when kernel.org is down.

BUG=chromium-os:15128
TEST=Ran trybot on empty buildroot and with an existing buildroot that
requires re-initialization.

Integration of changes http://gerrit.chromium.org/gerrit/#change,7111
and http://gerrit.chromium.org/gerrit/#change,7120 from TOT.

Change-Id: Ibafc67bdb0f8244666b1c74516395b57bf79fd52
Reviewed-on: http://gerrit.chromium.org/gerrit/7215
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Ryan Cui <rcui@chromium.org>
diff --git a/buildbot/constants.py b/buildbot/constants.py
index 252098b..9ee486c 100644
--- a/buildbot/constants.py
+++ b/buildbot/constants.py
@@ -9,6 +9,8 @@
 SOURCE_ROOT = os.path.join(os.path.dirname(__file__), '..', '..')
 CROSUTILS_LIB_DIR = os.path.join(SOURCE_ROOT, 'src/scripts/lib')
 
+REPO_URL = 'http://git.chromium.org/external/repo.git'
+
 GERRIT_PORT = '29418'
 GERRIT_INT_PORT = '29419'
 
diff --git a/buildbot/repository.py b/buildbot/repository.py
index bec320c..1be82b8 100755
--- a/buildbot/repository.py
+++ b/buildbot/repository.py
@@ -84,6 +84,8 @@
     clobber: Clobbers the directory as part of initialization.
   """
   DEFAULT_MANIFEST = 'default'
+  # Use our own repo, in case android.kernel.org (the default location) is down.
+  _INIT_CMD = ['repo', 'init', '--repo-url', constants.REPO_URL]
 
   def __init__(self, repo_url, directory, branch=None, clobber=False):
     self.repo_url = repo_url
@@ -98,12 +100,11 @@
     assert not os.path.exists(os.path.join(self.directory, '.repo')), \
         'Repo already initialized.'
     # Base command.
-    init_cmd = ['repo', 'init', '--manifest-url', self.repo_url]
+    init_cmd = self._INIT_CMD + ['--manifest-url', self.repo_url]
 
     # Handle branch / manifest options.
     if self.branch: init_cmd.extend(['--manifest-branch', self.branch])
-    cros_lib.RunCommand(init_cmd, cwd=self.directory, input='\n\ny\n',
-                        redirect_stdout=True, redirect_stderr=True)
+    cros_lib.RunCommand(init_cmd, cwd=self.directory, input='\n\ny\n')
 
   def _ReinitializeIfNecessary(self, local_manifest):
     """Reinitializes the repository if the manifest has changed."""
@@ -121,7 +122,7 @@
     logging.debug('Moving to manifest defined by %s' % local_manifest)
     # If no manifest passed in, assume default.
     if local_manifest == self.DEFAULT_MANIFEST:
-      cros_lib.RunCommand(['repo', 'init', '--manifest-name=default.xml'],
+      cros_lib.RunCommand(self._INIT_CMD + ['--manifest-name=default.xml'],
                           cwd=self.directory, input='\n\ny\n')
     else:
       # The 10x speed up magic.