From e6a925894c7371b7b400e10f0b7ed69343239176 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Thu, 29 Jul 2010 13:26:53 -0700 Subject: [PATCH] cros-workon: extend show_workon_ebuilds to give full paths, provide wrappers This will allow replacement of equery which in cros-workon Also other ebuild-related operations like grouping workon ebuilds with the same repo * Find for all ebuilds takes almost no time when cached and up to ~2 secs when not * equery takes ages just to load TEST=cros_workon_ebuilds before and after, and diff: --- list1 2010-07-27 21:22:23.000000000 -0700 +++ list2 2010-07-27 21:22:32.000000000 -0700 @@ -1,6 +1,5 @@ app-crypt/tpm-emulator app-crypt/trousers -app-i18n/ibus app-i18n/ibus-chewing app-i18n/ibus-hangul app-i18n/ibus-m17n (ibus is a mistake, not a workon package, i'll fix that in a separate CL) modified: lib/cros_workon_common.sh Review URL: http://codereview.chromium.org/2808072 --- lib/cros_workon_common.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/cros_workon_common.sh b/lib/cros_workon_common.sh index 45f3c13703..129bc0c1d8 100644 --- a/lib/cros_workon_common.sh +++ b/lib/cros_workon_common.sh @@ -6,16 +6,29 @@ # Common library for functions used by workon tools. -show_workon_ebuilds() { +find_workon_ebuilds() { 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 - pushd ${overlay} 1> /dev/null - find . -name '*.ebuild' | xargs fgrep cros-workon | \ - awk -F / '{ print $2 "/" $3 }' | uniq | sort - popd 1> /dev/null + # only look up ebuilds named 9999 to eliminate duplicates + find ${overlay}/ -name '*9999.ebuild' | xargs fgrep cros-workon | \ + sed -e 's/\([.]ebuild\):.*/\1/'|uniq done } + +# wrapper script that caches the result of find_workon_ebuilds() +show_workon_ebuilds_files() { + if [ -z "${CROS_ALL_EBUILDS}" ]; then + CROS_ALL_EBUILDS=$(find_workon_ebuilds) + fi + echo "${CROS_ALL_EBUILDS}" +} + +show_workon_ebuilds() { + show_workon_ebuilds_sources | \ + sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/'| sort +}