cros_sdk: create out/ dir and mount it at /mnt/host/out

The directory hierarchy under out/ will eventually contain all the
stateful paths which are bind-mounted into the chroot. This commit just
creates and mounts it, nothing uses it yet.

Have cherry picked @dcallagh's change and made one additional tiny
change to address @vapier's comment
https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4199239/comment/84b41ee0_e72c94ae/
prior to merging

BUG=b:265885353
TEST=cros_sdk -- touch /mnt/host/out/hello
TEST=cros_sdk --replace -- touch /mnt/host/out/hello2

Change-Id: Iefefb5e315c8f952f19a0dfb23c748fa82b267df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4199239
Tested-by: Phil Kiossoglou <pkiossoglou@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Phil Kiossoglou <pkiossoglou@chromium.org>
diff --git a/scripts/cros_sdk.py b/scripts/cros_sdk.py
index 0ef3a30..2445d52 100644
--- a/scripts/cros_sdk.py
+++ b/scripts/cros_sdk.py
@@ -829,6 +829,13 @@
         help=("SDK chroot dir name [%s]" % constants.DEFAULT_CHROOT_DIR),
     )
     parser.add_argument(
+        "--out-dir",
+        metavar="DIR",
+        default=constants.DEFAULT_OUT_DIR,
+        type=Path,
+        help="Use DIR for build state and output files",
+    )
+    parser.add_argument(
         "--nouse-image",
         dest="use_image",
         action="store_false",
@@ -1462,6 +1469,7 @@
         sdk_cache = os.path.join(chroot.cache_dir, "sdks")
         distfiles_cache = os.path.join(chroot.cache_dir, "distfiles")
         osutils.SafeMakedirsNonRoot(chroot.cache_dir)
+        osutils.SafeMakedirsNonRoot(options.out_dir)
 
         for target in (sdk_cache, distfiles_cache):
             src = os.path.join(constants.SOURCE_ROOT, os.path.basename(target))
@@ -1503,6 +1511,7 @@
                 cros_sdk_lib.CreateChroot(
                     Path(chroot.path),
                     Path(sdk_tarball),
+                    options.out_dir,
                     Path(chroot.cache_dir),
                     usepkg=not options.bootstrap and not options.nousepkg,
                     chroot_upgrade=options.chroot_upgrade,
@@ -1516,7 +1525,7 @@
         if options.enter:
             lock.read_lock()
             if not mounted:
-                cros_sdk_lib.MountChrootPaths(chroot.path)
+                cros_sdk_lib.MountChrootPaths(chroot.path, options.out_dir)
             ret = EnterChroot(
                 chroot,
                 options.chrome_root_mount,