cros_workon: leverage sudo_multi

The common.sh file has a `sudo_multi` helper to collapse multiple sudo
calls into a single one for a minor speed up.  Use it.

BUG=None
TEST=`./cros_workon --board x86-alex start metrics` still works
TEST=`./cros_workon --board x86-alex stop metrics` still works

Change-Id: I4b670a4d4d6f1402a69f1f7129cadc645cc93225
Reviewed-on: https://gerrit.chromium.org/gerrit/18171
Reviewed-by: Chris Wolfe <cwolfe@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2012-03-14 18:20:41 -04:00 committed by David James
parent 0d5efffd97
commit 5bf25dbbe7

View File

@ -80,19 +80,19 @@ CHROME_ATOM=chromeos-base/chromeos-chrome
mkdir -p "${WORKON_DIR}" || die "mkdir -p ${WORKON_DIR}"
touch "${WORKON_FILE}" || die "touch ${WORKON_FILE}"
sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \
die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}"
cmds=(
"mkdir -p '${KEYWORDS_DIR}' '${UNMASK_DIR}'"
# Clobber and re-create the WORKON_FILE symlinks every time. This
# is a trivial operation and eliminates all kinds of corner cases
# as well as any possible future renames of WORKON_FILE.
# In particular, chroot is usually built as "amd64-host" but becomes
# just "host" after installation. crosbug.com/23096
sudo rm -f "${KEYWORDS_FILE}" "${UNMASK_FILE}"
sudo ln -s "${WORKON_FILE}" "${KEYWORDS_FILE}" || \
die "ln -s ${WORKON_FILE} ${KEYWORDS_FILE}"
sudo ln -s "${WORKON_FILE}" "${UNMASK_FILE}" || \
die "ln -s ${WORKON_FILE} ${UNMASK_FILE}"
# Clobber and re-create the WORKON_FILE symlinks every time. This
# is a trivial operation and eliminates all kinds of corner cases
# as well as any possible future renames of WORKON_FILE.
# In particular, chroot is usually built as "amd64-host" but becomes
# just "host" after installation. crosbug.com/23096
"rm -f '${KEYWORDS_FILE}' '${UNMASK_FILE}'"
"ln -s '${WORKON_FILE}' '${KEYWORDS_FILE}'"
"ln -s '${WORKON_FILE}' '${UNMASK_FILE}'"
)
sudo_multi "${cmds[@]}"
find_keyword_workon_ebuilds() {