enter_chroot: make sure ccache dir perms are correct
For fresh sdk builds, gcc won't update and automatically see the
ccache tree for us. So make sure the perms are sane when people
enter the chroot. This will also automatically fix perms if/when
people manually delete the ccache dir (which sometimes happens on
the buildbots when people try to free up space).
BUG=None
TEST=`rm -rf distfiles/ccache/; cros_sdk` and see ccache dir get setup nicely
Change-Id: I5bcc86ebf696549b142a7ceb312eb8ec4be5e2bf
Reviewed-on: https://gerrit.chromium.org/gerrit/26257
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh
index b75dce1..d6ef7c4 100755
--- a/sdk_lib/enter_chroot.sh
+++ b/sdk_lib/enter_chroot.sh
@@ -393,6 +393,17 @@
# See https://bugzilla.gnome.org/show_bug.cgi?id=677648
sudo killall -STOP gvfs-gdu-volume-monitor gvfsd-trash 2>/dev/null || true
+ # Fix permissions on ccache tree. If this is a fresh chroot, then they
+ # might not be set up yet. Or if the user manually `rm -rf`-ed things,
+ # we need to reset it. Otherwise, gcc itself takes care of fixing things
+ # on demand, but only when it updates.
+ ccache_dir="${FLAGS_chroot}/var/cache/distfiles/ccache"
+ if [[ ! -d ${ccache_dir} ]]; then
+ sudo mkdir -p -m 2775 "${ccache_dir}"
+ fi
+ sudo find -H "${ccache_dir}" -type d -exec chmod 2775 {} + &
+ sudo find -H "${ccache_dir}" -gid 0 -exec chgrp 250 {} + &
+
# Configure committer username and email in chroot .gitconfig. Change
# to the root directory first so that random $PWD/.git/config settings
# do not get picked up. We want to stick to ~/.gitconfig only.