Tristan Corrick has uploaded this change for review.

View Change

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 <tristan@corrick.kiwi>
---
M util/chromeos/crosfirmware.sh
1 file changed, 24 insertions(+), 3 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/30549/1
diff --git a/util/chromeos/crosfirmware.sh b/util/chromeos/crosfirmware.sh
index 7cd9af9..567d58e 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

export PATH="$PATH:/sbin"
@@ -26,6 +23,28 @@
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
@@ -112,6 +131,8 @@

BOARD=$1

+exit_if_dependencies_are_missing
+
if [ "$BOARD" == "all" ]; then
CONF=$( mktemp )
get_inventory $CONF

To view, visit change 30549. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I265bd03666f1273d3c22b60aae860c48c758005b
Gerrit-Change-Number: 30549
Gerrit-PatchSet: 1
Gerrit-Owner: Tristan Corrick <tristan@corrick.kiwi>
Gerrit-MessageType: newchange