Reland "deploy_chrome: Warn before deploying to device with mismatched board"
This is a reland of b35e6e3e8946efea1adcbe6e71033bd54ef34b90
If self.options.staging_only is true, _CheckBoard crashes because there
is no device. Thus the original change caused https://crbug.com/1085526.
Now _CheckBoard shall only be called after self.options.staging_only has
been checked and is false.
Original change's description:
> deploy_chrome: Warn before deploying to device with mismatched board
>
> deploy_chrome shall always require that a target board is specified,
> either from cros chrome_sdk or via --board. If the DUT board does not
> match, deploy_chrome shall log a warning, and unless --force is
> specified, it shall prompt for whether to continue.
>
> BUG=chromium:741966
> TEST=chromite/run_pytest
>
> Change-Id: Ia51491ebc82b99e127e1b523ce213f546abffe15
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2125032
> Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
> Reviewed-by: Mike Frysinger <vapier@chromium.org>
> Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
> Commit-Queue: Avery Musbach <amusbach@chromium.org>
> Tested-by: Avery Musbach <amusbach@chromium.org>
BUG=chromium:741966,chromium:1085526
TEST=chromite/run_pytest
Change-Id: I954f301f074dd89e1aebdfdd046e71bbb43f3d73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2216412
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Tested-by: Avery Musbach <amusbach@chromium.org>
Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/deploy_chrome.py b/scripts/deploy_chrome.py
index d778830..4a286e0 100644
--- a/scripts/deploy_chrome.py
+++ b/scripts/deploy_chrome.py
@@ -103,9 +103,10 @@
self.options = options
self.staging_dir = staging_dir
if not self.options.staging_only:
- self.device = remote.RemoteDevice(options.to, port=options.port,
- ping=options.ping,
- private_key=options.private_key)
+ self.device = remote.ChromiumOSDevice(options.to, port=options.port,
+ ping=options.ping,
+ private_key=options.private_key,
+ include_dev_paths=False)
self._root_dir_is_still_readonly = multiprocessing.Event()
self.copy_paths = chrome_util.GetCopyPaths('chrome')
@@ -312,6 +313,18 @@
logging.error('Error connecting to the test device.')
raise DeployFailure(ex)
+ def _CheckBoard(self):
+ """Check that the Chrome build is targeted for the device board."""
+ if self.options.board == self.device.board:
+ return
+ logging.warning('Device board is %s whereas target board is %s.',
+ self.device.board, self.options.board)
+ if self.options.force:
+ return
+ if not cros_build_lib.BooleanPrompt('Continue despite board mismatch?',
+ False):
+ raise DeployFailure('Aborted.')
+
def _CheckDeployType(self):
if self.options.build_dir:
def BinaryExists(filename):
@@ -369,6 +382,9 @@
self._PrepareStagingDir()
return 0
+ # Check that the build matches the device.
+ self._CheckBoard()
+
# Ensure that the target directory exists before running parallel steps.
self._EnsureTargetDir()
@@ -423,9 +439,9 @@
# TODO(rcui): Have this use the UI-V2 format of having source and target
# device be specified as positional arguments.
parser.add_argument('--force', action='store_true', default=False,
- help='Skip all prompts (i.e., for disabling of rootfs '
- 'verification). This may result in the target '
- 'machine being rebooted.')
+ help='Skip all prompts (such as the prompt for disabling '
+ 'of rootfs verification). This may result in the '
+ 'target machine being rebooted.')
sdk_board_env = os.environ.get(cros_chrome_sdk.SDKFetcher.SDK_BOARD_ENV)
parser.add_argument('--board', default=sdk_board_env,
help='The board the Chrome build is targeted for. When '
@@ -543,9 +559,8 @@
if options.build_dir and any([options.gs_path, options.local_pkg_path]):
parser.error('Cannot specify both --build_dir and '
'--gs-path/--local-pkg-patch')
- if (not options.board and options.build_dir and options.dostrip and
- not options.strip_bin):
- parser.error('--board is required for stripping.')
+ if not options.board:
+ parser.error('--board is required outside of cros chrome_sdk')
if options.gs_path and options.local_pkg_path:
parser.error('Cannot specify both --gs-path and --local-pkg-path')
if not (options.staging_only or options.to):