cros_sdk: Strengthen check for chroot existence.
Currently, cros_sdk assumes that the existence of a chroot directory
means that the chroot has been set up. With the upcoming loopback-based
chroots, this will no longer be truean empty directory is exactly what
will exist after a reboot until the next use of the chroot. To fix
this, this CL changes the check to look for the contained
/etc/cros_chroot_version file instead of just a chroot directory.
This is a separate CL instead of combining with the main chroot loopback
CL so that build machines don't get left confused about the empty
chroots while crrev.com/c/553462 works its way through the trybots.
BUG=chromium:730144
TEST=Created/deleted/replaced a bunch of chroots with cros_sdk and a
local cbuildbot.
Change-Id: Ic4a29790e2c204b39416431794ccf773eb7a7cc8
Reviewed-on: https://chromium-review.googlesource.com/578466
Commit-Ready: Benjamin Gordon <bmgordon@chromium.org>
Tested-by: Benjamin Gordon <bmgordon@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
diff --git a/scripts/cros_sdk.py b/scripts/cros_sdk.py
index 84f6137..e0790e2 100644
--- a/scripts/cros_sdk.py
+++ b/scripts/cros_sdk.py
@@ -631,8 +631,9 @@
parser.error("Trying to enter the chroot when --delete "
"was specified makes no sense.")
- # Finally, discern if we need to create the chroot.
- chroot_exists = os.path.exists(options.chroot)
+ # Discern if we need to create the chroot.
+ chroot_exists = os.path.exists(os.path.join(
+ options.chroot, 'etc', 'cros_chroot_version'))
if options.create or options.enter:
# Only create if it's being wiped, or if it doesn't exist.
if not options.delete and chroot_exists: