From d80607da4d540a27b9f30e665de696a903a9375e Mon Sep 17 00:00:00 2001 From: Tristan Corrick Date: Mon, 31 Dec 2018 20:54:42 +1300 Subject: util/chromeos/crosfirmware.sh: Check for dependencies crosfirmware.sh has dependencies that might not be installed on some systems. If a dependency is missing, provide a clear message about the issue and how to resolve it. Change-Id: I265bd03666f1273d3c22b60aae860c48c758005b Signed-off-by: Tristan Corrick Reviewed-on: https://review.coreboot.org/c/30549 Reviewed-by: Patrick Georgi Tested-by: build bot (Jenkins) --- util/chromeos/crosfirmware.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/util/chromeos/crosfirmware.sh b/util/chromeos/crosfirmware.sh index 0d3c40a281..16ab24774c 100755 --- a/util/chromeos/crosfirmware.sh +++ b/util/chromeos/crosfirmware.sh @@ -14,9 +14,6 @@ # GNU General Public License for more details. # -# This script needs -# * sharutils - #DEBUG=1 # On some systems, `parted` and `debugfs` are located in /sbin. @@ -27,6 +24,28 @@ debug() test "$DEBUG" == "1" && echo "$*" } +exit_if_uninstalled() { + local cmd_name="$1" + local deb_pkg_name="$2" + + if type "$cmd_name" >/dev/null 2>&1; then + return + fi + + printf '`%s` was not found. ' "$cmd_name" >&2 + printf 'On Debian-based systems, it can be installed\n' >&2 + printf 'by running `apt install %s`.\n' "$deb_pkg_name" >&2 + + exit 1 +} + +exit_if_dependencies_are_missing() { + exit_if_uninstalled "uudecode" "sharutils" + exit_if_uninstalled "debugfs" "e2fsprogs" + exit_if_uninstalled "parted" "parted" + exit_if_uninstalled "curl" "curl" +} + get_inventory() { _conf=$1 @@ -113,6 +132,8 @@ do_one_board() BOARD=$1 +exit_if_dependencies_are_missing + if [ "$BOARD" == "all" ]; then CONF=$( mktemp ) get_inventory $CONF -- cgit v1.2.3