diff options
author | Mike Frysinger <vapier@chromium.org> | 2016-11-23 12:22:29 -0500 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-11-29 17:41:03 -0800 |
commit | 1e9245dfff914107ec06aac84f3b70c2df1f4a41 (patch) | |
tree | 3766ce65407bd95916bd4e61763ccaa04880eff7 /scripts/image_signing/common.sh | |
parent | c66cbc3440b03440d591274b188ea62b2de7af80 (diff) | |
download | vboot-1e9245dfff914107ec06aac84f3b70c2df1f4a41.tar.gz |
image_signing: unify board extraction logic from lsb-releasefirmware-servo-9040.Bfirmware-reef-9042.87.B
We had two places extracting the board value from lsb-release and parsing
the output by hand. Unify them to use the same parsing logic to avoid
desynchronized behavior.
We also create a new get_boardvar_from_lsb_release helper to unify the
board name -> variable name mangling logic.
BUG=chromium:667192
TEST=`./security_test_image --board samus` still detects the correct board
BRANCH=None
Change-Id: If88a8ae59b9c9fd45ddd796653a0173ed0186d2d
Reviewed-on: https://chromium-review.googlesource.com/414224
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'scripts/image_signing/common.sh')
-rw-r--r-- | scripts/image_signing/common.sh | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/scripts/image_signing/common.sh b/scripts/image_signing/common.sh index 62dc362a..657b5be2 100644 --- a/scripts/image_signing/common.sh +++ b/scripts/image_signing/common.sh @@ -75,14 +75,28 @@ die() { exit 1 } -# Extract and return board name from /etc/lsb-release. -# Args: rootfs +# Usage: lsbval path-to-lsb-file key +# Returns the value for the given lsb-release file variable. +lsbval() { + local lsbfile="$1" + local key="$2" + grep "^${key}=" "${lsbfile}" | sed "s/^${key}=//" +} + +# Usage: get_board_from_lsb_release rootfs +# Returns the exact board name from /etc/lsb-release. This may contain +# dashes or other characters not suitable for variable names. See the +# next function for that. get_board_from_lsb_release() { - local rootfs=$1 - # The cuts turn e.g. x86-foo as a well as x86-foo-pvtkeys into x86_foo. - local board=$(grep CHROMEOS_RELEASE_BOARD= "${rootfs}/etc/lsb-release" | \ - cut -d = -f 2 | cut -d - -f 1,2 --output-delimiter=_) - echo "${board}" + local rootfs="$1" + lsbval "${rootfs}/etc/lsb-release" CHROMEOS_RELEASE_BOARD +} + +# Usage: get_boardvar_from_lsb_release rootfs +# Returns the board name from /etc/lsb-release in a mangled form that can +# be used in variable names. e.g. dashes are turned into underscores. +get_boardvar_from_lsb_release() { + get_board_from_lsb_release "$@" | sed 's:[-]:_:g' } # This will override the trap set in common_minmal.sh |