mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-25 15:41:04 +02:00
cros_workon: add support for a forall command
Change-Id: If0c75ee905c4a8076340fa9675c17e9292125268 Review URL: http://codereview.chromium.org/2880007
This commit is contained in:
parent
43603dd11e
commit
952996c605
48
cros_workon
48
cros_workon
@ -9,10 +9,6 @@
|
|||||||
# last known good commit. Moving an ebuild to 'live' (via cros_workon start)
|
# last known good commit. Moving an ebuild to 'live' (via cros_workon start)
|
||||||
# is intended to support development. The current source tip is fetched,
|
# is intended to support development. The current source tip is fetched,
|
||||||
# source modified and built using the unstable 'live' (9999) ebuild.
|
# source modified and built using the unstable 'live' (9999) ebuild.
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# cros_workon <start|stop> <package> [<package> ...] [--board=<board-name]
|
|
||||||
# cros_workon list
|
|
||||||
|
|
||||||
# Load common constants. This should be the first executable line.
|
# Load common constants. This should be the first executable line.
|
||||||
# The path to common.sh should be relative to your script's location.
|
# The path to common.sh should be relative to your script's location.
|
||||||
@ -24,21 +20,24 @@ get_default_board
|
|||||||
|
|
||||||
DEFINE_string board "${DEFAULT_BOARD}" \
|
DEFINE_string board "${DEFAULT_BOARD}" \
|
||||||
"The board to set package keywords for."
|
"The board to set package keywords for."
|
||||||
|
DEFINE_string command "git status" \
|
||||||
|
"The command to be run by forall."
|
||||||
|
|
||||||
FLAGS_HELP="usage: $0 [flags]"
|
FLAGS_HELP="usage: $0 <command> [flags]
|
||||||
|
commands:
|
||||||
|
start: Moves an ebuild to live (intended to support development)
|
||||||
|
stop: Moves an ebuild to stable (use last known good)
|
||||||
|
list: List of all live ebuilds
|
||||||
|
forall: For each ebuild, cd to the source dir and run a commond"
|
||||||
FLAGS "$@" || exit 1
|
FLAGS "$@" || exit 1
|
||||||
eval set -- "${FLAGS_ARGV}"
|
eval set -- "${FLAGS_ARGV}"
|
||||||
|
|
||||||
if [ -z "${FLAGS_board}" ] ; then
|
[ -n "${FLAGS_board}" ] || die "--board is required."
|
||||||
die "--board is required."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# eat the workon command keywords: start, stop or list.
|
# eat the workon command keywords: start, stop or list.
|
||||||
WORKON_CMD=$1
|
WORKON_CMD=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
ATOM_LIST=$@
|
|
||||||
|
|
||||||
BOARD_DIR=/build/"${FLAGS_board}"
|
BOARD_DIR=/build/"${FLAGS_board}"
|
||||||
KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords
|
KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords
|
||||||
KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon
|
KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon
|
||||||
@ -46,6 +45,14 @@ KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon
|
|||||||
sudo mkdir -p "${KEYWORDS_DIR}" || die "mkdir -p ${KEYWORDS_DIR}"
|
sudo mkdir -p "${KEYWORDS_DIR}" || die "mkdir -p ${KEYWORDS_DIR}"
|
||||||
sudo touch "${KEYWORDS_FILE}" || die "touch ${KEYWORDS_FILE}"
|
sudo touch "${KEYWORDS_FILE}" || die "touch ${KEYWORDS_FILE}"
|
||||||
|
|
||||||
|
# Display ebuilds currently part of the live branch and open for development.
|
||||||
|
show_live_ebuilds () {
|
||||||
|
cat "${KEYWORDS_FILE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
ATOM_LIST=$@
|
||||||
|
[ -n "${ATOM_LIST}" ] || ATOM_LIST=$(show_live_ebuilds)
|
||||||
|
|
||||||
# Move a stable ebuild to the live development catgeory. The ebuild
|
# Move a stable ebuild to the live development catgeory. The ebuild
|
||||||
# src_unpack step fetches the package source for local development.
|
# src_unpack step fetches the package source for local development.
|
||||||
ebuild_to_live () {
|
ebuild_to_live () {
|
||||||
@ -69,14 +76,21 @@ ebuild_to_stable () {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Display ebuilds currently part of the live branch and open for development.
|
# Run a command on all or a set of repos.
|
||||||
show_live_ebuilds () {
|
ebuild_forall() {
|
||||||
cat "${KEYWORDS_FILE}"
|
local atoms=$1
|
||||||
|
|
||||||
|
for atom in ${atoms}; do
|
||||||
|
info "Running \"${FLAGS_command}\" on ${atom}"
|
||||||
|
eval $(ebuild-${FLAGS_board} $(equery-${FLAGS_board} which ${atom}) info)
|
||||||
|
(cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}")
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
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) show_live_ebuilds ;;
|
list) show_live_ebuilds ;;
|
||||||
*) die "valid cros_workon commands: start|stop|list" ;;
|
forall) ebuild_forall "${ATOM_LIST}" ;;
|
||||||
|
*) die "invalid cros_workon command" ;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
x
Reference in New Issue
Block a user