From 4b7fa1e97c09d4bad2c3018accea6d02877f7acb Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 16 Mar 2012 14:28:45 -0400 Subject: [PATCH] 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 Tested-by: Mike Frysinger Commit-Ready: Mike Frysinger --- cros_workon | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index f61d0af02e..ca62b6c3dd 100755 --- a/cros_workon +++ b/cros_workon @@ -97,7 +97,13 @@ cmds=( "ln -sf '${MASK_WORKON_FILE}' '${MASK_FILE}'" "ln -sf '${WORKON_FILE}' '${UNMASK_FILE}'" ) -sudo_multi "${cmds[@]}" +# 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() {