mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-07 13:06:59 +02:00
Propagate Google API keys into the chroot.
These are a new type of credential baked into chrome/chromium for developers without internal copies of ChromeOS, and not building internal versions of Chrome. We automatically move .googleapikeys into the chroot each time. We don't overwrite the destination, so that people can configure keys the way they want. If they just don't want to be bothered, the best thing happens the easiest way. Get Keys, put them in home. Keep working. BUG=chromium-os:34438 TEST=local Change-Id: I08e5970c6092f7b789aa5efef52db93841996d8f Reviewed-on: https://gerrit.chromium.org/gerrit/33771 Reviewed-by: Mike Frysinger <vapier@chromium.org> Commit-Ready: Peter Mayo <petermayo@chromium.org> Tested-by: Peter Mayo <petermayo@chromium.org>
This commit is contained in:
parent
dda30b4f70
commit
4411efeb87
@ -56,6 +56,8 @@ the command nor args should include single quotes. For example:
|
||||
Otherwise, provides an interactive shell.
|
||||
"
|
||||
|
||||
CROS_LOG_PREFIX=cros_sdk:enter_chroot
|
||||
|
||||
# Version of info from common.sh that only echos if --verbose is set.
|
||||
debug() {
|
||||
if [ $FLAGS_verbose -eq $FLAGS_TRUE ]; then
|
||||
@ -212,6 +214,35 @@ copy_into_chroot_if_exists() {
|
||||
cp "$1" "${FLAGS_chroot}/$2"
|
||||
}
|
||||
|
||||
# Usage: promote_api_keys
|
||||
# This takes care of getting the developer API keys into the chroot where
|
||||
# chrome can build with them. It needs to take it from the places a dev
|
||||
# is likely to put them, and recognize that older chroots may or may not
|
||||
# have been used since the concept of keys got added, as well as before
|
||||
# and after the developer decding to grab his own keys.
|
||||
promote_api_keys() {
|
||||
local destination="${FLAGS_chroot}/home/${USER}/.googleapikeys"
|
||||
# Don't disturb existing keys. They could be set differently
|
||||
if [[ -s "${destination}" ]]; then
|
||||
return 0
|
||||
fi
|
||||
if [[ -r "${HOME}/.googleapikeys" ]]; then
|
||||
cp "${HOME}/.googleapikeys" "${destination}"
|
||||
if [[ -s "${destination}" ]] ; then
|
||||
info "Copied Google API keys into chroot."
|
||||
fi
|
||||
elif [[ -r "${HOME}/.gyp/include.gypi" ]]; then
|
||||
local NAME="('google_(api_key|default_client_(id|secret))')"
|
||||
local WS="[[:space:]]*"
|
||||
local CONTENTS="('[^\\\\']*')"
|
||||
sed -nr -e "/^${WS}${NAME}${WS}[:=]${WS}${CONTENTS}.*/{s//\1: \4,/;p;}" \
|
||||
"${HOME}/.gyp/include.gypi" >"${destination}"
|
||||
if [[ -s "${destination}" ]]; then
|
||||
info "Put discovered Google API keys into chroot."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
setup_env() {
|
||||
# Validate sudo timestamp before entering the critical section so that we
|
||||
# don't stall for a password while we have the lockfile.
|
||||
@ -433,6 +464,7 @@ setup_env() {
|
||||
for fn in "${FILES_TO_COPY_TO_CHROOT[@]}"; do
|
||||
copy_into_chroot_if_exists "${HOME}/${fn}" "/home/${USER}/${fn}"
|
||||
done
|
||||
promote_api_keys
|
||||
|
||||
# Make sure user's requested locales are available
|
||||
# http://crosbug.com/19139
|
||||
|
@ -52,7 +52,7 @@ FLAGS "$@" || exit 1
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
check_flags_only_and_allow_null_arg "$@" && set --
|
||||
|
||||
CROS_LOG_PREFIX=cros_sdk
|
||||
CROS_LOG_PREFIX=cros_sdk:make_chroot
|
||||
|
||||
assert_not_root_user
|
||||
# Set the right umask for chroot creation.
|
||||
|
Loading…
Reference in New Issue
Block a user