From f7c9e7785b75ac14c52a010fddbdd2c442314146 Mon Sep 17 00:00:00 2001 From: Matt Tennant Date: Wed, 8 Feb 2012 17:06:26 -0800 Subject: [PATCH] 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 Reviewed-by: Matt Tennant Tested-by: Matt Tennant --- sdk_lib/enter_chroot.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index de484afe48..df3aaf3f00 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -195,6 +195,12 @@ function copy_ssh_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 { # Validate sudo timestamp before entering the critical section so that we # 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 \ user.email "${ident_email}" || true - # Copy ~/.gdata_cred.txt to chroot if it exists. This file contains - # credentials for reading/writing Google Docs on chromium.org. - if [ -f "$HOME/.gdata_cred.txt" ]; then - cp "$HOME/.gdata_cred.txt" "${FLAGS_chroot}/home/${USER}/.gdata_cred.txt" - fi + # Copy ~/.gdata_cred.txt and ~/.gdata_token to chroot if they exist. These + # files contain credentials for reading/writing Google Docs on chromium.org. + for fn in ".gdata_cred.txt" ".gdata_token"; do + copy_into_chroot_if_exists "${HOME}/${fn}" "/home/${USER}/${fn}" + done # Make sure user's requested locales are available # http://crosbug.com/19139