OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # This script moves ebuilds between 'stable' and 'live' states. | 7 # This script moves ebuilds between 'stable' and 'live' states. |
8 # By default 'stable' ebuilds point at and build from source at the | 8 # By default 'stable' ebuilds point at and build from source at the |
9 # last known good commit. Moving an ebuild to 'live' (via cros_workon start) | 9 # last known good commit. Moving an ebuild to 'live' (via cros_workon start) |
10 # is intended to support development. The current source tip is fetched, | 10 # is intended to support development. The current source tip is fetched, |
11 # source modified and built using the unstable 'live' (9999) ebuild. | 11 # source modified and built using the unstable 'live' (9999) ebuild. |
12 # | |
13 # Usage: | |
14 # cros_workon <start|stop> <package> [<package> ...] [--board=<board-name] | |
15 # cros_workon list | |
16 | 12 |
17 # Load common constants. This should be the first executable line. | 13 # Load common constants. This should be the first executable line. |
18 # The path to common.sh should be relative to your script's location. | 14 # The path to common.sh should be relative to your script's location. |
19 . "$(dirname "$0")/common.sh" | 15 . "$(dirname "$0")/common.sh" |
20 | 16 |
21 # Script must be run inside the chroot | 17 # Script must be run inside the chroot |
22 restart_in_chroot_if_needed $* | 18 restart_in_chroot_if_needed $* |
23 get_default_board | 19 get_default_board |
24 | 20 |
25 DEFINE_string board "${DEFAULT_BOARD}" \ | 21 DEFINE_string board "${DEFAULT_BOARD}" \ |
26 "The board to set package keywords for." | 22 "The board to set package keywords for." |
23 DEFINE_string command "git status" \ | |
24 "The command to be run by forall." | |
27 | 25 |
28 FLAGS_HELP="usage: $0 [flags]" | 26 FLAGS_HELP="usage: $0 <command> [flags] |
27 commands: | |
28 start: Moves an ebuild to live (intended to support development) | |
29 stop: Moves an ebuild to stable (use last known good) | |
30 list: List of all live ebuilds | |
31 forall: For each ebuild, cd to the source dir and run a commond" | |
29 FLAGS "$@" || exit 1 | 32 FLAGS "$@" || exit 1 |
30 eval set -- "${FLAGS_ARGV}" | 33 eval set -- "${FLAGS_ARGV}" |
31 | 34 |
32 if [ -z "${FLAGS_board}" ] ; then | 35 [ -n "${FLAGS_board}" ] || die "--board is required." |
33 die "--board is required." | |
34 fi | |
35 | 36 |
36 # eat the workon command keywords: start, stop or list. | 37 # eat the workon command keywords: start, stop or list. |
37 WORKON_CMD=$1 | 38 WORKON_CMD=$1 |
38 shift | 39 shift |
39 | 40 |
40 ATOM_LIST=$@ | |
41 | |
42 BOARD_DIR=/build/"${FLAGS_board}" | 41 BOARD_DIR=/build/"${FLAGS_board}" |
43 KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords | 42 KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords |
44 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon | 43 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon |
45 | 44 |
46 sudo mkdir -p "${KEYWORDS_DIR}" || die "mkdir -p ${KEYWORDS_DIR}" | 45 sudo mkdir -p "${KEYWORDS_DIR}" || die "mkdir -p ${KEYWORDS_DIR}" |
47 sudo touch "${KEYWORDS_FILE}" || die "touch ${KEYWORDS_FILE}" | 46 sudo touch "${KEYWORDS_FILE}" || die "touch ${KEYWORDS_FILE}" |
48 | 47 |
48 # Display ebuilds currently part of the live branch and open for development. | |
49 show_live_ebuilds () { | |
50 cat "${KEYWORDS_FILE}" | |
51 } | |
52 | |
53 ATOM_LIST=$@ | |
54 [ -n "${ATOM_LIST}" ] || ATOM_LIST=$(show_live_ebuilds) | |
55 | |
49 # Move a stable ebuild to the live development catgeory. The ebuild | 56 # Move a stable ebuild to the live development catgeory. The ebuild |
50 # src_unpack step fetches the package source for local development. | 57 # src_unpack step fetches the package source for local development. |
51 ebuild_to_live () { | 58 ebuild_to_live () { |
52 local atoms=$1 | 59 local atoms=$1 |
53 | 60 |
54 for atom in ${atoms}; do | 61 for atom in ${atoms}; do |
55 if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then | 62 if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then |
56 sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" | 63 sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" |
57 fi | 64 fi |
58 done | 65 done |
59 } | 66 } |
60 | 67 |
61 # Move a live development ebuild back to stable. | 68 # Move a live development ebuild back to stable. |
62 ebuild_to_stable () { | 69 ebuild_to_stable () { |
63 local atoms=$1 | 70 local atoms=$1 |
64 | 71 |
65 for atom in ${atoms}; do | 72 for atom in ${atoms}; do |
66 sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \ | 73 sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \ |
67 \"${KEYWORDS_FILE}+\"" | 74 \"${KEYWORDS_FILE}+\"" |
68 sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}" | 75 sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}" |
69 done | 76 done |
70 } | 77 } |
71 | 78 |
72 # Display ebuilds currently part of the live branch and open for development. | 79 # Run a command on all or a set of repos |
sosa
2010/07/01 00:22:58
nit: period at end
| |
73 show_live_ebuilds () { | 80 ebuild_forall() { |
74 cat "${KEYWORDS_FILE}" | 81 local atoms=$1 |
82 | |
83 for atom in ${atoms}; do | |
84 info "Running \"${FLAGS_command}\" on ${atom}" | |
85 eval $(ebuild-${FLAGS_board} $(equery-${FLAGS_board} which ${atom}) info) | |
86 (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}") | |
87 done | |
75 } | 88 } |
76 | 89 |
77 case ${WORKON_CMD} in | 90 case ${WORKON_CMD} in |
78 start) ebuild_to_live "${ATOM_LIST}" ;; | 91 start) ebuild_to_live "${ATOM_LIST}" ;; |
79 stop) ebuild_to_stable "${ATOM_LIST}" ;; | 92 stop) ebuild_to_stable "${ATOM_LIST}" ;; |
80 list) show_live_ebuilds ;; | 93 list) show_live_ebuilds ;; |
81 *) die "valid cros_workon commands: start|stop|list" ;; | 94 forall) ebuild_forall "${ATOM_LIST}" ;; |
95 *) die "invalid cros_workon command" ;; | |
82 esac | 96 esac |
OLD | NEW |