From 39a3a48a18c236dd7fd28f3e171b8452e726d5b0 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Sun, 29 Nov 2015 14:02:50 -0800 Subject: [PATCH 1/2] enter_chroot: add support for passing through GNUPGHOME When running under jenkins the $GNUPGHOME may be located under the current build directory instead of $HOME to avoid conflicting with other jobs on the same build host. --- common.sh | 1 + sdk_lib/enter_chroot.sh | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common.sh b/common.sh index a097c47ef1..3e101a41c7 100644 --- a/common.sh +++ b/common.sh @@ -231,6 +231,7 @@ load_environment_whitelist() { GIT_PROXY_COMMAND GIT_SSH RSYNC_PROXY + GNUPGHOME GPG_AGENT_INFO SSH_AGENT_PID SSH_AUTH_SOCK diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index 236a0beb86..bf4cf842f3 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -293,9 +293,10 @@ setup_env() { fi # Mount GnuPG's data directory for signing uploads - if [[ -d "$SUDO_HOME/.gnupg" ]]; then + : ${GNUPGHOME:="$SUDO_HOME/.gnupg"} + if [[ -d "${GNUPGHOME}" ]]; then debug "Mounting GnuPG" - setup_mount "${SUDO_HOME}/.gnupg" "--bind" "/home/${SUDO_USER}/.gnupg" + setup_mount "${GNUPGHOME}" "--bind" "${GNUPGHOME}" # bind mount the gpg agent dir if available GPG_AGENT_DIR="${GPG_AGENT_INFO%/*}" From 0b6acf86056319ffa01516dc43ca18f94eb2c822 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 30 Nov 2015 09:29:24 -0800 Subject: [PATCH 2/2] common: add support for using COREOS_BUILD_ID from the environment This allows build systems to export COREOS_BUILD_ID, making it practical to map built images to the job that created them. --- common.sh | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/common.sh b/common.sh index 3e101a41c7..a1e526b0ea 100644 --- a/common.sh +++ b/common.sh @@ -219,11 +219,8 @@ get_gclient_root() { # Populate the ENVIRONMENT_WHITELIST array. load_environment_whitelist() { ENVIRONMENT_WHITELIST=( - CHROMEOS_OFFICIAL - CHROMEOS_VERSION_AUSERVER - CHROMEOS_VERSION_DEVSERVER - CHROMEOS_VERSION_TRACK - GCC_GITHASH + COREOS_BUILD_ID + COREOS_OFFICIAL GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME GIT_COMMITTER_EMAIL @@ -244,6 +241,13 @@ load_environment_whitelist() { ) } +load_environment_var() { + local file="$1" name="$2" + local value + value=$(grep "^${name}=" "${file}") + export "${value}" +} + # Find root of source tree get_gclient_root @@ -267,23 +271,22 @@ BUILD_LIBRARY_DIR="${SCRIPTS_DIR}/build_library" REPO_CACHE_DIR="${REPO_ROOT}/.cache" REPO_MANIFESTS_DIR="${REPO_ROOT}/.repo/manifests" -# Source COREOS_* from manifest for version information. -COREOS_VERSION_FILE="${REPO_MANIFESTS_DIR}/version.txt" -if [[ ! -f "${COREOS_VERSION_FILE}" ]]; then - COREOS_VERSION_FILE="${SCRIPT_LOCATION}/version.txt" +# Source COREOS_VERSION_ID from manifest. +if [[ -f "${REPO_MANIFESTS_DIR}/version.txt" ]]; then + load_environment_var "${REPO_MANIFESTS_DIR}/version.txt" COREOS_VERSION_ID + # The build id may be provided externally by the build system. + : ${COREOS_BUILD_ID:=$(date +%Y-%m-%d-%H%M)} +elif [[ -f "${SCRIPT_LOCATION}/version.txt" ]]; then + load_environment_var "${SCRIPT_LOCATION}/version.txt" COREOS_VERSION_ID + # This only happens in update.zip where we must use the current build id. + load_environment_var "${SCRIPT_LOCATION}/version.txt" COREOS_BUILD_ID +else + die "Unable to locate version.txt" fi -source "$COREOS_VERSION_FILE" || die "Cannot source version.txt" - -# Set version based on old variables if undefined -: ${COREOS_VERSION_ID:=${COREOS_BUILD}.${COREOS_BRANCH}.${COREOS_PATCH}} # Official builds must set COREOS_OFFICIAL=1 to use an official version. -# Unofficial builds always appended the date/time as a build identifier. -# Also do not alter the version if using an alternate version.txt path. -COREOS_BUILD_ID="" -if [[ ${COREOS_OFFICIAL:-0} -ne 1 && - "${COREOS_VERSION_FILE}" =~ /\.repo/manifests/version.txt ]]; then - COREOS_BUILD_ID=$(date +%Y-%m-%d-%H%M) +# Unofficial builds always appended the build identifier. +if [[ ${COREOS_OFFICIAL:-0} -ne 1 && -n "${COREOS_BUILD_ID}" ]]; then COREOS_VERSION="${COREOS_VERSION_ID}+${COREOS_BUILD_ID}" else COREOS_VERSION="${COREOS_VERSION_ID}"