enter_chroot: handle /var/lock->/run/lock symlinks
Newer Gentoo builds have moved to /run which means /var/lock is a symlink
to /run/lock. But since that is an absolute symlink, it points outside of
the chroot which doesn't work for us. Use a stable path unrelated to the
chroot instead, but only with newer chroots.
We no longer have to worry about backwards compat because the code that
used to rely on this lock file (running sync processes) was punted a long
time ago.
BUG=chromium:218085
TEST=`cbuildbot chromiumos-sdk` passes
Change-Id: I38c6848dfb86386849050d7ccf3f90cbbe8e0e81
Reviewed-on: https://gerrit.chromium.org/gerrit/46231
Reviewed-by: David James <davidjames@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh
index d33198f..bbe9ba8 100755
--- a/sdk_lib/enter_chroot.sh
+++ b/sdk_lib/enter_chroot.sh
@@ -89,9 +89,9 @@
CHROME_ROOT_CONFIG="/var/cache/chrome_root" # inside chroot
FUSE_DEVICE="/dev/fuse"
-chmod 0777 "$FLAGS_chroot/var/lock"
-
-LOCKFILE="$FLAGS_chroot/var/lock/enter_chroot"
+# We can't use /var/lock because that might be a symlink to /run/lock outside
+# of the chroot. Or /run on the host system might not exist.
+LOCKFILE="${FLAGS_chroot}/.enter_chroot.lock"
MOUNTED_PATH=$(readlink -f "$FLAGS_chroot")
# Reset the depot tools/internal trunk pathways to what they'll