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, |
(...skipping 17 matching lines...) Expand all Loading... |
28 DEFINE_string command "git status" \ | 28 DEFINE_string command "git status" \ |
29 "The command to be run by forall." | 29 "The command to be run by forall." |
30 DEFINE_boolean all "${FLAGS_FALSE}" \ | 30 DEFINE_boolean all "${FLAGS_FALSE}" \ |
31 "Apply to all possible packages for the given command" | 31 "Apply to all possible packages for the given command" |
32 | 32 |
33 FLAGS_HELP="usage: $0 <command> [flags] [<list of packages>|--all] | 33 FLAGS_HELP="usage: $0 <command> [flags] [<list of packages>|--all] |
34 commands: | 34 commands: |
35 start: Moves an ebuild to live (intended to support development) | 35 start: Moves an ebuild to live (intended to support development) |
36 stop: Moves an ebuild to stable (use last known good) | 36 stop: Moves an ebuild to stable (use last known good) |
37 list: List of live ebuilds (workon ebuilds if --all) | 37 list: List of live ebuilds (workon ebuilds if --all) |
| 38 list-all: List all of the live ebuilds for all setup boards |
38 iterate: For each ebuild, cd to the source dir and run a commond" | 39 iterate: For each ebuild, cd to the source dir and run a commond" |
39 FLAGS "$@" || exit 1 | 40 FLAGS "$@" || exit 1 |
40 eval set -- "${FLAGS_ARGV}" | 41 eval set -- "${FLAGS_ARGV}" |
41 | 42 |
42 | 43 |
43 # eat the workon command keywords: start, stop or list. | 44 # eat the workon command keywords: start, stop or list. |
44 WORKON_CMD=$1 | 45 WORKON_CMD=$1 |
45 shift | 46 shift |
46 | 47 |
47 | 48 |
48 # Board dir config | 49 # Board dir config |
49 | 50 |
50 # If both are specified, just use host, because board does not | 51 # If both are specified, just use host, because board does not |
51 # have to be specified and may come from default, in which case | 52 # have to be specified and may come from default, in which case |
52 # there's no way to override. | 53 # there's no way to override. |
53 [ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \ | 54 [ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \ |
54 FLAGS_board="" # kill board | 55 FLAGS_board="" # kill board |
55 [ -z "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \ | 56 [ -z "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \ |
| 57 [ "${WORKON_CMD}" != "list-all" ] && \ |
56 die "You must specify either --host or --board=" | 58 die "You must specify either --host or --board=" |
57 | 59 |
58 if [ -n "${FLAGS_board}" ]; then | 60 if [ -n "${FLAGS_board}" ]; then |
59 BOARD_DIR=/build/"${FLAGS_board}" # --board specified | 61 BOARD_DIR=/build/"${FLAGS_board}" # --board specified |
60 EQUERYCMD=equery-"${FLAGS_board}" | 62 EQUERYCMD=equery-"${FLAGS_board}" |
61 EBUILDCMD=ebuild-"${FLAGS_board}" | 63 EBUILDCMD=ebuild-"${FLAGS_board}" |
62 BOARD_STR="${FLAGS_board}" | 64 BOARD_STR="${FLAGS_board}" |
63 BOARD_KEYWORD="$(portageq-${FLAGS_board} envvar ARCH)" | 65 BOARD_KEYWORD="$(portageq-${FLAGS_board} envvar ARCH)" |
64 else | 66 else |
65 BOARD_DIR="" # --host specified | 67 BOARD_DIR="" # --host specified |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 done | 131 done |
130 | 132 |
131 echo "${names}" | 133 echo "${names}" |
132 } | 134 } |
133 | 135 |
134 # Display ebuilds currently part of the live branch and open for development. | 136 # Display ebuilds currently part of the live branch and open for development. |
135 show_live_ebuilds () { | 137 show_live_ebuilds () { |
136 sed -n 's/^[~=]\(.*\)-9999$/\1/p' "${WORKON_FILE}" | 138 sed -n 's/^[~=]\(.*\)-9999$/\1/p' "${WORKON_FILE}" |
137 } | 139 } |
138 | 140 |
| 141 # Display ebuilds currently part of the live branch and open for development |
| 142 # for any board that currently has live ebuilds. |
| 143 show_all_live_ebuilds () { |
| 144 for workon_file in ${WORKON_DIR}/*; do |
| 145 if [ -s "${workon_file}" ]; then |
| 146 echo -e "${V_BOLD_GREEN}$(basename ${workon_file}):${V_VIDOFF}" |
| 147 sed -n 's/^[~=]\(.*\)-9999$/ \1/p' "${workon_file}" |
| 148 echo "" |
| 149 fi |
| 150 done |
| 151 } |
| 152 |
139 # This is called only for "cros-workon start". We dont handle the "stop" case si
nce the local changes are ignored anyway since the 9999.ebuild is masked and we
dont want to deal with what to do with the user's local changes. | 153 # This is called only for "cros-workon start". We dont handle the "stop" case si
nce the local changes are ignored anyway since the 9999.ebuild is masked and we
dont want to deal with what to do with the user's local changes. |
140 regen_manifest_and_sync() { | 154 regen_manifest_and_sync() { |
141 # Nothing to do unless you are working on the minilayout | 155 # Nothing to do unless you are working on the minilayout |
142 local manifest=${CHROOT_TRUNK_DIR}/.repo/manifest.xml | 156 local manifest=${CHROOT_TRUNK_DIR}/.repo/manifest.xml |
143 if [ $(basename $(readlink -f ${manifest})) != "minilayout.xml" ]; then | 157 if [ $(basename $(readlink -f ${manifest})) != "minilayout.xml" ]; then |
144 return | 158 return |
145 fi | 159 fi |
146 | 160 |
147 for pkgname in $(show_live_ebuilds); do | 161 for pkgname in $(show_live_ebuilds); do |
148 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) | 162 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${atom}) info) | 215 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${atom}) info) |
202 (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}") | 216 (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}") |
203 done | 217 done |
204 } | 218 } |
205 | 219 |
206 # --all makes commands operate on different lists | 220 # --all makes commands operate on different lists |
207 if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then | 221 if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then |
208 case ${WORKON_CMD} in | 222 case ${WORKON_CMD} in |
209 start) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});; | 223 start) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});; |
210 stop|iterate) ATOM_LIST=$(show_live_ebuilds);; | 224 stop|iterate) ATOM_LIST=$(show_live_ebuilds);; |
211 list) ;; | 225 list|list-all) ;; |
212 *) die "--all is invalid for the given command";; | 226 *) die "--all is invalid for the given command";; |
213 esac | 227 esac |
214 else # not selected --all | 228 else # not selected --all |
215 case ${WORKON_CMD} in | 229 case ${WORKON_CMD} in |
216 start|stop|iterate) | 230 start|stop|iterate) |
217 ATOM_LIST=$@ | 231 ATOM_LIST=$@ |
218 if [ -z "${ATOM_LIST}" ]; then | 232 if [ -z "${ATOM_LIST}" ]; then |
219 die "${WORKON_CMD}: No packages specified" | 233 die "${WORKON_CMD}: No packages specified" |
220 elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then | 234 elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then |
221 die "Error parsing package list" | 235 die "Error parsing package list" |
222 fi;; | 236 fi;; |
223 *) ;; | 237 *) ;; |
224 esac | 238 esac |
225 fi | 239 fi |
226 | 240 |
227 case ${WORKON_CMD} in | 241 case ${WORKON_CMD} in |
228 start) ebuild_to_live "${ATOM_LIST}" ;; | 242 start) ebuild_to_live "${ATOM_LIST}" ;; |
229 stop) ebuild_to_stable "${ATOM_LIST}" ;; | 243 stop) ebuild_to_stable "${ATOM_LIST}" ;; |
230 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko
n_ebuilds ${BOARD_KEYWORD} ;; | 244 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko
n_ebuilds ${BOARD_KEYWORD} ;; |
| 245 list-all) show_all_live_ebuilds ;; |
231 iterate)ebuild_iterate "${ATOM_LIST}" ;; | 246 iterate)ebuild_iterate "${ATOM_LIST}" ;; |
232 *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; | 247 *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; |
233 esac | 248 esac |
OLD | NEW |