bootstrap: Filter commandline arguments.
When invoking cbuildbot on older branches, we would pass along
cbuildbot options that didn't exist on the branch. Use cbuildbot's
existing mechanism for filtering command line options that aren't
supported by the old branch.
BUG=chromium:684887
TEST=run_tests followed by multiple local builds.
Change-Id: Ieb03ca9876618ce9e904a4098d7ee083088fc38b
Reviewed-on: https://chromium-review.googlesource.com/444829
Commit-Ready: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py
index b828570..34a3aba 100644
--- a/scripts/bootstrap.py
+++ b/scripts/bootstrap.py
@@ -18,12 +18,14 @@
import os
from chromite.cbuildbot import repository
+from chromite.cbuildbot.stages import sync_stages
from chromite.lib import config_lib
from chromite.lib import cros_build_lib
from chromite.lib import cros_logging as logging
from chromite.lib import osutils
from chromite.scripts import cbuildbot
+
def PreParseArguments(argv):
"""Extract the branch name from cbuildbot command line arguments.
@@ -35,16 +37,17 @@
Returns:
Branch as a string ('master' if nothing is specified).
"""
- # Must match cbuildbot._CreateParser().
parser = cbuildbot.CreateParser()
-
- # Extract the branch argument, if present, ignore the rest.
- options, _ = parser.parse_args(argv)
+ options, args = cbuildbot.ParseCommandLine(parser, argv)
# This option isn't required for cbuildbot, but is for us.
if not options.buildroot:
cros_build_lib.Die('--buildroot is a required option.')
+ # Save off the build targets, in a mirror of cbuildbot code.
+ options.build_targets = args
+ options.Freeze()
+
return options
@@ -118,21 +121,24 @@
repo.Sync()
-def RunCbuildbot(buildroot, argv):
+def RunCbuildbot(options):
"""Start cbuildbot in specified directory with all arguments.
Args:
- buildroot: Root of ChromeOS checkout to run cbuildbot in.
- argv: All command line arguments to pass as list of strings.
+ options: Parse command line options.
Returns:
Return code of cbuildbot as an integer.
"""
- logging.info('Bootstrap cbuildbot in: %s', buildroot)
- cbuildbot_cmd = os.path.join(buildroot, 'chromite', 'bin', 'cbuildbot')
- result = cros_build_lib.RunCommand([cbuildbot_cmd] + argv,
- error_code_ok=True,
- cwd=buildroot)
+ logging.info('Bootstrap cbuildbot in: %s', options.buildroot)
+ cbuildbot_path = os.path.join(
+ options.buildroot, 'chromite', 'bin', 'cbuildbot')
+
+ cmd = sync_stages.BootstrapStage.FilterArgsForTargetCbuildbot(
+ options.buildroot, cbuildbot_path, options)
+
+ result = cros_build_lib.RunCommand(
+ cmd, error_code_ok=True, cwd=options.buildroot)
logging.debug('cbuildbot result is: %s', result.returncode)
return result.returncode
@@ -165,4 +171,4 @@
InitialCheckout(branchname, buildroot, git_cache_dir)
# Run cbuildbot inside the full ChromeOS checkout, on the specified branch.
- RunCbuildbot(buildroot, argv)
+ return RunCbuildbot(options)