cros_sdk: stop using make_chroot.sh to delete the chroot
We already have all the logic to do this, so finish the migration to
chromite for deleting the chroot.
BUG=b:191307774
TEST=`cros_sdk --delete` works
Change-Id: I1a86d2befa77854268db70560f217ce690c6720f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2966901
Tested-by: Mike Frysinger <vapier@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Alex Klein <saklein@chromium.org>
Reviewed-by: Alex Klein <saklein@chromium.org>
diff --git a/scripts/cros_sdk.py b/scripts/cros_sdk.py
index 9b22a1c..3e120de 100644
--- a/scripts/cros_sdk.py
+++ b/scripts/cros_sdk.py
@@ -200,21 +200,6 @@
cros_build_lib.Die('Creating chroot failed!\n%s', e)
-def DeleteChroot(chroot_path):
- """Deletes an existing chroot"""
- cmd = MAKE_CHROOT + ['--chroot', chroot_path, '--delete']
- try:
- logging.notice('Deleting chroot.')
- cros_build_lib.dbg_run(cmd)
- except cros_build_lib.RunCommandError as e:
- cros_build_lib.Die('Deleting chroot failed!\n%s', e)
-
-
-def CleanupChroot(chroot_path):
- """Unmounts a chroot and cleans up any associated devices."""
- cros_sdk_lib.CleanupChrootMount(chroot_path, delete=False)
-
-
def EnterChroot(chroot_path, cache_dir, chrome_root, chrome_root_mount,
goma_dir, goma_client_json, working_dir, additional_args):
"""Enters an existing SDK chroot"""
@@ -1010,9 +995,6 @@
# If deleting, do it regardless of the use_image flag so that a
# previously-created loopback chroot can also be cleaned up.
- # TODO(bmgordon): See if the DeleteChroot call below can be removed in
- # favor of this block.
- chroot_deleted = False
if options.delete:
# Set a timeout of 300 seconds when getting the lock.
with locking.FileLock(lock_path, 'chroot lock',
@@ -1026,13 +1008,8 @@
else:
logging.warning(
'cros_sdk was invoked with force option, continuing.')
- if missing_image_tools:
- logging.notice('Unmounting chroot.')
- osutils.UmountTree(options.chroot)
- else:
- logging.notice('Deleting chroot.')
- cros_sdk_lib.CleanupChrootMount(options.chroot, delete=True)
- chroot_deleted = True
+ logging.notice('Deleting chroot.')
+ cros_sdk_lib.CleanupChrootMount(options.chroot, delete=True)
# If cleanup was requested, we have to do it while we're still in the original
# namespace. Since cleaning up the mount will interfere with any other
@@ -1053,7 +1030,7 @@
# even if we don't get the lock because it will attempt to unmount the
# tree and will print diagnostic information from 'fuser', 'lsof', and
# 'ps'.
- CleanupChroot(options.chroot)
+ cros_sdk_lib.CleanupChrootMount(options.chroot, delete=False)
sys.exit(0)
# Make sure the main chroot mount is visible. Contents will be filled in
@@ -1174,12 +1151,6 @@
if options.proxy_sim:
_ProxySimSetup(options)
- if (options.delete and not chroot_deleted and
- (os.path.exists(options.chroot) or
- os.path.exists(_ImageFileForChroot(options.chroot)))):
- lock.write_lock()
- DeleteChroot(options.chroot)
-
sdk_cache = os.path.join(options.cache_dir, 'sdks')
distfiles_cache = os.path.join(options.cache_dir, 'distfiles')
osutils.SafeMakedirsNonRoot(options.cache_dir)