Pass LOCAL_SOURCE to build_packages when cbuildbot manages the Chrome Sync.

This is the first step towards supporting applying Chrome patches in cbuildbot.

Right now, cbuildbot syncs Chrome once, and the chromeos-chrome ebuild syncs
it again. This works fine, but prevents us from being able to patch Chrome,
since the ebuild blows away any local patches that were applied.

BUG=chromium-os:38903
TEST=Remote trybot runs, all unit tests.

Change-Id: I46ecd5a5ff92b8764345deaa804115fc33725616
Reviewed-on: https://gerrit.chromium.org/gerrit/43260
Commit-Queue: David James <davidjames@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 65531f4..59358ba 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -223,16 +223,12 @@
     args = stages.BootstrapStage.FilterArgsForTargetCbuildbot(
         self.options.buildroot, constants.PATH_TO_CBUILDBOT, self.options)
 
-    # Re-write paths to use absolute paths.
+    # Specify a buildroot explicitly (just in case, for local trybot).
     # Suppress any timeout options given from the commandline in the
     # invoked cbuildbot; our timeout will enforce it instead.
     args += ['--resume', '--timeout', '0', '--notee', '--nocgroups',
              '--buildroot', os.path.abspath(self.options.buildroot)]
 
-    if self.options.chrome_root:
-      args += ['--chrome_root',
-               os.path.abspath(self.options.chrome_root)]
-
     if stages.ManifestVersionedSyncStage.manifest_manager:
       ver = stages.ManifestVersionedSyncStage.manifest_manager.current_version
       args += ['--version', ver]
@@ -609,6 +605,16 @@
     options.chrome_version = gclient.GetTipOfTrunkSvnRevision(svn_url)
     options.chrome_rev = constants.CHROME_REV_SPEC
 
+  options.managed_chrome = (chrome_rev != constants.CHROME_REV_LOCAL and
+      (not build_config['usepkg_build_packages'] or chrome_rev))
+
+  if options.managed_chrome:
+    # Tell Chrome to fetch the source locally.
+    internal = constants.USE_CHROME_INTERNAL in (build_config['useflags'] or [])
+    chrome_src = 'chrome-src-internal' if internal else 'chrome-src'
+    options.chrome_root = os.path.join(options.cache_dir, 'distfiles', 'target',
+                                       chrome_src)
+
   target = DistributedBuilder if IsDistributedBuilder() else SimpleBuilder
   buildbot = target(options, build_config)
   if not buildbot.Run():