mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-07 13:06:59 +02:00
Revert "build_packages: Upload command stats after each run."
This reverts commit 615fe57ff0
.
This CL broke mod_image_for_recovery.sh with the following failure:
common.sh: line 684: $2: unbound variable
This bug is easy to fix, but suggests the CL needs more testing, so
we're going to revert for now and re-submit the CL once it's been
verified to pass on release trybots.
Example failure:
http://chromegw.corp.google.com/i/chromeos/builders/x86-mario%20canary/builds/2214/steps/Archive/logs/stdio
BUG=chromium-os:27355
TEST=None, since this is reverting a change that broke the tree.
Change-Id: I61d182e3dcee267a8d9dea3b547fa6a75140d974
Reviewed-on: https://gerrit.chromium.org/gerrit/26077
Reviewed-by: Doug Anderson <dianders@chromium.org>
Tested-by: David James <davidjames@chromium.org>
This commit is contained in:
parent
615fe57ff0
commit
9d9efefe27
@ -186,24 +186,9 @@ if [[ "${FLAGS_showoutput}" -eq "${FLAGS_TRUE}" && \
|
||||
# Only parallel_emerge supports --show-output.
|
||||
EMERGE_FLAGS+=" --show-output"
|
||||
fi
|
||||
|
||||
# Prepare tmp file to capture emerge output from tee.
|
||||
tmpfile=$(mktemp -t tmp.build_packages-emerge.XXXXXX)
|
||||
trap "rm -f '${tmpfile}'" EXIT
|
||||
|
||||
info "Merging board packages ${PACKAGES}"
|
||||
(
|
||||
set -o pipefail
|
||||
sudo -E ${EMERGE_BOARD_CMD} -uDNv ${EMERGE_FLAGS} ${PACKAGES} | \
|
||||
tee "${tmpfile}"
|
||||
)
|
||||
|
||||
# Extract total package count from emerge output.
|
||||
package_count=$(awk '$0 ~ /^Total: [0-9]+ packages/ { print $2 }' "${tmpfile}")
|
||||
rm "${tmpfile}"
|
||||
trap - EXIT
|
||||
sudo -E ${EMERGE_BOARD_CMD} -uDNv ${EMERGE_FLAGS} ${PACKAGES}
|
||||
|
||||
echo "Builds complete"
|
||||
EXTRA_COMMAND_STATS[package_count]=${package_count}
|
||||
command_completed
|
||||
print_time_elapsed
|
||||
echo "Done"
|
||||
|
76
common.sh
76
common.sh
@ -557,10 +557,6 @@ safe_umount_tree() {
|
||||
fi
|
||||
}
|
||||
|
||||
get_git_id() {
|
||||
git var GIT_COMMITTER_IDENT | sed -e 's/^.*<\(\S\+\)>.*$/\1/'
|
||||
}
|
||||
|
||||
# Fixes symlinks that are incorrectly prefixed with the build root ${1}
|
||||
# rather than the real running root '/'.
|
||||
# TODO(sosa) - Merge setup - cleanup below with this method.
|
||||
@ -668,79 +664,13 @@ enable_rw_mount() {
|
||||
# Get current timestamp. Assumes common.sh runs at startup.
|
||||
start_time=$(date +%s)
|
||||
|
||||
# Get time elapsed since start_time in seconds.
|
||||
get_elapsed_seconds() {
|
||||
# Print time elsapsed since start_time.
|
||||
print_time_elapsed() {
|
||||
local end_time=$(date +%s)
|
||||
local elapsed_seconds=$(($end_time - $start_time))
|
||||
echo ${elapsed_seconds}
|
||||
}
|
||||
|
||||
# Print time elapsed since start_time.
|
||||
print_time_elapsed() {
|
||||
# Optional first arg to specify elapsed_seconds. If not given, will
|
||||
# recalculate elapsed time to now. Optional second arg to specify
|
||||
# command name associated with elapsed time.
|
||||
local elapsed_seconds=${1:-$(get_elapsed_seconds)}
|
||||
local cmd_base=$2
|
||||
|
||||
local minutes=$(($elapsed_seconds / 60))
|
||||
local seconds=$(($elapsed_seconds % 60))
|
||||
|
||||
if [ -n "${cmd_base}" ]; then
|
||||
info "Elapsed time (${cmd_base}): ${minutes}m${seconds}s"
|
||||
else
|
||||
info "Elapsed time: ${minutes}m${seconds}s"
|
||||
fi
|
||||
}
|
||||
|
||||
# Associative array for filling in extra command-specific stats before
|
||||
# calling command_completed.
|
||||
declare -A EXTRA_COMMAND_STATS
|
||||
|
||||
# Save original command line.
|
||||
command_line_arr=( "$0" "$@" )
|
||||
|
||||
command_completed() {
|
||||
# Call print_elapsed_time regardless.
|
||||
local run_time=$(get_elapsed_seconds)
|
||||
local cmd_base=$(basename "${command_line_arr[0]}")
|
||||
print_time_elapsed ${run_time} ${cmd_base}
|
||||
|
||||
# Prepare command stats in an associative array. Additonal command-specific
|
||||
# stats can be added through EXTRA_COMMAND_STATS associative array.
|
||||
declare -A stats
|
||||
stats=(
|
||||
[cmd_line]=${command_line_arr[*]}
|
||||
[cmd_base]=${cmd_base}
|
||||
[cmd_args]=${command_line_arr[*]:1}
|
||||
[run_time]=${run_time}
|
||||
[username]=$(get_git_id)
|
||||
[board]=${FLAGS_board}
|
||||
[host]=$(hostname -f)
|
||||
[cpu_count]=$(grep -c processor /proc/cpuinfo)
|
||||
[cpu_type]=$(uname -p)
|
||||
)
|
||||
|
||||
local attr
|
||||
for attr in "${!EXTRA_COMMAND_STATS[@]}"; do
|
||||
stats[${attr}]=${EXTRA_COMMAND_STATS[${attr}]}
|
||||
done
|
||||
|
||||
# Prepare temporary file for stats.
|
||||
local tmpfile=$(mktemp -t tmp.stats.XXXXXX)
|
||||
trap "rm -f '${tmpfile}'" EXIT
|
||||
|
||||
# Write stats out to temporary file.
|
||||
echo "Chromium OS Build Command Stats - Version 1" > "${tmpfile}"
|
||||
for attr in "${!stats[@]}"; do
|
||||
echo "${attr} ${stats[${attr}]}"
|
||||
done >> "${tmpfile}"
|
||||
|
||||
# Call upload_command_stats on the stats file. If it fails do not stop.
|
||||
"${GCLIENT_ROOT}"/chromite/bin/upload_command_stats "${tmpfile}" || true
|
||||
|
||||
rm "${tmpfile}"
|
||||
trap - EXIT
|
||||
echo "Elapsed time: ${minutes}m${seconds}s"
|
||||
}
|
||||
|
||||
# The board and variant command line options can be used in a number of ways
|
||||
|
@ -79,13 +79,6 @@ fi
|
||||
# TODO: replace shflags with something less error-prone, or contribute a fix.
|
||||
switch_to_strict_mode
|
||||
|
||||
# These config files are to be copied into chroot if they exist in home dir.
|
||||
FILES_TO_COPY_TO_CHROOT=(
|
||||
.gdata_cred.txt # User/password for Google Docs on chromium.org
|
||||
.gdata_token # Auth token for Google Docs on chromium.org
|
||||
.disable_build_stats_upload # Presence of file disables command stats upload
|
||||
)
|
||||
|
||||
INNER_CHROME_ROOT=$FLAGS_chrome_root_mount # inside chroot
|
||||
CHROME_ROOT_CONFIG="/var/cache/chrome_root" # inside chroot
|
||||
INNER_DEPOT_TOOLS_ROOT="/home/$USER/depot_tools" # inside chroot
|
||||
@ -404,8 +397,9 @@ setup_env() {
|
||||
git config -f ${FLAGS_chroot}/home/${USER}/.gitconfig --replace-all \
|
||||
user.email "${ident_email}" || true
|
||||
|
||||
# Certain files get copied into the chroot when entering.
|
||||
for fn in "${FILES_TO_COPY_TO_CHROOT[@]}"; do
|
||||
# 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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user