From a5e394704d08639f4f284eba7deb0a73a321a5cb Mon Sep 17 00:00:00 2001 From: Chris Sosa Date: Mon, 19 Jul 2010 11:50:11 -0700 Subject: [PATCH] Create common script file for workon tools. Planning on using in another CL. Review URL: http://codereview.chromium.org/3022010 --- cros_workon | 17 +++-------------- lib/cros_workon_common.sh | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 lib/cros_workon_common.sh diff --git a/cros_workon b/cros_workon index 73431a3109..e9d02426be 100755 --- a/cros_workon +++ b/cros_workon @@ -14,6 +14,9 @@ # The path to common.sh should be relative to your script's location. . "$(dirname "$0")/common.sh" +# Load common functions for workon scripts. +. "$(dirname "$0")/lib/cros_workon_common.sh" + # Script must be run inside the chroot restart_in_chroot_if_needed $* get_default_board @@ -154,20 +157,6 @@ ebuild_iterate() { done } -show_workon_ebuilds() { - pushd "${BOARD_DIR}"/etc/ 1> /dev/null - source make.conf - popd 1> /dev/null - local CROS_OVERLAYS="${PORTDIR_OVERLAY}" - - for overlay in ${CROS_OVERLAYS}; do - pushd ${overlay} 1> /dev/null - find . -name '*.ebuild' | xargs fgrep cros-workon | \ - awk -F / '{ print $2 "/" $3 }' | uniq | sort - popd 1> /dev/null - done -} - # --all makes commands operate on different lists if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then case ${WORKON_CMD} in diff --git a/lib/cros_workon_common.sh b/lib/cros_workon_common.sh new file mode 100644 index 0000000000..45f3c13703 --- /dev/null +++ b/lib/cros_workon_common.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Common library for functions used by workon tools. + +show_workon_ebuilds() { + pushd "${BOARD_DIR}"/etc/ 1> /dev/null + source make.conf + popd 1> /dev/null + local CROS_OVERLAYS="${PORTDIR_OVERLAY}" + + for overlay in ${CROS_OVERLAYS}; do + pushd ${overlay} 1> /dev/null + find . -name '*.ebuild' | xargs fgrep cros-workon | \ + awk -F / '{ print $2 "/" $3 }' | uniq | sort + popd 1> /dev/null + done +}