Chromium Code Reviews| Index: common.sh |
| diff --git a/common.sh b/common.sh |
| index 1d25074316d2a336046e3a5311cc1d6de5b02a37..ac10de6e1c5df104232427793c304eab80a57ec0 100644 |
| --- a/common.sh |
| +++ b/common.sh |
| @@ -647,3 +647,36 @@ prepare_test_image() { |
| # From now on we use the just-created test image |
| CHROMEOS_RETURN_VAL="$1/${CHROMEOS_TEST_IMAGE_NAME}" |
| } |
| + |
| +# Check that the specified file exists. If the file path is empty or the file |
| +# doesn't exist on the filesystem generate useful error messages. Otherwise |
| +# show the user the name and path of the file that will be used. |
| +check_for_file() { |
| + local name=$1 |
| + local padding=$2 |
| + local path=$3 |
| + |
| + if [ -z "${path}" ]; then |
| + error "No ${name} file specified." && exit |
|
davidjames
2011/03/01 00:09:49
1. Looks like this is exiting with a success code.
robotboy
2011/03/01 00:20:19
Done.
|
| + fi |
| + |
| + if [ ! -e "${path}" ]; then |
| + error "No ${name} file found at: ${path}" && exit |
| + else |
| + info "Using ${name}${padding}: ${path}" |
| + fi |
| +} |
| + |
| +# Check that the specified tool exists. If it does not exist in the PATH |
| +# generate a useful error message indicating how to install the ebuild |
| +# that contains the required tool. |
| +check_for_tool() { |
| + local tool=$1 |
| + local ebuild=$2 |
| + |
| + if ! which "${tool}" >/dev/null ; then |
| + error "The ${tool} utility was not found in your path. Run the following" |
| + error "command in your chroot to install it: sudo -E emerge ${ebuild}" |
| + exit |
| + fi |
| +} |