From 5bf25dbbe721b59c11a34f00f308efc267a7cea2 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 14 Mar 2012 18:20:41 -0400 Subject: [PATCH] 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 Reviewed-by: David James Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- cros_workon | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cros_workon b/cros_workon index 18676ce50e..7a7f7d3873 100755 --- a/cros_workon +++ b/cros_workon @@ -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() {