cros_flash: Remove --install flag for USB flash
It doesn't seem like this flag is being used by anyone. Removing this
allows us to potentially remove dependency to chromeos-installer in the
SDK.
BUG=None
TEST=cros flash
TEST=chromite/run_tests
Change-Id: I67c2028033fb227ba0132c1378aba31fe56bc5a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2594266
Tested-by: Amin Hassani <ahassani@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/cli/cros/cros_flash.py b/cli/cros/cros_flash.py
index 22f8703..0b5169e 100644
--- a/cli/cros/cros_flash.py
+++ b/cli/cros/cros_flash.py
@@ -159,10 +159,6 @@
action='store_false', default=True,
help=('Do not copy the update payloads to the device. For now this '
'only works for the stateful payload.'))
- usb = parser.add_argument_group('USB specific options')
- usb.add_argument(
- '--install', default=False, action='store_true',
- help='Install to the USB device using the base disk layout.')
def _GetDefaultVersion(self):
"""Get default full SDK version.
@@ -192,7 +188,6 @@
self.options.image,
board=self.options.board,
version=self._GetDefaultVersion(),
- install=self.options.install,
src_image_to_delta=self.options.src_image_to_delta,
rootfs_update=self.options.rootfs_update,
stateful_update=self.options.stateful_update,
diff --git a/cli/cros/cros_flash_unittest.py b/cli/cros/cros_flash_unittest.py
index 292b6c2..2f3694c 100644
--- a/cli/cros/cros_flash_unittest.py
+++ b/cli/cros/cros_flash_unittest.py
@@ -79,7 +79,6 @@
expected_kwargs = {
'board': None,
'version': 'latest',
- 'install': False,
'src_image_to_delta': None,
'rootfs_update': True,
'stateful_update': True,
diff --git a/cli/flash.py b/cli/flash.py
index 16c137c..cb1b252 100644
--- a/cli/flash.py
+++ b/cli/flash.py
@@ -11,7 +11,6 @@
import os
import re
import shutil
-import subprocess
import sys
import tempfile
@@ -152,8 +151,7 @@
class USBImager(object):
"""Copy image to the target removable device."""
- def __init__(self, device, board, image, version, debug=False,
- install=False, yes=False):
+ def __init__(self, device, board, image, version, debug=False, yes=False):
"""Initializes USBImager."""
self.device = device
self.board = board if board else GetDefaultBoard()
@@ -161,7 +159,6 @@
self.version = version
self.debug = debug
self.debug_level = logging.DEBUG if debug else logging.INFO
- self.install = install
self.yes = yes
def DeviceNameToPath(self, device_name):
@@ -213,28 +210,6 @@
return devices[idx]
- def InstallImageToDevice(self, image, device):
- """Installs |image| to the removable |device|.
-
- Args:
- image: Path to the image to copy.
- device: Device to copy to.
- """
- cmd = [
- 'chromeos-install',
- '--yes',
- '--skip_src_removable',
- '--skip_dst_removable',
- '--payload_image=%s' % image,
- '--dst=%s' % device,
- '--skip_postinstall',
- ]
- cros_build_lib.sudo_run(cmd,
- print_cmd=True,
- debug_level=logging.NOTICE,
- stderr=subprocess.STDOUT,
- log_output=True)
-
def CopyImageToDevice(self, image, device):
"""Copies |image| to the removable |device|.
@@ -319,10 +294,7 @@
image_path = self._GetImagePath()
try:
device = self.DeviceNameToPath(target)
- if self.install:
- self.InstallImageToDevice(image_path, device)
- else:
- self.CopyImageToDevice(image_path, device)
+ self.CopyImageToDevice(image_path, device)
except cros_build_lib.RunCommandError:
logging.error('Failed copying image to device %s',
self.DeviceNameToPath(target))
@@ -550,7 +522,7 @@
self.Cleanup()
-def Flash(device, image, board=None, install=False, src_image_to_delta=None,
+def Flash(device, image, board=None, src_image_to_delta=None,
rootfs_update=True, stateful_update=True, clobber_stateful=False,
reboot=True, wipe=True, ssh_private_key=None, ping=True,
disable_rootfs_verification=False, clear_cache=False, yes=False,
@@ -567,7 +539,6 @@
image: Path (string) to the update image. Can be a local or xbuddy path;
non-existant local paths are converted to xbuddy.
board: Board to use; None to automatically detect.
- install: Install to USB using base disk layout; USB |device| scheme only.
src_image_to_delta: Local path to an image to be used as the base to
generate delta payloads; SSH |device| scheme only.
rootfs_update: Update rootfs partition; SSH |device| scheme only.
@@ -602,13 +573,6 @@
ds_wrapper.DevServerWrapper.WipeStaticDirectory()
ds_wrapper.DevServerWrapper.CreateStaticDirectory()
- if install:
- if not device or device.scheme != commandline.DEVICE_SCHEME_USB:
- raise ValueError(
- '--install can only be used when writing to a USB device')
- if not cros_build_lib.IsInsideChroot():
- raise ValueError('--install can only be used inside the chroot')
-
# The user may not have specified a source image, use version as the default.
image = image or version
if not device or device.scheme == commandline.DEVICE_SCHEME_SSH:
@@ -647,7 +611,6 @@
image,
version,
debug=debug,
- install=install,
yes=yes)
imager.Run()
elif device.scheme == commandline.DEVICE_SCHEME_FILE:
diff --git a/cli/flash_unittest.py b/cli/flash_unittest.py
index 3ecffb6..d4b400d 100644
--- a/cli/flash_unittest.py
+++ b/cli/flash_unittest.py
@@ -171,9 +171,8 @@
class USBImagerMock(partial_mock.PartialCmdMock):
"""Mock out USBImager."""
TARGET = 'chromite.cli.flash.USBImager'
- ATTRS = ('CopyImageToDevice', 'InstallImageToDevice',
- 'ChooseRemovableDevice', 'ListAllRemovableDevices',
- 'GetRemovableDeviceDescription')
+ ATTRS = ('CopyImageToDevice', 'ChooseRemovableDevice',
+ 'ListAllRemovableDevices', 'GetRemovableDeviceDescription')
VALID_IMAGE = True
def __init__(self):
@@ -182,9 +181,6 @@
def CopyImageToDevice(self, _inst, *_args, **_kwargs):
"""Mock out CopyImageToDevice."""
- def InstallImageToDevice(self, _inst, *_args, **_kwargs):
- """Mock out InstallImageToDevice."""
-
def ChooseRemovableDevice(self, _inst, *_args, **_kwargs):
"""Mock out ChooseRemovableDevice."""
@@ -222,13 +218,6 @@
flash.Flash(self.Device('/dev/foo'), self.IMAGE)
self.assertTrue(self.imager_mock.patched['CopyImageToDevice'].called)
- def testLocalImagePathInstall(self):
- """Tests that imaging methods are called correctly."""
- with mock.patch('os.path.isfile', return_value=True):
- flash.Flash(self.Device('/dev/foo'), self.IMAGE, board='taco',
- install=True)
- self.assertTrue(self.imager_mock.patched['InstallImageToDevice'].called)
-
def testLocalBadImagePath(self):
"""Tests that using an image not having the magic bytes has prompt."""
self.isgpt_mock.return_value = False