[coreboot-gerrit] New patch to review for coreboot: 84998dc rename status-related stuff to board_status
David Hendricks (dhendrix@chromium.org)
gerrit at coreboot.org
Tue Nov 12 03:56:19 CET 2013
David Hendricks (dhendrix at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4038
-gerrit
commit 84998dc8327dcfc87738c594d62767e0b0947214
Author: David Hendricks <dhendrix at chromium.org>
Date: Mon Nov 11 18:43:39 2013 -0800
rename status-related stuff to board_status
This just moves stuff to be more clear about the purpose of
the script. Other suggestions are welcome.
Change-Id: Ic6095fd4eb347daa5a03eff21b5952d2d42a6bfd
Signed-off-by: David Hendricks <dhendrix at chromium.org>
---
util/board_status/board_status.sh | 137 +++++++++++++++++++++++
util/board_status/getrevision.sh | 228 ++++++++++++++++++++++++++++++++++++++
util/status/getrevision.sh | 228 --------------------------------------
util/status/status.sh | 137 -----------------------
4 files changed, 365 insertions(+), 365 deletions(-)
diff --git a/util/board_status/board_status.sh b/util/board_status/board_status.sh
new file mode 100644
index 0000000..d2955e0
--- /dev/null
+++ b/util/board_status/board_status.sh
@@ -0,0 +1,137 @@
+#!/bin/sh
+#
+# This file is part of the coreboot project.
+#
+# Copyright (C) 2013 Google Inc.
+#
+
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+OUTDIR="status"
+
+# Stuff from command-line switches
+REMOTE_HOST=""
+CLOBBER_OUTPUT=0
+UPLOAD_RESULTS=0
+
+show_help() {
+ echo "Usage:
+ ${0} <option>
+
+Options
+ -h
+ Show this message.
+ -c
+ Clobber output when finished.
+ -r <host>
+ Obtain machine information from remote host (using ssh).
+ -u
+ Upload results to coreboot.org.
+"
+}
+
+# test a command
+#
+# $1: test command on remote host (0=no, 1=yes)
+# $2: command to test
+test_cmd()
+{
+ local rc
+
+ if [ -e "$2" ]; then
+ return
+ fi
+
+ if [[ $1 -eq 1 && "$REMOTE_HOST" ]]; then
+ ssh root@${REMOTE_HOST} which "$2" >/dev/null
+ rc=$?
+ else
+ which "$2" >/dev/null
+ rc=$?
+ fi
+
+ if [ $rc -eq 0 ]; then
+ return
+ fi
+
+ echo "$2 not found"
+ exit $EXIT_FAILURE
+}
+
+# run a command
+#
+# $1: 0 to run command locally, 1 to run remotely if remote host defined
+# $2: command
+cmd()
+{
+ if [ -e "$2" ]; then
+ return
+ fi
+
+ if [[ $1 -eq 1 && -n "$REMOTE_HOST" ]]; then
+ ssh root@${REMOTE_HOST} "$2"
+ else
+ $2
+ fi
+
+ if [ $? -eq 0 ]; then
+ return
+ fi
+
+ echo "Failed to run command: $2"
+ exit $EXIT_FAILURE
+}
+
+while getopts "chr:u" opt; do
+ case "$opt" in
+ h)
+ show_help
+ exit $EXIT_SUCCESS
+ ;;
+ c)
+ CLOBBER_OUTPUT=1
+ ;;
+ r)
+ REMOTE_HOST="$OPTARG"
+ ;;
+ u)
+ UPLOAD_RESULTS=1
+ ;;
+ esac
+done
+
+if [ -e "$OUTDIR" ]; then
+ echo "Output directory exists, aborting."
+ exit $EXIT_FAILURE
+fi
+
+mkdir "$OUTDIR"
+
+getrevision="util/board_status/getrevision.sh"
+test_cmd 0 $getrevision
+touch ${OUTDIR}/revision.txt
+printf "Local revision: %s\n" $($getrevision -l) >> ${OUTDIR}/revision.txt
+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"
+test_cmd 0 "$cbfstool_cmd"
+$cbfstool_cmd build/coreboot.rom extract -n config -f ${OUTDIR}/config.txt
+
+test_cmd 1 "cbmem"
+cmd 1 "cbmem -c" > ${OUTDIR}/coreboot_console.txt
+cmd 1 "cbmem -t" > ${OUTDIR}/coreboot_timestamps.txt
+cmd 1 "cbmem -C" > ${OUTDIR}/coreboot_coverage.txt
+
+cmd 1 dmesg > ${OUTDIR}/kernel_log.txt
+
+#if [ $UPLOAD_RESULTS -eq 1 ]; then
+# FIXME: implement this part
+#fi
+
+if [ $CLOBBER_OUTPUT -eq 1 ]; then
+ rm -rf ${OUTDIR}
+fi
+
+exit $EXIT_SUCCESS
diff --git a/util/board_status/getrevision.sh b/util/board_status/getrevision.sh
new file mode 100755
index 0000000..c8c126a
--- /dev/null
+++ b/util/board_status/getrevision.sh
@@ -0,0 +1,228 @@
+#!/bin/sh
+#
+# This file is part of the coreboot project. It originated in the
+# flashrom project but has been heavily modified since then.
+#
+# Copyright (C) 2013 Stefan Tauner
+# Copyright (C) 2013 Google Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+# Make sure we don't get translated output
+export LC_ALL=C
+# nor local times or dates
+export TZ=UTC0
+
+# Helper functions
+git_has_local_changes() {
+ git update-index -q --refresh >/dev/null
+ ! git diff-index --quiet HEAD -- "$1"
+}
+
+git_last_commit() {
+ git log --pretty=format:"%h" -1 -- "$1"
+}
+
+git_is_file_tracked() {
+ git ls-files --error-unmatch -- "$1" >/dev/null 2>&1
+}
+
+is_file_tracked() {
+ git_is_file_tracked "$1"
+}
+
+# Tries to find a remote source for the changes committed locally.
+# This includes the URL of the remote repository including the last commit and a suitable branch name.
+# Takes one optional argument: the path to inspect
+git_url() {
+ # Note: This may not work as expected if multiple remotes are fetched from.
+ echo $(git remote -v | \
+ awk '/fetch/ {split($2, pieces, "@"); print pieces[2]; exit 0}')
+}
+
+# Returns a string indicating where others can get the current source code (excluding uncommitted changes)
+# Takes one optional argument: the path to inspect
+scm_url() {
+ local url
+
+ url="$(git_url "$1")"
+
+ echo "${url}"
+}
+
+# Retrieve timestamp since last modification. If the sources are pristine,
+# then the timestamp will match that of the SCM's most recent modification
+# date.
+timestamp() {
+ local t
+
+ # date syntaxes are manifold:
+ # gnu date [-d input]... [+FORMAT]
+ # netbsd date [-ajnu] [-d date] [-r seconds] [+format] [[[[[[CC]yy]mm]dd]HH]MM[.SS]]
+ # freebsd date [-jnu] [-d dst] [-r seconds] [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] [...]
+ # dragonflybsd date [-jnu] [-d dst] [-r seconds] [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] [...]
+ # openbsd date [-aju] [-d dst] [-r seconds] [+format] [[[[[[cc]yy]mm]dd]HH]MM[.SS]] [...]
+ if git_is_file_tracked "$2" ; then
+ # are there local changes?
+ if git_has_local_changes "$2" ; then
+ t=$(date -u "${1}")
+ else
+ # No local changes, get date of the last commit
+ case $(uname) in
+ # Most BSD dates do not support parsing date values from user input with -d but all of
+ # them support parsing epoch seconds with -r. Thanks to git we can easily use that:
+ NetBSD|OpenBSD|DragonFly|FreeBSD)
+ t=$(date -u -r "$(git log --pretty=format:%ct -1 -- $2)" "$1" 2>/dev/null);;
+ *)
+ t=$(date -d "$(git log --pretty=format:%cD -1 -- $2)" -u "$1" 2>/dev/null);;
+ esac
+ fi
+ else
+ t=$(date -u "$1")
+ fi
+
+ if [ -z "$t" ]; then
+ echo "Warning: Could not determine timestamp." 2>/dev/null
+ fi
+ echo "${t}"
+}
+
+# Retrieve local SCM revision info. This is useful if we're working in a different SCM than upstream and/or
+# have local changes.
+local_revision() {
+ local r
+
+ if git_is_file_tracked "$1" ; then
+ r=$(git_last_commit "$1")
+
+ if git_has_local_changes "$1" ; then
+ r="$r-dirty"
+ fi
+ else
+ return ${EXIT_FAILURE}
+ fi
+
+ echo "${r}"
+}
+
+upstream_revision() {
+ local r=
+
+ r=$(git log remotes/origin/master -1 --format=format:%h)
+
+ if [ -z "$r" ]; then
+ r="unknown" # default to unknown
+ fi
+ echo "${r}"
+}
+
+show_help() {
+ echo "Usage:
+ ${0} <command> [path]
+
+Commands
+ -h or --help
+ this message
+ -l or --local
+ local revision information including an indicator for uncommitted changes
+ -u or --upstream
+ upstream revision
+ -U or --url
+ URL associated with the latest commit
+ -d or --date
+ date of most recent modification
+ -t or --timestamp
+ timestamp of most recent modification
+"
+ return
+}
+
+check_action() {
+ if [ -n "$action" ]; then
+ echo "Error: Multiple actions given.">&2
+ exit ${EXIT_FAILURE}
+ fi
+}
+
+main() {
+ local query_path=
+ local action=
+
+ # The is the main loop
+ while [ $# -gt 0 ];
+ do
+ case ${1} in
+ -h|--help)
+ action=show_help;
+ shift;;
+ -l|--local)
+ check_action $1
+ action=local_revision
+ shift;;
+ -u|--upstream)
+ check_action $1
+ action=upstream_revision
+ shift;;
+ -U|--url)
+ check_action $1
+ action=scm_url
+ shift;;
+ -d|--date)
+ check_action $1
+ action="timestamp +%Y-%m-%d" # refrain from suffixing 'Z' to indicate it's UTC
+ shift;;
+ -t|--timestamp)
+ check_action $1
+ action="timestamp +%Y-%m-%dT%H:%M:%SZ" # There is only one valid time format! ISO 8601
+ shift;;
+ -*)
+ show_help;
+ echo "Error: Invalid option: ${1}"
+ exit ${EXIT_FAILURE};;
+ *)
+ if [ -z "$query_path" ] ; then
+ if [ ! -e "$1" ] ; then
+ echo "Error: Path \"${1}\" does not exist.">&2
+ exit ${EXIT_FAILURE}
+ fi
+ query_path=$1
+ else
+ echo "Warning: Ignoring over-abundant paramter: \"${1}\"">&2
+ fi
+ shift;;
+ esac;
+ done
+
+ # default to current directory (usually equals the whole repository)
+ if [ -z "$query_path" ] ; then
+ query_path=.
+ fi
+ if ! is_file_tracked "$query_path" ; then
+ echo "Warning: Path \"${query_path}\" is not under version control.">&2
+ fi
+ if [ -z "$action" ] ; then
+ show_help
+ echo "Error: No actions specified"
+ exit ${EXIT_FAILURE}
+ fi
+
+ $action "$query_path"
+}
+
+main $@
diff --git a/util/status/getrevision.sh b/util/status/getrevision.sh
deleted file mode 100755
index c8c126a..0000000
--- a/util/status/getrevision.sh
+++ /dev/null
@@ -1,228 +0,0 @@
-#!/bin/sh
-#
-# This file is part of the coreboot project. It originated in the
-# flashrom project but has been heavily modified since then.
-#
-# Copyright (C) 2013 Stefan Tauner
-# Copyright (C) 2013 Google Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
-
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-
-# Make sure we don't get translated output
-export LC_ALL=C
-# nor local times or dates
-export TZ=UTC0
-
-# Helper functions
-git_has_local_changes() {
- git update-index -q --refresh >/dev/null
- ! git diff-index --quiet HEAD -- "$1"
-}
-
-git_last_commit() {
- git log --pretty=format:"%h" -1 -- "$1"
-}
-
-git_is_file_tracked() {
- git ls-files --error-unmatch -- "$1" >/dev/null 2>&1
-}
-
-is_file_tracked() {
- git_is_file_tracked "$1"
-}
-
-# Tries to find a remote source for the changes committed locally.
-# This includes the URL of the remote repository including the last commit and a suitable branch name.
-# Takes one optional argument: the path to inspect
-git_url() {
- # Note: This may not work as expected if multiple remotes are fetched from.
- echo $(git remote -v | \
- awk '/fetch/ {split($2, pieces, "@"); print pieces[2]; exit 0}')
-}
-
-# Returns a string indicating where others can get the current source code (excluding uncommitted changes)
-# Takes one optional argument: the path to inspect
-scm_url() {
- local url
-
- url="$(git_url "$1")"
-
- echo "${url}"
-}
-
-# Retrieve timestamp since last modification. If the sources are pristine,
-# then the timestamp will match that of the SCM's most recent modification
-# date.
-timestamp() {
- local t
-
- # date syntaxes are manifold:
- # gnu date [-d input]... [+FORMAT]
- # netbsd date [-ajnu] [-d date] [-r seconds] [+format] [[[[[[CC]yy]mm]dd]HH]MM[.SS]]
- # freebsd date [-jnu] [-d dst] [-r seconds] [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] [...]
- # dragonflybsd date [-jnu] [-d dst] [-r seconds] [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] [...]
- # openbsd date [-aju] [-d dst] [-r seconds] [+format] [[[[[[cc]yy]mm]dd]HH]MM[.SS]] [...]
- if git_is_file_tracked "$2" ; then
- # are there local changes?
- if git_has_local_changes "$2" ; then
- t=$(date -u "${1}")
- else
- # No local changes, get date of the last commit
- case $(uname) in
- # Most BSD dates do not support parsing date values from user input with -d but all of
- # them support parsing epoch seconds with -r. Thanks to git we can easily use that:
- NetBSD|OpenBSD|DragonFly|FreeBSD)
- t=$(date -u -r "$(git log --pretty=format:%ct -1 -- $2)" "$1" 2>/dev/null);;
- *)
- t=$(date -d "$(git log --pretty=format:%cD -1 -- $2)" -u "$1" 2>/dev/null);;
- esac
- fi
- else
- t=$(date -u "$1")
- fi
-
- if [ -z "$t" ]; then
- echo "Warning: Could not determine timestamp." 2>/dev/null
- fi
- echo "${t}"
-}
-
-# Retrieve local SCM revision info. This is useful if we're working in a different SCM than upstream and/or
-# have local changes.
-local_revision() {
- local r
-
- if git_is_file_tracked "$1" ; then
- r=$(git_last_commit "$1")
-
- if git_has_local_changes "$1" ; then
- r="$r-dirty"
- fi
- else
- return ${EXIT_FAILURE}
- fi
-
- echo "${r}"
-}
-
-upstream_revision() {
- local r=
-
- r=$(git log remotes/origin/master -1 --format=format:%h)
-
- if [ -z "$r" ]; then
- r="unknown" # default to unknown
- fi
- echo "${r}"
-}
-
-show_help() {
- echo "Usage:
- ${0} <command> [path]
-
-Commands
- -h or --help
- this message
- -l or --local
- local revision information including an indicator for uncommitted changes
- -u or --upstream
- upstream revision
- -U or --url
- URL associated with the latest commit
- -d or --date
- date of most recent modification
- -t or --timestamp
- timestamp of most recent modification
-"
- return
-}
-
-check_action() {
- if [ -n "$action" ]; then
- echo "Error: Multiple actions given.">&2
- exit ${EXIT_FAILURE}
- fi
-}
-
-main() {
- local query_path=
- local action=
-
- # The is the main loop
- while [ $# -gt 0 ];
- do
- case ${1} in
- -h|--help)
- action=show_help;
- shift;;
- -l|--local)
- check_action $1
- action=local_revision
- shift;;
- -u|--upstream)
- check_action $1
- action=upstream_revision
- shift;;
- -U|--url)
- check_action $1
- action=scm_url
- shift;;
- -d|--date)
- check_action $1
- action="timestamp +%Y-%m-%d" # refrain from suffixing 'Z' to indicate it's UTC
- shift;;
- -t|--timestamp)
- check_action $1
- action="timestamp +%Y-%m-%dT%H:%M:%SZ" # There is only one valid time format! ISO 8601
- shift;;
- -*)
- show_help;
- echo "Error: Invalid option: ${1}"
- exit ${EXIT_FAILURE};;
- *)
- if [ -z "$query_path" ] ; then
- if [ ! -e "$1" ] ; then
- echo "Error: Path \"${1}\" does not exist.">&2
- exit ${EXIT_FAILURE}
- fi
- query_path=$1
- else
- echo "Warning: Ignoring over-abundant paramter: \"${1}\"">&2
- fi
- shift;;
- esac;
- done
-
- # default to current directory (usually equals the whole repository)
- if [ -z "$query_path" ] ; then
- query_path=.
- fi
- if ! is_file_tracked "$query_path" ; then
- echo "Warning: Path \"${query_path}\" is not under version control.">&2
- fi
- if [ -z "$action" ] ; then
- show_help
- echo "Error: No actions specified"
- exit ${EXIT_FAILURE}
- fi
-
- $action "$query_path"
-}
-
-main $@
diff --git a/util/status/status.sh b/util/status/status.sh
deleted file mode 100644
index 4b5496c..0000000
--- a/util/status/status.sh
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/bin/sh
-#
-# This file is part of the coreboot project.
-#
-# Copyright (C) 2013 Google Inc.
-#
-
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-OUTDIR="status"
-
-# Stuff from command-line switches
-REMOTE_HOST=""
-CLOBBER_OUTPUT=0
-UPLOAD_RESULTS=0
-
-show_help() {
- echo "Usage:
- ${0} <option>
-
-Options
- -h
- Show this message.
- -c
- Clobber output when finished.
- -r <host>
- Obtain machine information from remote host (using ssh).
- -u
- Upload results to coreboot.org.
-"
-}
-
-# test a command
-#
-# $1: test command on remote host (0=no, 1=yes)
-# $2: command to test
-test_cmd()
-{
- local rc
-
- if [ -e "$2" ]; then
- return
- fi
-
- if [[ $1 -eq 1 && "$REMOTE_HOST" ]]; then
- ssh root@${REMOTE_HOST} which "$2" >/dev/null
- rc=$?
- else
- which "$2" >/dev/null
- rc=$?
- fi
-
- if [ $rc -eq 0 ]; then
- return
- fi
-
- echo "$2 not found"
- exit $EXIT_FAILURE
-}
-
-# run a command
-#
-# $1: 0 to run command locally, 1 to run remotely if remote host defined
-# $2: command
-cmd()
-{
- if [ -e "$2" ]; then
- return
- fi
-
- if [[ $1 -eq 1 && -n "$REMOTE_HOST" ]]; then
- ssh root@${REMOTE_HOST} "$2"
- else
- $2
- fi
-
- if [ $? -eq 0 ]; then
- return
- fi
-
- echo "Failed to run command: $2"
- exit $EXIT_FAILURE
-}
-
-while getopts "chr:u" opt; do
- case "$opt" in
- h)
- show_help
- exit $EXIT_SUCCESS
- ;;
- c)
- CLOBBER_OUTPUT=1
- ;;
- r)
- REMOTE_HOST="$OPTARG"
- ;;
- u)
- UPLOAD_RESULTS=1
- ;;
- esac
-done
-
-if [ -e "$OUTDIR" ]; then
- echo "Output directory exists, aborting."
- exit $EXIT_FAILURE
-fi
-
-mkdir "$OUTDIR"
-
-getrevision="util/status/getrevision.sh"
-test_cmd 0 $getrevision
-touch ${OUTDIR}/revision.txt
-printf "Local revision: %s\n" $($getrevision -l) >> ${OUTDIR}/revision.txt
-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"
-test_cmd 0 "$cbfstool_cmd"
-$cbfstool_cmd build/coreboot.rom extract -n config -f ${OUTDIR}/config.txt
-
-test_cmd 1 "cbmem"
-cmd 1 "cbmem -c" > ${OUTDIR}/coreboot_console.txt
-cmd 1 "cbmem -t" > ${OUTDIR}/coreboot_timestamps.txt
-cmd 1 "cbmem -C" > ${OUTDIR}/coreboot_coverage.txt
-
-cmd 1 dmesg > ${OUTDIR}/kernel_log.txt
-
-#if [ $UPLOAD_RESULTS -eq 1 ]; then
-# FIXME: implement this part
-#fi
-
-if [ $CLOBBER_OUTPUT -eq 1 ]; then
- rm -rf ${OUTDIR}
-fi
-
-exit $EXIT_SUCCESS
More information about the coreboot-gerrit
mailing list