Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: cros_workon

Issue 3022003: cros-workon: change forall into iterate (Closed) Base URL: ssh://gitrw.chromium.org/crosutils
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12
13 # Load common constants. This should be the first executable line. 13 # Load common constants. This should be the first executable line.
14 # 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.
15 . "$(dirname "$0")/common.sh" 15 . "$(dirname "$0")/common.sh"
16 16
17 # Script must be run inside the chroot 17 # Script must be run inside the chroot
18 restart_in_chroot_if_needed $* 18 restart_in_chroot_if_needed $*
19 get_default_board 19 get_default_board
20 20
21 DEFINE_string board "${DEFAULT_BOARD}" \ 21 DEFINE_string board "${DEFAULT_BOARD}" \
22 "The board to set package keywords for." 22 "The board to set package keywords for."
23 DEFINE_boolean host "${FLAGS_FALSE}" \ 23 DEFINE_boolean host "${FLAGS_FALSE}" \
24 "Uses the host instead of board" 24 "Uses the host instead of board"
25 DEFINE_string command "git status" \ 25 DEFINE_string command "git status" \
26 "The command to be run by forall." 26 "The command to be run by forall."
27 DEFINE_boolean all "${FLAGS_FALSE}" \ 27 DEFINE_boolean all "${FLAGS_FALSE}" \
28 "Apply to all possible packages for the given command" 28 "Apply to all possible packages for the given command"
29 29
30 FLAGS_HELP="usage: $0 <command> [flags] 30 FLAGS_HELP="usage: $0 <command> [flags] [<list of packages>|--all]
31 commands: 31 commands:
32 start: Moves an ebuild to live (intended to support development) 32 start: Moves an ebuild to live (intended to support development)
33 stop: Moves an ebuild to stable (use last known good) 33 stop: Moves an ebuild to stable (use last known good)
34 list: List of live ebuilds (workon ebuilds if --all) 34 list: List of live ebuilds (workon ebuilds if --all)
35 forall: For each ebuild, cd to the source dir and run a commond" 35 iterate: For each ebuild, cd to the source dir and run a commond"
36 FLAGS "$@" || exit 1 36 FLAGS "$@" || exit 1
37 eval set -- "${FLAGS_ARGV}" 37 eval set -- "${FLAGS_ARGV}"
38 38
39 39
40 # eat the workon command keywords: start, stop or list. 40 # eat the workon command keywords: start, stop or list.
41 WORKON_CMD=$1 41 WORKON_CMD=$1
42 shift 42 shift
43 43
44 44
45 # board dir config 45 # board dir config
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 sudo bash -c "grep -v '^~${atom}-9999\$' \"${UNMASK_FILE}\" > \ 137 sudo bash -c "grep -v '^~${atom}-9999\$' \"${UNMASK_FILE}\" > \
138 \"${UNMASK_FILE}+\"" 138 \"${UNMASK_FILE}+\""
139 sudo mv "${UNMASK_FILE}+" "${UNMASK_FILE}" 139 sudo mv "${UNMASK_FILE}+" "${UNMASK_FILE}"
140 else 140 else
141 warn "Not working on ${atom}" 141 warn "Not working on ${atom}"
142 fi 142 fi
143 done 143 done
144 } 144 }
145 145
146 # Run a command on all or a set of repos. 146 # Run a command on all or a set of repos.
147 ebuild_forall() { 147 ebuild_iterate() {
148 local atoms=$1 148 local atoms=$1
149 149
150 for atom in ${atoms}; do 150 for atom in ${atoms}; do
151 info "Running \"${FLAGS_command}\" on ${atom}" 151 info "Running \"${FLAGS_command}\" on ${atom}"
152 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${atom}) info) 152 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${atom}) info)
153 (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}") 153 (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}")
154 done 154 done
155 } 155 }
156 156
157 show_workon_ebuilds() { 157 show_workon_ebuilds() {
158 pushd "${BOARD_DIR}"/etc/ 1> /dev/null 158 pushd "${BOARD_DIR}"/etc/ 1> /dev/null
159 source make.conf 159 source make.conf
160 popd 1> /dev/null 160 popd 1> /dev/null
161 local CROS_OVERLAYS="${PORTDIR_OVERLAY}" 161 local CROS_OVERLAYS="${PORTDIR_OVERLAY}"
162 162
163 for overlay in ${CROS_OVERLAYS}; do 163 for overlay in ${CROS_OVERLAYS}; do
164 pushd ${overlay} 1> /dev/null 164 pushd ${overlay} 1> /dev/null
165 find . -name '*.ebuild' | xargs fgrep cros-workon | \ 165 find . -name '*.ebuild' | xargs fgrep cros-workon | \
166 awk -F / '{ print $2 "/" $3 }' | uniq | sort 166 awk -F / '{ print $2 "/" $3 }' | uniq | sort
167 popd 1> /dev/null 167 popd 1> /dev/null
168 done 168 done
169 } 169 }
170 170
171 # --all makes commands operate on different lists 171 # --all makes commands operate on different lists
172 if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then 172 if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then
173 case ${WORKON_CMD} in 173 case ${WORKON_CMD} in
174 start) ATOM_LIST=$(show_workon_ebuilds);; 174 start) ATOM_LIST=$(show_workon_ebuilds);;
175 stop) ATOM_LIST=$(show_live_ebuilds);; 175 stop|iterate) ATOM_LIST=$(show_live_ebuilds);;
176 list) ;; 176 list) ;;
177 *) die "--all is invalid for the given command";; 177 *) die "--all is invalid for the given command";;
178 esac 178 esac
179 else # not selected --all 179 else # not selected --all
180 ATOM_LIST=$@
181 case ${WORKON_CMD} in 180 case ${WORKON_CMD} in
182 start|stop) 181 start|stop|iterate)
182 ATOM_LIST=$@
183 if [ -z "${ATOM_LIST}" ]; then 183 if [ -z "${ATOM_LIST}" ]; then
184 die "${WORKON_CMD}: No packages specified" 184 die "${WORKON_CMD}: No packages specified"
185 elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then 185 elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then
186 die "Error parsing package list" 186 die "Error parsing package list"
187 fi;; 187 fi;;
188 forall)
189 if [ -z "${ATOM_LIST}" ]; then
190 ATOM_LIST=$(show_workon_ebuilds)
191 elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then
192 die "Error parsing package list"
193 fi;;
194 *) ;; 188 *) ;;
195 esac 189 esac
196 fi 190 fi
197 191
198 case ${WORKON_CMD} in 192 case ${WORKON_CMD} in
199 start) ebuild_to_live "${ATOM_LIST}" ;; 193 start) ebuild_to_live "${ATOM_LIST}" ;;
200 stop) ebuild_to_stable "${ATOM_LIST}" ;; 194 stop) ebuild_to_stable "${ATOM_LIST}" ;;
201 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko n_ebuilds ;; 195 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko n_ebuilds ;;
202 forall) ebuild_forall "${ATOM_LIST}" ;; 196 iterate)ebuild_iterate "${ATOM_LIST}" ;;
203 *) die "invalid cros_workon command" ;; 197 *) die "invalid cros_workon command" ;;
204 esac 198 esac
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698