diff options
author | Tom Hughes <tomhughes@chromium.org> | 2020-02-18 13:17:51 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-24 16:10:39 +0000 |
commit | c06e040dcd91b0da76e2a82d41a034b5954c763c (patch) | |
tree | 9ce696ff3bae2a0d0641f3875bb52db30e137065 | |
parent | fc75d9a817df0fcb8f9a878828a146ef1553f18f (diff) | |
download | chrome-ec-c06e040dcd91b0da76e2a82d41a034b5954c763c.tar.gz |
util: Fix shellcheck warnings in getversion.sh
BRANCH=none
BUG=none
TEST=make buildall -j
TEST=for i in $(ls build); do \
bcompare build/$i/ec_version.h \
build.new/$i/ec_version.h; done
Change-Id: If7c30746816075ab9958da96466b3a834746b0e1
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2063377
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Raul E Rangel <rrangel@chromium.org>
Commit-Queue: Raul E Rangel <rrangel@chromium.org>
-rwxr-xr-x | util/getversion.sh | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/util/getversion.sh b/util/getversion.sh index 33c8ebd780..2ac25ef62f 100755 --- a/util/getversion.sh +++ b/util/getversion.sh @@ -6,6 +6,8 @@ # # Generate version information for the EC binary +: "${REPRODUCIBLE_BUILD:=}" + # Use this symbol as a separator to be able to reliably concatenate strings of # text. dc=$'\001' @@ -36,16 +38,16 @@ get_tree_version() { local ver_branch local ver_major - if ghash=`git rev-parse --short --verify HEAD 2>/dev/null`; then - if gdesc=`git describe --dirty --match='v*' 2>/dev/null`; then - IFS="-" fields=($gdesc) + if ghash="$(git rev-parse --short --verify HEAD 2>/dev/null)"; then + if gdesc="$(git describe --dirty --match='v*' 2>/dev/null)"; then + IFS="-" read -r -a fields <<< "${gdesc}" tag="${fields[0]}" - IFS="." vernum=($tag) - numcommits=$((${vernum[2]}+${fields[1]:-0})) + IFS="." read -r -a vernum <<< "${tag}" + numcommits=$((vernum[2]+${fields[1]:-0})) ver_major="${vernum[0]}" ver_branch="${vernum[1]}" else - numcommits=`git rev-list HEAD | wc -l` + numcommits=$(git rev-list HEAD | wc -l) ver_major="v0" ver_branch="0" fi @@ -88,7 +90,6 @@ main() { local vbase local ver - IFS="${dc}" if [[ -z "${STATIC_VERSION}" ]]; then ver="${CR50_SQA:+SQA/}${CR50_DEV:+DBG/}${CRYPTO_TEST:+CT/}${BOARD}_" tool_ver="" @@ -112,10 +113,10 @@ main() { # Create a combined version string for all component directories. if [[ -z "${STATIC_VERSION}" ]]; then - for git_dir in ${dir_list[@]}; do - pushd "${git_dir}" > /dev/null + for git_dir in "${dir_list[@]}"; do + pushd "${git_dir}" > /dev/null || exit 1 component="$(basename "${git_dir}")" - values=( $(get_tree_version) ) + IFS="${dc}" read -r -a values <<< "$(get_tree_version)" vbase="${values[0]}" # Retrieved version information. global_dirty+="${values[1]}" # Non-zero, if the repository is 'dirty' if [ "${component}" != "." ]; then @@ -131,7 +132,7 @@ main() { ver="${ver_32}" fi - popd > /dev/null + popd > /dev/null || exit 1 done fi @@ -149,10 +150,10 @@ main() { echo "/* Sub-fields for use in Makefile.rules and to form build info string" echo " * in common/version.c. */" echo "#define VERSION \"${ver}\"" - if [[ -n "${STATIC_VERSION}" ]] || [[ "$REPRODUCIBLE_BUILD" = 1 ]]; then + if [[ -n "${STATIC_VERSION}" ]] || [[ "${REPRODUCIBLE_BUILD}" = 1 ]]; then echo '#define BUILDER "reproducible@build"' else - echo "#define BUILDER \"${USER}@`hostname`\"" + echo "#define BUILDER \"${USER}@$(hostname)\"" fi if [[ -n "${STATIC_VERSION}" ]]; then |