diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2016-07-27 22:45:28 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-07-28 22:57:21 -0700 |
commit | 33bbf37d2af612d701a004070c358502c4bbe83d (patch) | |
tree | 09b124d4eab6a2470ecc3d57f7989f55f81e0980 /util | |
parent | 12f22933e30f169c214520324dc1570143744d38 (diff) | |
download | chrome-ec-33bbf37d2af612d701a004070c358502c4bbe83d.tar.gz |
util: collect cr50 versions from multiple git trees
The cr50 code comes from four different repositories. This patch
introduces an array of the repositories where version information is
supposed to come from.
For all boards but cr50 this array includes just the local repository,
for cr50 the array is extended with the three other components.
This patch also allows to change the 'tree dirty' marker appended to
the sha1s of the 'dirty' trees, having a shorter marker helps to keep
multicomponent version strings shorter.
All external component's version information in the generated combined
version string is prepended by the component's root directory name.
BRANCH=ToT
BUG=chrome-os-partner:55373
TEST=ran the script for two EC boards, kevin and cr50, verified the
output:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$ BOARD=kevin ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
* in common/version.c. */
/* Repo is clean, use the commit date of the last commit */
$
$ BOARD=cr50 ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
* in common/version.c. */
/* Repo is clean, use the commit date of the last commit */
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
then introduced some local changes in the ec and tpm2 directories and
ran the script again. Note the '+' used as the 'dirty' marker in the
cr50 string:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$ BOARD=kevin ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
* in common/version.c. */
/* Repo is dirty, using time of last compilation */
$
$ BOARD=cr50 ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
* in common/version.c. */
/* Repo is dirty, using time of last compilation */
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Change-Id: I4b4ec23ce003970c09442e8d8aeed2306d4e5dd8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363917
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'util')
-rwxr-xr-x | util/getversion.sh | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/util/getversion.sh b/util/getversion.sh index bb1b7c5574..83c42d88e5 100755 --- a/util/getversion.sh +++ b/util/getversion.sh @@ -10,6 +10,9 @@ # text. dc=$'\001' +# Default marker to indicate 'dirty' repositories +dirty_marker='-dirty' + # This function examines the state of the current directory and attempts to # extract its version information: the latest tag, if any, how many patches # are there since the latest tag, the top sha1, and if there are local @@ -25,6 +28,7 @@ dc=$'\001' # "no_version" get_tree_version() { + local dirty local ghash local numcommits local tag @@ -49,7 +53,9 @@ get_tree_version() { # changed git status > /dev/null 2>&1 - dirty=`sh -c "[ '$(git diff-index --name-only HEAD)' ] && echo '-dirty'"` + if [ -n "$(git diff-index --name-only HEAD 2>/dev/null)" ]; then + dirty="${dirty_marker}" + fi vbase="${ver_major}.${ver_branch}.${numcommits}-${ghash}${dirty}" else # Fall back to the VCSID provided by the packaging system if available. @@ -63,11 +69,34 @@ get_tree_version() { echo "${vbase}${dc}${dirty}" } + IFS="${dc}" -values=( $(get_tree_version) ) -vbase="${values[0]}" # Retrieved version information. -dirty="${values[1]}" # Non-zero, if the repository is 'dirty' -ver="${BOARD}_${vbase}" +ver="${BOARD}_" +global_dirty= # set if any of the component repos is 'dirty'. +dir_list=( . ) # list of component directories, always includes the EC tree + +case "${BOARD}" in + (cr50) + # cr50 includes sources from 4 different git trees. Shortened 'dirty' tree + # marker allows to keep the summary version string shorter. + dirty_marker='+' + dir_list+=( private-cr51 ../../third_party/tpm2 ../../third_party/cryptoc ) + ;; +esac + +# Create a combined version string for all component directories. +for git_dir in ${dir_list[@]}; do + pushd "${git_dir}" > /dev/null + component="$(basename "${git_dir}")" + values=( $(get_tree_version) ) + vbase="${values[0]}" # Retrieved version information. + global_dirty+="${values[1]}" # Non-zero, if the repository is 'dirty' + if [ "${component}" != "." ]; then + ver+=" ${component}:" + fi + ver+="${vbase}" + popd > /dev/null +done echo "/* This file is generated by util/getversion.sh */" @@ -82,7 +111,7 @@ echo " * in common/version.c. */" echo "#define VERSION \"${ver}\"" echo "#define BUILDER \"${USER}@`hostname`\"" -if [ -n "$dirty" ]; then +if [ -n "$global_dirty" ]; then echo "/* Repo is dirty, using time of last compilation */" echo "#define DATE \"$(date '+%F %T')\"" else |