blob: 89f578f309ef2df724437a5a68207684c726295e [file] [log] [blame]
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: cros-credentials.eclass
# @MAINTAINER:
# ChromiumOS Build Team
# @BUGREPORTS:
# Please report bugs via http://crbug.com/new (with label Build)
# @VCSURL: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/master/eclass/@ECLASS@
# @BLURB: Set credentials properly to access private git repo.
# @DESCRIPTION:
# Copy in credentials to fake home directory so that build process can
# access vcs and ssh if needed.
# Add a call to cros-credentials_setup before accessing a private repo.
cros-credentials_setup() {
mkdir -p "${HOME}"
local whoami=$(whoami)
local ssh_config_dir="/home/${whoami}/.ssh"
if [[ -d "${ssh_config_dir}" ]]; then
cp -rfp "${ssh_config_dir}" "${HOME}" || die
fi
local net_config="/home/${whoami}/.netrc"
if [[ -f "${net_config}" ]]; then
cp -fp "${net_config}" "${HOME}" || die
fi
local gitcookies_src="/home/${whoami}/.gitcookies"
local gitcookies_dst="${HOME}/.gitcookies"
if [[ -f "${gitcookies_src}" ]]; then
cp -fp "${gitcookies_src}" "${gitcookies_dst}" || die
git config --global http.cookiefile "${gitcookies_dst}"
fi
}