cros_workon: initial implementation

Moves ebuild(s) between stable and live states.

Lists ebuilds currently under development in the testing branch.

Stable ebuilds obtain and build against the last known good commit.
Live ebuilds (9999) perform a 'git clone' during the src_unpack
step to obtain and save the source for development and building.

Example usage:

  Sync & build 'ibus-hangul' testing ebuild (9999)
     ./cros_workon start app-i18n/ibus-hangul

  Build 'ibus-hangul' from the last stable commit
     ./cros_workon stop app-i18n/ibus-hangul

  List of ebuilds under development
     ./cros_workon list

Change-Id: I2ea4babd7597d5cea9ca96419a74152f9f0b23f1

Note: --board must be specified if the --default option
      to setup_board was not used.

Review URL: http://codereview.chromium.org/2852019
This commit is contained in:
Brian Daugherty 2010-06-23 14:43:28 -06:00 committed by David James
parent 51d4faa68b
commit 01772ff58f

105
cros_workon Executable file
View File

@ -0,0 +1,105 @@
#!/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.
# This script moves ebuilds between 'stable' and 'live' states.
# By default 'stable' ebuilds point at and build from source at the
# last known good commit. Moving an ebuild to 'live' (via cros_workon start)
# is intended to support development. The current source tip is fetched,
# 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.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# Script must be run inside the chroot
restart_in_chroot_if_needed $*
get_default_board
DEFINE_string board "${DEFAULT_BOARD}" \
"The board to set package keywords for."
FLAGS_HELP="usage: $0 [flags]"
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
if [ -z "${FLAGS_board}" ] ; then
die "--board is required."
fi
# eat the workon command keywords: start, stop or list.
WORKON_CMD=$1
shift
ATOM_LIST=$@
BOARD_DIR=/build/"${FLAGS_board}"
KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords
KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon
# Move a stable ebuild to the live development catgeory. The ebuild
# src_unpack step fetches the package source for local development.
ebuild_to_live () {
local atoms=$1
echo
echo "Moving stable ebuild to live development:"
if [[ -d "${KEYWORDS_DIR}" ]]; then
sudo mkdir -p "${KEYWORDS_DIR}"
fi
for atom in ${atoms}; do
if [[ -f "${KEYWORDS_FILE}" ]] &&
$(grep -qx "${atom}" "${KEYWORDS_FILE}") ; then
echo " '${atom}' already marked for development"
else
echo " '${atom}'"
sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\""
fi
done
}
# Move a live development ebuild back to stable.
ebuild_to_stable () {
local atoms=$1
echo
echo "Moving live development ebuild to stable:"
for atom in ${atoms}; do
if [[ -f "${KEYWORDS_FILE}" ]] &&
$(grep -qx "${atom}" "${KEYWORDS_FILE}") ; then
echo " '${atom}'"
sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \
\"${KEYWORDS_FILE}+\""
sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}"
fi
done
}
# Display ebuilds currently part of the live branch and open for development.
show_live_ebuilds () {
echo
echo "Live development ebuilds:"
cat "${KEYWORDS_FILE}"
}
case ${WORKON_CMD} in
start) ebuild_to_live "${ATOM_LIST}" ;;
stop) ebuild_to_stable "${ATOM_LIST}" ;;
list) show_live_ebuilds ;;
*) die "valid cros_workon commands: start|stop|list" ;;
esac