cros_workon: check for board dir before creating dirs

If you pass an invalid board name, or a board that hasn't yet been setup,
cros_workon will happily create the dirs in /build/ for you.  For invalid
boards this isn't a big deal, but for valid ones, this can confuse build
steps later on like ./setup_board.

Change cros_workon to fail immediately if the desired dir under /build/
does not exist.  This will "break" using some operations such as "list"
on boards that were installed at one point but currently no longer are,
but cros_workon needs quite a bit more work in order for that workflow
to be supported (if anyone even cares).

BUG=None
TEST=`./cros_workon --board x86-marioffffff list` quit early

Change-Id: Ib83357d5d1c6383987a6d9e3dae1e86cf4864d82
Reviewed-on: https://gerrit.chromium.org/gerrit/18394
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2012-03-16 14:28:45 -04:00 committed by David James
parent c585c5aa06
commit 4b7fa1e97c

View File

@ -97,7 +97,13 @@ cmds=(
"ln -sf '${MASK_WORKON_FILE}' '${MASK_FILE}'"
"ln -sf '${WORKON_FILE}' '${UNMASK_FILE}'"
)
# If the board dir doesn't exist yet, we don't want to create it as
# that'll screw up ./setup_board later on.
if [[ -d ${BOARD_DIR:-/} ]] ; then
sudo_multi "${cmds[@]}"
else
die "${BOARD_STR} has not been setup yet"
fi
find_keyword_workon_ebuilds() {