From f9ea0036fa5ae7c9122c8133a5e5d03e2896ed1c Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Mon, 31 Jan 2011 16:13:30 -0800 Subject: [PATCH] cros_workon: collapse cros_workon_common.sh cros_workon is the only user of cros_workon_common.sh This is pre-requisite to moving cros_workon into devutils.git BUG=11507 TEST=Ran ./cros_workon --board x86-generic --all list Change-Id: I1eab551ab33646360e507328932c151a0d36f50a Review URL: http://codereview.chromium.org/6347052 --- cros_workon | 29 ++++++++++++++++++++++++++--- lib/cros_workon_common.sh | 33 --------------------------------- 2 files changed, 26 insertions(+), 36 deletions(-) delete mode 100644 lib/cros_workon_common.sh diff --git a/cros_workon b/cros_workon index 61b1e47420..0c7ded12ad 100755 --- a/cros_workon +++ b/cros_workon @@ -14,9 +14,6 @@ # 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 @@ -98,6 +95,32 @@ if [ ! -L "${UNMASK_FILE}" ]; then die "ln -s ${WORKON_FILE} ${UNMASK_FILE}" fi +find_keyword_workon_ebuilds() { + keyword="${1}" + + pushd "${BOARD_DIR}"/etc/ 1> /dev/null + source make.conf + popd 1> /dev/null + local CROS_OVERLAYS="${PORTDIR_OVERLAY}" + + # NOTE: overlay may be a symlink, and we have to use ${overlay}/ + for overlay in ${CROS_OVERLAYS}; do + # only look up ebuilds named 9999 to eliminate duplicates + find ${overlay}/ -name '*9999.ebuild' | \ + xargs grep -l "inherit.*cros-workon" | \ + xargs grep -l "KEYWORDS=.*${keyword}.*" + done +} + +show_workon_ebuilds() { + keyword=$1 + + find_keyword_workon_ebuilds ${keyword} | \ + sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/' | \ + sort -u + # This changes the absolute path to ebuilds into category/package. +} + # Canonicalize package name to category/package. canonicalize_name () { local pkgfile diff --git a/lib/cros_workon_common.sh b/lib/cros_workon_common.sh deleted file mode 100644 index b7f1a12bee..0000000000 --- a/lib/cros_workon_common.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/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. - -find_keyword_workon_ebuilds() { - keyword="${1}" - - pushd "${BOARD_DIR}"/etc/ 1> /dev/null - source make.conf - popd 1> /dev/null - local CROS_OVERLAYS="${PORTDIR_OVERLAY}" - - # NOTE: overlay may be a symlink, and we have to use ${overlay}/ - for overlay in ${CROS_OVERLAYS}; do - # only look up ebuilds named 9999 to eliminate duplicates - find ${overlay}/ -name '*9999.ebuild' | \ - xargs grep -l "inherit.*cros-workon" | \ - xargs grep -l "KEYWORDS=.*${keyword}.*" - done -} - -show_workon_ebuilds() { - keyword=$1 - - find_keyword_workon_ebuilds ${keyword} | \ - sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/' | \ - sort -u - # This changes the absolute path to ebuilds into category/package. -}