mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-05 20:26:44 +02:00
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:
parent
ef45f16aa2
commit
e9474900c6
@ -60,11 +60,13 @@ if [ -n "${FLAGS_board}" ]; then
|
||||
EQUERYCMD=equery-"${FLAGS_board}"
|
||||
EBUILDCMD=ebuild-"${FLAGS_board}"
|
||||
BOARD_STR="${FLAGS_board}"
|
||||
BOARD_KEYWORD="$(portageq-${FLAGS_board} envvar ARCH)"
|
||||
else
|
||||
BOARD_DIR="" # --host specified
|
||||
EQUERYCMD=equery
|
||||
EBUILDCMD=ebuild
|
||||
BOARD_STR="host"
|
||||
BOARD_KEYWORD="$(portageq envvar ARCH)"
|
||||
fi
|
||||
|
||||
WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon
|
||||
@ -95,7 +97,7 @@ canonicalize_name () {
|
||||
local pkgfile
|
||||
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
|
||||
return 1
|
||||
fi
|
||||
@ -249,7 +251,7 @@ ebuild_iterate() {
|
||||
# --all makes commands operate on different lists
|
||||
if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then
|
||||
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);;
|
||||
list) ;;
|
||||
*) die "--all is invalid for the given command";;
|
||||
@ -270,7 +272,7 @@ fi
|
||||
case ${WORKON_CMD} in
|
||||
start) ebuild_to_live "${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}" ;;
|
||||
*) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;;
|
||||
esac
|
||||
|
||||
@ -6,7 +6,9 @@
|
||||
|
||||
# Common library for functions used by workon tools.
|
||||
|
||||
find_workon_ebuilds() {
|
||||
find_keyword_workon_ebuilds() {
|
||||
keyword="${1}"
|
||||
|
||||
pushd "${BOARD_DIR}"/etc/ 1> /dev/null
|
||||
source make.conf
|
||||
popd 1> /dev/null
|
||||
@ -15,20 +17,17 @@ find_workon_ebuilds() {
|
||||
# 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 fgrep cros-workon | \
|
||||
sed -e 's/\([.]ebuild\):.*/\1/'|uniq
|
||||
find ${overlay}/ -name '*9999.ebuild' | \
|
||||
xargs grep -l "inherit.*cros-workon" | \
|
||||
xargs grep -l "KEYWORDS=.*${keyword}.*"
|
||||
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_files | \
|
||||
sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/'| sort
|
||||
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.
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user