Copy ~/.gdata_token to chroot upon enter_chroot.

The refresh-packages builder needs to start using auth tokens for logging into
Google Docs, rather than email/password each time, so this copies ~/.gdata_token
into the chroot in the same way as ~/gdata_cred.txt.

BUG=chromium-os:23819
TEST=Put a file at ~/.gdata_token outside chroot, then run:
`cros_sdk true ; cmp {chroot/home/$USER/,~/}.gdata_token`, which passes.

Change-Id: Ib688a01aa88e0fd0f0211236bb0354813ef1fbb3
Reviewed-on: https://gerrit.chromium.org/gerrit/15550
Commit-Ready: Matt Tennant <mtennant@chromium.org>
Reviewed-by: Matt Tennant <mtennant@chromium.org>
Tested-by: Matt Tennant <mtennant@chromium.org>
This commit is contained in:
Matt Tennant 2012-02-08 17:06:26 -08:00 committed by Gerrit
parent 0534a6ec41
commit f7c9e7785b

View File

@ -195,6 +195,12 @@ function copy_ssh_config {
sed "/^.*\(${filter}\).*$/d" "${sshc}" > "${chroot_ssh_dir}/config" sed "/^.*\(${filter}\).*$/d" "${sshc}" > "${chroot_ssh_dir}/config"
} }
function copy_into_chroot_if_exists {
# $1 is file path outside of chroot to copy to path $2 inside chroot.
[ -e "$1" ] || return
cp "$1" "${FLAGS_chroot}/$2"
}
function setup_env { function setup_env {
# Validate sudo timestamp before entering the critical section so that we # Validate sudo timestamp before entering the critical section so that we
# don't stall for a password while we have the lockfile. # don't stall for a password while we have the lockfile.
@ -389,11 +395,11 @@ function setup_env {
git config -f ${FLAGS_chroot}/home/${USER}/.gitconfig --replace-all \ git config -f ${FLAGS_chroot}/home/${USER}/.gitconfig --replace-all \
user.email "${ident_email}" || true user.email "${ident_email}" || true
# Copy ~/.gdata_cred.txt to chroot if it exists. This file contains # Copy ~/.gdata_cred.txt and ~/.gdata_token to chroot if they exist. These
# credentials for reading/writing Google Docs on chromium.org. # files contain credentials for reading/writing Google Docs on chromium.org.
if [ -f "$HOME/.gdata_cred.txt" ]; then for fn in ".gdata_cred.txt" ".gdata_token"; do
cp "$HOME/.gdata_cred.txt" "${FLAGS_chroot}/home/${USER}/.gdata_cred.txt" copy_into_chroot_if_exists "${HOME}/${fn}" "/home/${USER}/${fn}"
fi done
# Make sure user's requested locales are available # Make sure user's requested locales are available
# http://crosbug.com/19139 # http://crosbug.com/19139