Updates to the board status script
This is the first major re-work for the board status script. Summary: - Added a command to the getrevision.sh script to retrieve tagged revision. - Results are placed in a dynamically generated temporary location. This makes it easy to do multiple trial runs and avoids polluting the coreboot directory. - Results are stored in a directory with the following form: <vendor>/<mainboard>/<tagged_revision>/<timestamp>/ Vendor and mainboard are obtained from CONFIG_MAINBOARD_DIR so that hierarchy is consistent between coreboot and board-status. - The results directory is used as the commit message. - board-status repository is checked out automatically if results are to be uploaded. TODO: - Add ability to run commands which may fail. Currently we assume any failure should terminate the script, but some commands can be made optional. Successfully uploaded first result to board-status repository. See http://review.coreboot.org/gitweb?p=board-status.git;a=summary . Change-Id: Icba41ccad4e6e6ee829b8092a2459c2d72a3365b Signed-off-by: David Hendricks <dhendrix@chromium.org> Reviewed-on: http://review.coreboot.org/4039 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
This commit is contained in:
parent
0dde01cad1
commit
1b6e7a6748
|
@ -55,6 +55,7 @@ tarballs/
|
||||||
|
|
||||||
util/*/.dependencies
|
util/*/.dependencies
|
||||||
util/*/.test
|
util/*/.test
|
||||||
|
util/board_status/board-status
|
||||||
util/cbfstool/cbfstool
|
util/cbfstool/cbfstool
|
||||||
util/cbmem/.dependencies
|
util/cbmem/.dependencies
|
||||||
util/cbmem/cbmem
|
util/cbmem/cbmem
|
||||||
|
|
|
@ -7,13 +7,17 @@
|
||||||
|
|
||||||
EXIT_SUCCESS=0
|
EXIT_SUCCESS=0
|
||||||
EXIT_FAILURE=1
|
EXIT_FAILURE=1
|
||||||
OUTDIR="status"
|
|
||||||
|
|
||||||
# Stuff from command-line switches
|
# Stuff from command-line switches
|
||||||
REMOTE_HOST=""
|
REMOTE_HOST=""
|
||||||
CLOBBER_OUTPUT=0
|
CLOBBER_OUTPUT=0
|
||||||
UPLOAD_RESULTS=0
|
UPLOAD_RESULTS=0
|
||||||
|
|
||||||
|
# Used to specify whether a command should always be run locally or
|
||||||
|
# if command should be run remoteley when a remote host is specified.
|
||||||
|
LOCAL=0
|
||||||
|
REMOTE=1
|
||||||
|
|
||||||
show_help() {
|
show_help() {
|
||||||
echo "Usage:
|
echo "Usage:
|
||||||
${0} <option>
|
${0} <option>
|
||||||
|
@ -22,7 +26,7 @@ Options
|
||||||
-h
|
-h
|
||||||
Show this message.
|
Show this message.
|
||||||
-c
|
-c
|
||||||
Clobber output when finished.
|
Clobber temporary output when finished. Useful when not uploading.
|
||||||
-r <host>
|
-r <host>
|
||||||
Obtain machine information from remote host (using ssh).
|
Obtain machine information from remote host (using ssh).
|
||||||
-u
|
-u
|
||||||
|
@ -42,7 +46,7 @@ test_cmd()
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $1 -eq 1 && "$REMOTE_HOST" ]]; then
|
if [[ $1 -eq $REMOTE && -n "$REMOTE_HOST" ]]; then
|
||||||
ssh root@${REMOTE_HOST} which "$2" >/dev/null
|
ssh root@${REMOTE_HOST} which "$2" >/dev/null
|
||||||
rc=$?
|
rc=$?
|
||||||
else
|
else
|
||||||
|
@ -68,7 +72,7 @@ cmd()
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $1 -eq 1 && -n "$REMOTE_HOST" ]]; then
|
if [[ $1 -eq $REMOTE && -n "$REMOTE_HOST" ]]; then
|
||||||
ssh root@${REMOTE_HOST} "$2"
|
ssh root@${REMOTE_HOST} "$2"
|
||||||
else
|
else
|
||||||
$2
|
$2
|
||||||
|
@ -100,38 +104,87 @@ while getopts "chr:u" opt; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -e "$OUTDIR" ]; then
|
grep -rH 'coreboot.org' .git/config >/dev/null 2>&1
|
||||||
echo "Output directory exists, aborting."
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Script must be run from root of coreboot directory"
|
||||||
exit $EXIT_FAILURE
|
exit $EXIT_FAILURE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir "$OUTDIR"
|
# Results will be placed in a temporary location until we're ready to upload.
|
||||||
|
# If the user does not wish to upload, results will remain in /tmp.
|
||||||
|
tmpdir=$(mktemp -d)
|
||||||
|
|
||||||
|
# Obtain board and revision info to form the directory structure:
|
||||||
|
# <vendor>/<board>/<revision>/<timestamp>
|
||||||
|
cbfstool_cmd="util/cbfstool/cbfstool"
|
||||||
|
test_cmd $LOCAL "$cbfstool_cmd"
|
||||||
|
$cbfstool_cmd build/coreboot.rom extract -n config -f ${tmpdir}/config.txt
|
||||||
|
mainboard_dir="$(grep CONFIG_MAINBOARD_DIR ${tmpdir}/config.txt | awk -F '"' '{ print $2 }')"
|
||||||
|
vendor=$(echo "$mainboard_dir" | awk -F '/' '{ print $1 }')
|
||||||
|
mainboard=$(echo "$mainboard_dir" | awk -F '/' '{ print $2 }')
|
||||||
|
|
||||||
getrevision="util/board_status/getrevision.sh"
|
getrevision="util/board_status/getrevision.sh"
|
||||||
test_cmd 0 $getrevision
|
test_cmd $LOCAL $getrevision
|
||||||
touch ${OUTDIR}/revision.txt
|
tagged_version=$($getrevision -T)
|
||||||
printf "Local revision: %s\n" $($getrevision -l) >> ${OUTDIR}/revision.txt
|
timestamp=$($getrevision -t)
|
||||||
printf "Upstream revision: %s\n" $($getrevision -u) >> ${OUTDIR}/revision.txt
|
|
||||||
printf "Upstream URL: %s\n" $($getrevision -U)>> ${OUTDIR}/revision.txt
|
|
||||||
printf "Timestamp: %s\n" $($getrevision -t) >> ${OUTDIR}/revision.txt
|
|
||||||
|
|
||||||
cbfstool_cmd="util/cbfstool/cbfstool"
|
results="${vendor}/${mainboard}/${tagged_version}/${timestamp}"
|
||||||
test_cmd 0 "$cbfstool_cmd"
|
|
||||||
$cbfstool_cmd build/coreboot.rom extract -n config -f ${OUTDIR}/config.txt
|
|
||||||
|
|
||||||
test_cmd 1 "cbmem"
|
echo "Temporarily placing output in ${tmpdir}/${results}"
|
||||||
cmd 1 "cbmem -c" > ${OUTDIR}/coreboot_console.txt
|
mkdir -p "${tmpdir}/${results}"
|
||||||
cmd 1 "cbmem -t" > ${OUTDIR}/coreboot_timestamps.txt
|
|
||||||
cmd 1 "cbmem -C" > ${OUTDIR}/coreboot_coverage.txt
|
|
||||||
|
|
||||||
cmd 1 dmesg > ${OUTDIR}/kernel_log.txt
|
mv "${tmpdir}/config.txt" "${tmpdir}/${results}"
|
||||||
|
|
||||||
#if [ $UPLOAD_RESULTS -eq 1 ]; then
|
touch ${tmpdir}/${results}/revision.txt
|
||||||
# FIXME: implement this part
|
printf "Local revision: %s\n" "$($getrevision -l)" >> ${tmpdir}/${results}/revision.txt
|
||||||
#fi
|
printf "Tagged revision: %s\n" "${tagged_version}" >> ${tmpdir}/${results}/revision.txt
|
||||||
|
printf "Upstream revision: %s\n" $($getrevision -u) >> ${tmpdir}/${results}/revision.txt
|
||||||
|
printf "Upstream URL: %s\n" $($getrevision -U)>> ${tmpdir}/${results}/revision.txt
|
||||||
|
printf "Timestamp: %s\n" "$timestamp" >> ${tmpdir}/${results}/revision.txt
|
||||||
|
|
||||||
|
test_cmd $REMOTE "cbmem"
|
||||||
|
cmd $REMOTE "cbmem -c" > ${tmpdir}/${results}/coreboot_console.txt
|
||||||
|
|
||||||
|
# TODO: Some commands should be optional and be non-fatal in case of error.
|
||||||
|
#cmd $REMOTE "cbmem -t" > ${outdir}/coreboot_timestamps.txt
|
||||||
|
|
||||||
|
cmd $REMOTE dmesg > ${tmpdir}/${results}/kernel_log.txt
|
||||||
|
|
||||||
|
# FIXME: the board-status directory might get big over time. Is there a way we
|
||||||
|
# can push the results without fetching the whole repo?
|
||||||
|
coreboot_dir=`pwd`
|
||||||
|
if [ $UPLOAD_RESULTS -eq 1 ]; then
|
||||||
|
# extract username from ssh://<username>@review.coreboot.org/blah
|
||||||
|
username=$(git config --get remote.origin.url | sed 's/ssh\:\/\///' | sed 's/@.*//')
|
||||||
|
|
||||||
|
cd "util/board_status/"
|
||||||
|
if [ ! -e "board-status" ]; then
|
||||||
|
git clone "ssh://${username}@review.coreboot.org:29418/board-status"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
"Error cloning board-status repo, aborting."
|
||||||
|
exit $EXIT_FAILURE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "board-status"
|
||||||
|
echo "Copying results to $(pwd)/${results}"
|
||||||
|
|
||||||
|
# Note: Result directory should be unique due to the timestamp.
|
||||||
|
cp -R "${tmpdir}/${vendor}" .
|
||||||
|
|
||||||
|
echo "Uploading results"
|
||||||
|
git add "${vendor}"
|
||||||
|
git commit -a -am "${mainboard_dir}/${tagged_version}/${timestamp}"
|
||||||
|
git push origin
|
||||||
|
|
||||||
|
# Results have been uploaded so it's pointless to keep the
|
||||||
|
# temporary files around.
|
||||||
|
rm -rf "${tmpdir}"
|
||||||
|
fi
|
||||||
|
cd "$coreboot_dir"
|
||||||
|
|
||||||
if [ $CLOBBER_OUTPUT -eq 1 ]; then
|
if [ $CLOBBER_OUTPUT -eq 1 ]; then
|
||||||
rm -rf ${OUTDIR}
|
rm -rf ${tmpdir}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $EXIT_SUCCESS
|
exit $EXIT_SUCCESS
|
||||||
|
|
|
@ -121,6 +121,20 @@ local_revision() {
|
||||||
echo "${r}"
|
echo "${r}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Similar to local_revision but uses "git describe" instead of "git log" which
|
||||||
|
# includes number of commits since most recent tag.
|
||||||
|
tagged_revision() {
|
||||||
|
local r
|
||||||
|
|
||||||
|
if git_is_file_tracked "$1" ; then
|
||||||
|
r=$(git describe --tags --dirty)
|
||||||
|
else
|
||||||
|
return ${EXIT_FAILURE}
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${r}"
|
||||||
|
}
|
||||||
|
|
||||||
upstream_revision() {
|
upstream_revision() {
|
||||||
local r=
|
local r=
|
||||||
|
|
||||||
|
@ -143,6 +157,8 @@ Commands
|
||||||
local revision information including an indicator for uncommitted changes
|
local revision information including an indicator for uncommitted changes
|
||||||
-u or --upstream
|
-u or --upstream
|
||||||
upstream revision
|
upstream revision
|
||||||
|
-T or --tags
|
||||||
|
similar to -l, but uses \"git describe\" to obtain revision info with tags
|
||||||
-U or --url
|
-U or --url
|
||||||
URL associated with the latest commit
|
URL associated with the latest commit
|
||||||
-d or --date
|
-d or --date
|
||||||
|
@ -175,6 +191,10 @@ main() {
|
||||||
check_action $1
|
check_action $1
|
||||||
action=local_revision
|
action=local_revision
|
||||||
shift;;
|
shift;;
|
||||||
|
-T|--tags)
|
||||||
|
check_action $1
|
||||||
|
action=tagged_revision
|
||||||
|
shift;;
|
||||||
-u|--upstream)
|
-u|--upstream)
|
||||||
check_action $1
|
check_action $1
|
||||||
action=upstream_revision
|
action=upstream_revision
|
||||||
|
|
Loading…
Reference in New Issue