From 916b1f1e11cb40105b87349bc7fb66de13858ca1 Mon Sep 17 00:00:00 2001 From: Chris Wolfe Date: Mon, 30 Apr 2012 16:03:06 -0400 Subject: [PATCH] enter_chroot: symlink boto config from chromeos-overlay, if available The private chromeos-overlay has shared credentials for read-only access to the archive of CrOS images. When entering the chroot check whether these credentials are available, and install them to ~/.boto within the chroot unless that file already exists. BUG=None TEST=Applied patch and entered fresh private and public chroots. Manually ran 'gsutil config' to replace the credentials; this works as long as there is no ~/.boto.bak already. Re-entered the chroot with manually-configured credentials. Ran 'gsutil ls' with BOTO_CONFIG set to a board-specific boto. Change-Id: Ib62dc28f90bce692a833b5fc9d4c56981acc98d1 Reviewed-on: https://gerrit.chromium.org/gerrit/21480 Reviewed-by: Mike Frysinger Tested-by: Chris Wolfe Commit-Ready: Chris Wolfe --- sdk_lib/enter_chroot.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index df3aaf3f00..3e49230b3b 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -435,6 +435,23 @@ function setup_env { if [ -n "$(find "${FLAGS_chroot}/dev/shm" ! -perm 777)" ] ; then sudo chmod -R 777 "${FLAGS_chroot}/dev/shm" fi + + # If the private overlays are installed, gsutil can use those credentials. + if [ ! -e "${FLAGS_chroot}/home/${USER}/.boto" ]; then + boto='src/private-overlays/chromeos-overlay/googlestorage_account.boto' + if [ -s "${FLAGS_trunk}/${boto}" ]; then + ln -s "trunk/${boto}" "${FLAGS_chroot}/home/${USER}/.boto" + fi + fi + + # Have found a few chroots where ~/.gsutil is owned by root:root, probably + # as a result of old gsutil or tools. This causes permission errors when + # gsutil cp tries to create its cache files, so ensure the user can + # actually write to their directory. + gsutil_dir="${FLAGS_chroot}/home/${USER}/.gsutil" + if [ -d "${gsutil_dir}" ] && [ ! -w "${gsutil_dir}" ]; then + sudo chown -R "${USER}:$(id -gn)" "${gsutil_dir}" + fi ) 200>>"$LOCKFILE" || die "setup_env failed" }