cros_workon: redefine the concept of a "workon" package list to depend on the board

* Modified all workon listing functions to also look for keyword

* Added a fallback to list all workon ebuilds if keyword is not specified, which
is needed for cros_mark_all_as_stable, which does not differentiate between boards.

This, amongst other potential issues, resolves the case when it was possible to
start working on a package not keyworded for the given board, and making
build_packages fail unconditionally.

TEST=below
$ ./cros_workon list --all --board=x86-generic |wc -l
73
$ ./cros_workon list --all --host |wc -l
57
Looking at the lists rather than "|wc -l" looks correct
$ ./cros_mark_all_as_stable
^ Produces satisfactory result

BUG=6700

Change-Id: Ieee92a39febcef5fb95e59cf97b6e63281a7c750

Review URL: http://codereview.chromium.org/3400001
This commit is contained in:
Zdenek Behan 2010-09-15 11:33:54 -07:00 committed by David James
parent 8e79ec4bff
commit c28d7a1dfc

View File

@ -60,11 +60,13 @@ if [ -n "${FLAGS_board}" ]; then
EQUERYCMD=equery-"${FLAGS_board}" EQUERYCMD=equery-"${FLAGS_board}"
EBUILDCMD=ebuild-"${FLAGS_board}" EBUILDCMD=ebuild-"${FLAGS_board}"
BOARD_STR="${FLAGS_board}" BOARD_STR="${FLAGS_board}"
BOARD_KEYWORD="$(portageq-${FLAGS_board} envvar ARCH)"
else else
BOARD_DIR="" # --host specified BOARD_DIR="" # --host specified
EQUERYCMD=equery EQUERYCMD=equery
EBUILDCMD=ebuild EBUILDCMD=ebuild
BOARD_STR="host" BOARD_STR="host"
BOARD_KEYWORD="$(portageq envvar ARCH)"
fi fi
WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon
@ -95,7 +97,7 @@ canonicalize_name () {
local pkgfile local pkgfile
local pkgname local pkgname
if ! pkgfile=$(ACCEPT_KEYWORDS="**" ${EQUERYCMD} which $1); then if ! pkgfile=$(ACCEPT_KEYWORDS="~${BOARD_KEYWORD}" ${EQUERYCMD} which $1); then
warn "error looking up package $1" 1>&2 warn "error looking up package $1" 1>&2
return 1 return 1
fi fi
@ -249,7 +251,7 @@ ebuild_iterate() {
# --all makes commands operate on different lists # --all makes commands operate on different lists
if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then
case ${WORKON_CMD} in case ${WORKON_CMD} in
start) ATOM_LIST=$(show_workon_ebuilds);; start) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});;
stop|iterate) ATOM_LIST=$(show_live_ebuilds);; stop|iterate) ATOM_LIST=$(show_live_ebuilds);;
list) ;; list) ;;
*) die "--all is invalid for the given command";; *) die "--all is invalid for the given command";;
@ -270,7 +272,7 @@ fi
case ${WORKON_CMD} in case ${WORKON_CMD} in
start) ebuild_to_live "${ATOM_LIST}" ;; start) ebuild_to_live "${ATOM_LIST}" ;;
stop) ebuild_to_stable "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;;
list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ${BOARD_KEYWORD} ;;
iterate)ebuild_iterate "${ATOM_LIST}" ;; iterate)ebuild_iterate "${ATOM_LIST}" ;;
*) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;;
esac esac